-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Clang: Return new layout path if cannot find CRT #87319
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
In ToolChain::getCompilerRT: // If none is found, use a file name from the new layout, which may get // printed in an error message, aiding users in knowing what Clang is // looking for. But in current code, the old layout is printed if no libclang_rt.builtin is found with cmd like: ./bin/clang --target=aarch64-linux-gnu -rtlib=compiler-rt hello.c
@llvm/pr-subscribers-clang Author: YunQiang Su (wzssyqa) ChangesIn ToolChain::getCompilerRT: But in current code, the old layout is printed if no libclang_rt.builtin is found with cmd like: aarch64-linux-gnu/bin/ld: cannot find <path>/lib/clang/19/lib/linux/libclang_rt.builtins-aarch64.a: No such file or directory Full diff: https://github.com/llvm/llvm-project/pull/87319.diff 1 Files Affected:
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 03450fc0f57b93..3b5960992a9dd1 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -692,12 +692,21 @@ std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component,
buildCompilerRTBasename(Args, Component, Type, /*AddArch=*/true);
SmallString<128> OldPath(getCompilerRTPath());
llvm::sys::path::append(OldPath, CRTBasename);
- if (Path.empty() || getVFS().exists(OldPath))
+ if (getVFS().exists(OldPath))
return std::string(OldPath);
// If none is found, use a file name from the new layout, which may get
// printed in an error message, aiding users in knowing what Clang is
// looking for.
+ if (Path.empty()) {
+ CRTBasename =
+ buildCompilerRTBasename(Args, Component, Type, /*AddArch=*/false);
+ SmallString<128> NewP(D.ResourceDir);
+ llvm::sys::path::append(NewP, "lib");
+ llvm::sys::path::append(NewP, getTriple().str());
+ llvm::sys::path::append(NewP, CRTBasename);
+ return std::string(NewP);
+ }
return std::string(Path);
}
|
@llvm/pr-subscribers-clang-driver Author: YunQiang Su (wzssyqa) ChangesIn ToolChain::getCompilerRT: But in current code, the old layout is printed if no libclang_rt.builtin is found with cmd like: aarch64-linux-gnu/bin/ld: cannot find <path>/lib/clang/19/lib/linux/libclang_rt.builtins-aarch64.a: No such file or directory Full diff: https://github.com/llvm/llvm-project/pull/87319.diff 1 Files Affected:
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 03450fc0f57b93..3b5960992a9dd1 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -692,12 +692,21 @@ std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component,
buildCompilerRTBasename(Args, Component, Type, /*AddArch=*/true);
SmallString<128> OldPath(getCompilerRTPath());
llvm::sys::path::append(OldPath, CRTBasename);
- if (Path.empty() || getVFS().exists(OldPath))
+ if (getVFS().exists(OldPath))
return std::string(OldPath);
// If none is found, use a file name from the new layout, which may get
// printed in an error message, aiding users in knowing what Clang is
// looking for.
+ if (Path.empty()) {
+ CRTBasename =
+ buildCompilerRTBasename(Args, Component, Type, /*AddArch=*/false);
+ SmallString<128> NewP(D.ResourceDir);
+ llvm::sys::path::append(NewP, "lib");
+ llvm::sys::path::append(NewP, getTriple().str());
+ llvm::sys::path::append(NewP, CRTBasename);
+ return std::string(NewP);
+ }
return std::string(Path);
}
|
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.
I don't think we should add another copy of buildCompilerRTBasename
to getCompilerRT
to make it more complex. Let's keep the discussion in #87150
Replaced by: #87150 |
In ToolChain::getCompilerRT:
If none is found, use a file name from the new layout, which may get
printed in an error message, aiding users in knowing what Clang is
looking for.
But in current code, the old layout is printed if no libclang_rt.builtin is found with cmd like: