[clang] 51ff548 - [LinkerWrapper] Fix passing `-rpath` directly to clang
Joseph Huber via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 1 10:03:14 PST 2023
Author: Joseph Huber
Date: 2023-02-01T12:03:03-06:00
New Revision: 51ff5481146475afc869cf54ebc0b46d9da15a14
URL: https://github.com/llvm/llvm-project/commit/51ff5481146475afc869cf54ebc0b46d9da15a14
DIFF: https://github.com/llvm/llvm-project/commit/51ff5481146475afc869cf54ebc0b46d9da15a14.diff
LOG: [LinkerWrapper] Fix passing `-rpath` directly to clang
Summary:
This code passed the value of `-rpath` directly to the clang invocation.
If we're using the linker then it'll be fine. However, if the linker is
`gcc` as is the case when doing `-fopenmp-targets=x86_64` then this will
cause problems. This patch adds the `-Wl,-rpath,` to feed it to the
linker correctly.
Added:
Modified:
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
Removed:
################################################################################
diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 6981e124b1062..2980044edd756 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -396,9 +396,11 @@ Expected<StringRef> clang(ArrayRef<StringRef> InputFiles, const ArgList &Args) {
CmdArgs.push_back("-Wl,-Bsymbolic");
CmdArgs.push_back("-shared");
ArgStringList LinkerArgs;
- for (const opt::Arg *Arg :
- Args.filtered(OPT_library, OPT_rpath, OPT_library_path))
+ for (const opt::Arg *Arg : Args.filtered(OPT_library, OPT_library_path))
Arg->render(Args, LinkerArgs);
+ for (const opt::Arg *Arg : Args.filtered(OPT_rpath))
+ LinkerArgs.push_back(
+ Args.MakeArgString("-Wl,-rpath," + StringRef(Arg->getValue())));
llvm::copy(LinkerArgs, std::back_inserter(CmdArgs));
}
More information about the cfe-commits
mailing list