diff options
author | dim <dim@FreeBSD.org> | 2011-02-24 21:45:58 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2011-02-24 21:45:58 +0000 |
commit | 61338aea40a097bf11d4a72a72bd2975a7c07b30 (patch) | |
tree | de58a8db5b7aa3032c5e08b442badf45e39a2eee /contrib/llvm/tools/clang/lib/Driver/Tools.cpp | |
parent | 591be2888817141405565d27940ddb42af4b40f9 (diff) | |
download | FreeBSD-src-61338aea40a097bf11d4a72a72bd2975a7c07b30.zip FreeBSD-src-61338aea40a097bf11d4a72a72bd2975a7c07b30.tar.gz |
Recently, in upstream clang, a fix was done to add -L/usr/lib to the
arguments passed to ld, when linking. This was to appease configure
scripts in several ports, that grep for such a -L option in "${CC} -v"
output, to determine the startup objects passed to ld. Note ld itself
does not need to be told about /usr/lib, since it has this path builtin
anyway.
However, if clang is built as a bootstrap tool during buildworld, it
should not use *anything* outside ${WORLDTMP} to include or link with.
The upstream fix to add -L/usr/lib breaks this assumption, and can thus
cause libraries from /usr/lib to be linked in during buildworld.
This can result in buildworld dying during linking of zinject, where it
picks up the wrong copy of libzpool.so, eventually leading to:
/usr/obj/usr/src/tmp/lib/libthr.so.3: undefined reference to `_rtld_get_stack_prot'
Fix this issue by not adding any hardcoded paths, but by looping through
the run-time library path list, which is already correctly set for the
bootstrap phase.
Reported by: datastream.freecity@gmail.com
Pointy hat to: dim
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Driver/Tools.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Driver/Tools.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/contrib/llvm/tools/clang/lib/Driver/Tools.cpp b/contrib/llvm/tools/clang/lib/Driver/Tools.cpp index 5a63213..b23c731 100644 --- a/contrib/llvm/tools/clang/lib/Driver/Tools.cpp +++ b/contrib/llvm/tools/clang/lib/Driver/Tools.cpp @@ -3206,7 +3206,12 @@ void freebsd::Link::ConstructJob(Compilation &C, const JobAction &JA, } Args.AddAllArgs(CmdArgs, options::OPT_L); - CmdArgs.push_back("-L/usr/lib"); + + const ToolChain::path_list Paths = getToolChain().getFilePaths(); + for (ToolChain::path_list::const_iterator i = Paths.begin(), e = Paths.end(); + i != e; ++i) + CmdArgs.push_back(Args.MakeArgString(llvm::StringRef("-L") + *i)); + Args.AddAllArgs(CmdArgs, options::OPT_T_Group); Args.AddAllArgs(CmdArgs, options::OPT_e); Args.AddAllArgs(CmdArgs, options::OPT_s); @@ -3568,13 +3573,9 @@ void linuxtools::Link::ConstructJob(Compilation &C, const JobAction &JA, Args.AddAllArgs(CmdArgs, options::OPT_L); const ToolChain::path_list Paths = ToolChain.getFilePaths(); - - for (ToolChain::path_list::const_iterator i = Paths.begin(), - e = Paths.end(); - i != e; ++i) { - const std::string &s = *i; - CmdArgs.push_back(Args.MakeArgString(std::string("-L") + s)); - } + for (ToolChain::path_list::const_iterator i = Paths.begin(), e = Paths.end(); + i != e; ++i) + CmdArgs.push_back(Args.MakeArgString(llvm::StringRef("-L") + *i)); AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs); |