Skip to content

Commit 6e4aebd

Browse files
jhuber6chencha3
authored andcommitted
[Clang] Make '-frtlib-add-rpath' include the standard library directory (llvm#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 7f5ad7c commit 6e4aebd

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)