Skip to content

Commit f18e87c

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 4d2b066 commit f18e87c

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
@@ -1022,7 +1022,10 @@ ToolChain::getTargetSubDirPath(StringRef BaseDir) const {
10221022
}
10231023

10241024
std::optional<std::string> ToolChain::getRuntimePath() const {
1025-
SmallString<128> P(D.ResourceDir);
1025+
SmallString<128> P(D.SysRoot);
1026+
StringRef ClangLibdirBasename(CLANG_INSTALL_LIBDIR_BASENAME);
1027+
llvm::sys::path::append(P, "/usr/", ClangLibdirBasename, "clang",
1028+
CLANG_VERSION_STRING);
10261029
llvm::sys::path::append(P, "lib");
10271030
if (auto Ret = getTargetSubDirPath(P))
10281031
return Ret;
@@ -1050,7 +1053,10 @@ ToolChain::path_list ToolChain::getArchSpecificLibPaths() const {
10501053
path_list Paths;
10511054

10521055
auto AddPath = [&](const ArrayRef<StringRef> &SS) {
1053-
SmallString<128> Path(getDriver().ResourceDir);
1056+
SmallString<128> Path(getDriver().SysRoot);
1057+
StringRef ClangLibdirBasename(CLANG_INSTALL_LIBDIR_BASENAME);
1058+
llvm::sys::path::append(Path, "/usr/", ClangLibdirBasename, "clang",
1059+
CLANG_VERSION_STRING);
10541060
llvm::sys::path::append(Path, "lib");
10551061
for (auto &S : SS)
10561062
llvm::sys::path::append(Path, S);

0 commit comments

Comments
 (0)