Skip to content

Commit d4cf955

Browse files
committed
clang: Use sysroot relative paths for getArchSpecificLibPaths and getRuntimePath
Clang's default sysroot implementation differs that what we do in OE, and we do it with gcc as well where we install c++ runtime headers in target sysroot, clang does not by default it puts them relative to its own installation and uses resourcedir to point to it. In order to solve this we have to raise this question with respective upstreams or rethink about how we package compiler runtime. Upstream-Status: Inappropriate [OE-Specific] Signed-off-by: Khem Raj <[email protected]>
1 parent 24135d9 commit d4cf955

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

clang/lib/Driver/ToolChain.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,10 @@ ToolChain::getTargetSubDirPath(StringRef BaseDir) const {
10251025
}
10261026

10271027
std::optional<std::string> ToolChain::getRuntimePath() const {
1028-
SmallString<128> P(D.ResourceDir);
1028+
SmallString<128> P(D.SysRoot);
1029+
StringRef ClangLibdirBasename(CLANG_INSTALL_LIBDIR_BASENAME);
1030+
llvm::sys::path::append(P, "/usr/", ClangLibdirBasename, "clang",
1031+
CLANG_VERSION_STRING);
10291032
llvm::sys::path::append(P, "lib");
10301033
if (auto Ret = getTargetSubDirPath(P))
10311034
return Ret;
@@ -1053,7 +1056,10 @@ ToolChain::path_list ToolChain::getArchSpecificLibPaths() const {
10531056
path_list Paths;
10541057

10551058
auto AddPath = [&](const ArrayRef<StringRef> &SS) {
1056-
SmallString<128> Path(getDriver().ResourceDir);
1059+
SmallString<128> Path(getDriver().SysRoot);
1060+
StringRef ClangLibdirBasename(CLANG_INSTALL_LIBDIR_BASENAME);
1061+
llvm::sys::path::append(Path, "/usr/", ClangLibdirBasename, "clang",
1062+
CLANG_VERSION_STRING);
10571063
llvm::sys::path::append(Path, "lib");
10581064
for (auto &S : SS)
10591065
llvm::sys::path::append(Path, S);

0 commit comments

Comments
 (0)