tstellar created this revision. tstellar added reviewers: JonChesterfield, MaskRay. Herald added subscribers: guansong, yaxunl. Herald added a project: All. tstellar requested review of this revision. Herald added a reviewer: jdoerfert. Herald added subscribers: cfe-commits, sstefan1. Herald added a project: clang.
Suggested in https://reviews.llvm.org/D118493#3402001 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D142174 Files: clang/lib/Driver/ToolChains/CommonArgs.cpp Index: clang/lib/Driver/ToolChains/CommonArgs.cpp =================================================================== --- clang/lib/Driver/ToolChains/CommonArgs.cpp +++ clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -791,6 +791,13 @@ /*IsLTO=*/true, PluginOptPrefix); } +static bool isSystemPath(const StringRef &path) { + return llvm::StringSwitch<bool>(path) + .Case("/usr/lib", true) + .Case("/usr/lib64", true) + .Default(false); +} + void tools::addOpenMPRuntimeSpecificRPath(const ToolChain &TC, const ArgList &Args, ArgStringList &CmdArgs) { @@ -802,6 +809,11 @@ SmallString<256> DefaultLibPath = llvm::sys::path::parent_path(TC.getDriver().Dir); llvm::sys::path::append(DefaultLibPath, CLANG_INSTALL_LIBDIR_BASENAME); + + // If clang is installed to a 'system path' there is no reason to add rpath. + if (isSystemPath(DefaultLibPath)) + return; + CmdArgs.push_back("-rpath"); CmdArgs.push_back(Args.MakeArgString(DefaultLibPath)); }
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp =================================================================== --- clang/lib/Driver/ToolChains/CommonArgs.cpp +++ clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -791,6 +791,13 @@ /*IsLTO=*/true, PluginOptPrefix); } +static bool isSystemPath(const StringRef &path) { + return llvm::StringSwitch<bool>(path) + .Case("/usr/lib", true) + .Case("/usr/lib64", true) + .Default(false); +} + void tools::addOpenMPRuntimeSpecificRPath(const ToolChain &TC, const ArgList &Args, ArgStringList &CmdArgs) { @@ -802,6 +809,11 @@ SmallString<256> DefaultLibPath = llvm::sys::path::parent_path(TC.getDriver().Dir); llvm::sys::path::append(DefaultLibPath, CLANG_INSTALL_LIBDIR_BASENAME); + + // If clang is installed to a 'system path' there is no reason to add rpath. + if (isSystemPath(DefaultLibPath)) + return; + CmdArgs.push_back("-rpath"); CmdArgs.push_back(Args.MakeArgString(DefaultLibPath)); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits