-
Notifications
You must be signed in to change notification settings - Fork 14.3k
ohos: fix ohos.c test case error with LLVM_ENABLE_PER_TARGET_RUNTIME_… #121484
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
Conversation
…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
@llvm/pr-subscribers-clang Author: Peng Huang (phuang) Changes…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, Note: OHOS driver doesn't support the old layout, compiler-rt for ${arch}-linux-unknown-ohos targets have to be built with Full diff: https://github.com/llvm/llvm-project/pull/121484.diff 1 Files Affected:
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();
|
@llvm/pr-subscribers-clang-driver Author: Peng Huang (phuang) Changes…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, Note: OHOS driver doesn't support the old layout, compiler-rt for ${arch}-linux-unknown-ohos targets have to be built with Full diff: https://github.com/llvm/llvm-project/pull/121484.diff 1 Files Affected:
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();
|
Can we make |
Sure. I will try adding it. |
There was some desire to, but it seems to have fizzled out: https://discourse.llvm.org/t/rfc-time-to-drop-legacy-runtime-paths/64628 I imagine it'll happen eventually, but it will probably take a while.
I don't know enough about OHOS and its users to be able to say. If you're not sure: I suggest leaving out support for now, and someone who needs it can contribute support for it. But if we do leave support out: good error messages for users who happen to try to use/build it in the wrong configuration are probably essential. |
To add this cmake configure error, where should I look at? any hint? |
Updated the cmake script to output error message if LLVM_ENABLE_PER_TARGET_RUNTIME_DIR is OFF for ohos targets. |
OHOS driver doesn't support old runtime libraries layout, so make cmake configure report error if LLVM_ENABLE_PER_TARGET_RUNTIME_DIR is OFF.
b41e3c3
to
ee85a1c
Compare
We can disable the test on -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF layouts, but I don't find a lit feature that. The usual way is to create a compiler-rt file hierarchy under |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
…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