[clang] [compiler-rt] ohos: fix ohos.c test case error with LLVM_ENABLE_PER_TARGET_RUNTIME_… (PR #121484)
Peng Huang via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 2 10:30:56 PST 2025
https://github.com/phuang updated https://github.com/llvm/llvm-project/pull/121484
>From 14d95fba0e0142be90d8c72dc8baed7cefc2268d Mon Sep 17 00:00:00 2001
From: Peng Huang <shawn.p.huang at gmail.com>
Date: Thu, 2 Jan 2025 10:21:00 -0500
Subject: [PATCH 1/2] ohos: fix ohos.c test case error with
LLVM_ENABLE_PER_TARGET_RUNTIME_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,
${arch}-linux-unknown-ohos targets have to be built with
LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
---
clang/lib/Driver/ToolChain.cpp | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
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();
>From ee85a1c0b141fd6bf539b1945f513e2d63d01c5b Mon Sep 17 00:00:00 2001
From: Peng Huang <shawn.p.huang at gmail.com>
Date: Thu, 2 Jan 2025 13:07:24 -0500
Subject: [PATCH 2/2] ohos: make configure fail if
LLVM_ENABLE_PER_TARGET_RUNTIME_DIR is OFF
OHOS driver doesn't support old runtime libraries layout, so make
cmake configure report error if LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
is OFF.
---
compiler-rt/cmake/Modules/CompilerRTUtils.cmake | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
index 379e2c25949cb4..9189c010575569 100644
--- a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -510,6 +510,11 @@ function(get_compiler_rt_target arch variable)
endfunction()
function(get_compiler_rt_install_dir arch install_dir)
+ if (NOT LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
+ if (LLVM_TARGET_TRIPLE MATCHES "ohos")
+ message(FATAL_ERROR "${LLVM_TARGET_TRIPLE} requires LLVM_ENABLE_PER_TARGET_RUNTIME_DIR")
+ endif()
+ endif()
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
get_compiler_rt_target(${arch} target)
set(${install_dir} ${COMPILER_RT_INSTALL_LIBRARY_DIR}/${target} PARENT_SCOPE)
More information about the llvm-commits
mailing list