Skip to content

[Flang] Link -lflang_rt.runtime if available on the device #132737

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 24, 2025

Conversation

jhuber6
Copy link
Contributor

@jhuber6 jhuber6 commented Mar 24, 2025

Summary:
Now that we can build the Fortran runtime on the GPU (mostly) we should
be able to implicitly link it if it exists. This matches the normal
behavior where it is included implicity. No tests because it
would require a full VFS and is fairly trivial.

Summary:
Now that we can build the Fortran runtime on the GPU (mostly) we should
be able to implicitly link it if it exists. This matches the normal
behavior where it is included implicity. No tests because it
would require a full VFS and is fairly trivial.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Mar 24, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 24, 2025

@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Joseph Huber (jhuber6)

Changes

Summary:
Now that we can build the Fortran runtime on the GPU (mostly) we should
be able to implicitly link it if it exists. This matches the normal
behavior where it is included implicity. No tests because it
would require a full VFS and is fairly trivial.


Full diff: https://github.com/llvm/llvm-project/pull/132737.diff

1 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/Clang.cpp (+5)
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index fb3ed2db0e3c0..d7da2af321e7b 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -9337,6 +9337,11 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
         CmdArgs.push_back(
             Args.MakeArgString("--device-linker=" + TC.getTripleString() + "=" +
                                "-lclang_rt.builtins"));
+      bool HasFlangRT = HasCompilerRT && C.getDriver().IsFlangMode();
+      if (HasCompilerRT)
+        CmdArgs.push_back(
+            Args.MakeArgString("--device-linker=" + TC.getTripleString() + "=" +
+                               "-lflang_rt.runtime"));
     });
   }
 

Copy link
Member

@Meinersbur Meinersbur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jhuber6 jhuber6 merged commit b1a8e6e into llvm:main Mar 24, 2025
11 checks passed
@jhuber6 jhuber6 deleted the LinkFlangRT branch March 24, 2025 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants