[clang] ohos: fix ohos.c test case error with LLVM_ENABLE_PER_TARGET_RUNTIME_… (PR #121484)

via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 2 07:34:59 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Peng Huang (phuang)

<details>
<summary>Changes</summary>

…DIR=OFF

The problem is because libclang_rt.builtins-{arch}.a for all the arches will be installed into the same folder with old compiler rt layout (LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF) and OHOS driver will get a wrong library in this case. To fix the problem, `-ohos` suffix will be added to the ohos builtin libraries search path.

Note: OHOS driver doesn't support the old layout, compiler-rt for ${arch}-linux-unknown-ohos targets have to be built with
LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON

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


1 Files Affected:

- (modified) clang/lib/Driver/ToolChain.cpp (+5-1) 


``````````diff
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 9f174fbda398b5..06ff0918245ea4 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -745,7 +745,11 @@ std::string ToolChain::buildCompilerRTBasename(const llvm::opt::ArgList &Args,
   std::string ArchAndEnv;
   if (AddArch) {
     StringRef Arch = getArchNameForCompilerRTLib(*this, Args);
-    const char *Env = TT.isAndroid() ? "-android" : "";
+    const char *Env = "";
+    if (TT.isAndroid())
+      Env = "-android";
+    else if (TT.isOHOSFamily())
+      Env = "-ohos";
     ArchAndEnv = ("-" + Arch + Env).str();
   }
   return (Prefix + Twine("clang_rt.") + Component + ArchAndEnv + Suffix).str();

``````````

</details>


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


More information about the cfe-commits mailing list