[PATCH] [Driver] Use paths explicitly provided by the -L option before default paths

Simon Atanasyan simon at atanasyan.com
Thu Feb 26 03:09:37 PST 2015


Hi shankarke, ruiu,

User should be able to override default search paths using the `-L` option.

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D7902

Files:
  lib/Driver/GnuLdDriver.cpp
  test/Driver/Inputs/libtest.a
  test/Driver/def-lib-search.test

Index: lib/Driver/GnuLdDriver.cpp
===================================================================
--- lib/Driver/GnuLdDriver.cpp
+++ lib/Driver/GnuLdDriver.cpp
@@ -423,10 +423,6 @@
   if (auto *arg = parsedArgs->getLastArg(OPT_sysroot))
     ctx->setSysroot(arg->getValue());
 
-  // Add the default search directory specific to the target.
-  if (!parsedArgs->hasArg(OPT_nostdlib))
-    addPlatformSearchDirs(*ctx, triple, baseTriple);
-
   // Handle --demangle option(For compatibility)
   if (parsedArgs->hasArg(OPT_demangle))
     ctx->setDemangleSymbols(true);
@@ -545,6 +541,10 @@
   for (auto *arg : parsedArgs->filtered(OPT_L))
     ctx->addSearchPath(arg->getValue());
 
+  // Add the default search directory specific to the target.
+  if (!parsedArgs->hasArg(OPT_nostdlib))
+    addPlatformSearchDirs(*ctx, triple, baseTriple);
+
   for (auto *arg : parsedArgs->filtered(OPT_u))
     ctx->addInitialUndefinedSymbol(arg->getValue());
 
Index: test/Driver/Inputs/libtest.a
===================================================================
--- /dev/null
+++ test/Driver/Inputs/libtest.a
@@ -0,0 +1 @@
+!<arch>
Index: test/Driver/def-lib-search.test
===================================================================
--- /dev/null
+++ test/Driver/def-lib-search.test
@@ -0,0 +1,8 @@
+# Check that search paths explicitly provided by the -L option
+# are used in search before default paths. 
+
+RUN: not lld -flavor gnu -target x86_64 -t -ltest \
+RUN:         --sysroot=%p/Inputs -L%p/Inputs 2> %t
+RUN: FileCheck %s < %t
+
+CHECK: {{[^ ]+}}{{[\\/]}}Inputs{{[\\/]}}libtest.a

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7902.20740.patch
Type: text/x-patch
Size: 1590 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150226/40d0be67/attachment.bin>


More information about the llvm-commits mailing list