From: Joseph Huber Date: Wed, 1 Feb 2023 18:01:44 +0000 (-0600) Subject: [LinkerWrapper] Fix passing `-rpath` directly to clang X-Git-Tag: upstream/17.0.6~18920 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=51ff5481146475afc869cf54ebc0b46d9da15a14;p=platform%2Fupstream%2Fllvm.git [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. --- diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp index 6981e12..2980044 100644 --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp @@ -396,9 +396,11 @@ Expected clang(ArrayRef 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)); }