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

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 18 07:53:52 PDT 2024


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

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


>From b6f6cbf7e1819779eeece437daef5bfb9b2a8cd0 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Wed, 18 Sep 2024 09:51:51 -0500
Subject: [PATCH] [Clang] Automatically link the `compiler-rt` for GPUs if
 present

Summary:
This automically links `copmiler-rt` for offloading languages if it
exists in the resource directory.
---
 clang/lib/Driver/ToolChains/Clang.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

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"));
     });
   }
 



More information about the cfe-commits mailing list