Skip to content

Commit d03f470

Browse files
authored
[Clang] Make '-frtlib-add-rpath' include the standard library directory (#86217)
Summary: The original intention of the `openmp-add-rpath` option was to add the rpath to the language runtime directory. However, the current implementation only adds it to the compiler's resource directory. This patch adds support for appending the `-rpath` to the compiler's standard library directory as well. Currently this is `<exe>/../lib/<triple>`.
1 parent c41286a commit d03f470

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,11 @@ void tools::addArchSpecificRPath(const ToolChain &TC, const ArgList &Args,
11421142
options::OPT_fno_rtlib_add_rpath, false))
11431143
return;
11441144

1145-
for (const auto &CandidateRPath : TC.getArchSpecificLibPaths()) {
1145+
SmallVector<std::string> CandidateRPaths(TC.getArchSpecificLibPaths());
1146+
if (const auto CandidateRPath = TC.getStdlibPath())
1147+
CandidateRPaths.emplace_back(*CandidateRPath);
1148+
1149+
for (const auto &CandidateRPath : CandidateRPaths) {
11461150
if (TC.getVFS().exists(CandidateRPath)) {
11471151
CmdArgs.push_back("-rpath");
11481152
CmdArgs.push_back(Args.MakeArgString(CandidateRPath));

0 commit comments

Comments
 (0)