From 30aba033c89d85e8904708abb313c37df50d77ac Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 15 Nov 2012 23:02:06 +0100 Subject: [PATCH] Don't push -L-l/-L-L using -Xlinker. --- driver/linker.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/driver/linker.cpp b/driver/linker.cpp index d96d5911..211234f3 100644 --- a/driver/linker.cpp +++ b/driver/linker.cpp @@ -188,7 +188,11 @@ int linkObjToBinaryGcc(bool sharedLib) for (unsigned i = 0; i < global.params.linkswitches->dim; i++) { char *p = static_cast(global.params.linkswitches->data[i]); - args.push_back("-Xlinker"); + // Don't push -l and -L switches using -Xlinker, but pass them directly + // to GCC. This makes sure user-defined paths take precedence over + // GCC's builtin LIBRARY_PATHs. + if (!p[0] || !(p[0] == '-' && (p[1] == 'l' || p[1] == 'L'))) + args.push_back("-Xlinker"); args.push_back(p); }