[clang] [Clang] Automatically link the `compiler-rt` for GPUs if present (PR #109152)

via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 18 07:54:25 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Joseph Huber (jhuber6)

<details>
<summary>Changes</summary>

Summary:
This automically links `copmiler-rt` for offloading languages if it
exists in the resource directory.


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


1 Files Affected:

- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+6) 


``````````diff
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index c00df5f5bc729c..1e615214580134 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -9239,6 +9239,12 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
         CmdArgs.push_back(Args.MakeArgString(
             "--device-linker=" + TC.getTripleString() + "=" + "-lm"));
       }
+      auto HasCompilerRT = getToolChain().getVFS().exists(
+          TC.getCompilerRT(Args, "builtins", ToolChain::FT_Static));
+      if (HasCompilerRT)
+        CmdArgs.push_back(
+            Args.MakeArgString("--device-linker=" + TC.getTripleString() + "=" +
+                               "-lclang_rt.builtins"));
     });
   }
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/109152


More information about the cfe-commits mailing list