[lld] r212713 - [mach-o]: support -Z option to skip standard library paths

Tim Northover tnorthover at apple.com
Thu Jul 10 04:46:13 PDT 2014


Author: tnorthover
Date: Thu Jul 10 06:46:13 2014
New Revision: 212713

URL: http://llvm.org/viewvc/llvm-project?rev=212713&view=rev
Log:
[mach-o]: support -Z option to skip standard library paths

Added:
    lld/trunk/test/mach-o/libresolve-z.yaml
Modified:
    lld/trunk/lib/Driver/DarwinLdDriver.cpp
    lld/trunk/lib/Driver/DarwinLdOptions.td

Modified: lld/trunk/lib/Driver/DarwinLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=212713&r1=212712&r2=212713&view=diff
==============================================================================
--- lld/trunk/lib/Driver/DarwinLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/DarwinLdDriver.cpp Thu Jul 10 06:46:13 2014
@@ -302,8 +302,11 @@ bool DarwinLdDriver::parse(int argc, con
     ctx.addModifiedSearchDir(libPath->getValue(), syslibRoots, false);
   }
 
-  ctx.addModifiedSearchDir("/usr/lib", syslibRoots, true);
-  ctx.addModifiedSearchDir("/usr/local/lib", syslibRoots, true);
+  // -Z suppresses the standard search paths.
+  if (!parsedArgs->hasArg(OPT_Z)) {
+    ctx.addModifiedSearchDir("/usr/lib", syslibRoots, true);
+    ctx.addModifiedSearchDir("/usr/local/lib", syslibRoots, true);
+  }
 
   // Now that we've constructed the final set of search paths, print out what
   // we'll be using for testing purposes.

Modified: lld/trunk/lib/Driver/DarwinLdOptions.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdOptions.td?rev=212713&r1=212712&r2=212713&view=diff
==============================================================================
--- lld/trunk/lib/Driver/DarwinLdOptions.td (original)
+++ lld/trunk/lib/Driver/DarwinLdOptions.td Thu Jul 10 06:46:13 2014
@@ -66,6 +66,8 @@ def bundle_loader : Separate<["-"], "bun
 def grp_libs : OptionGroup<"libs">, HelpText<"LIBRARY OPTIONS">;
 def L : JoinedOrSeparate<["-"], "L">,
         HelpText<"Add directory to library search path">, Group<grp_libs>;
+def Z : Flag<["-"], "Z">,
+     HelpText<"Do not search standard directories for libraries or frameworks">;
 def all_load : Flag<["-"], "all_load">,
         HelpText<"Forces all members of all static libraries to be loaded">,
         Group<grp_libs>;

Added: lld/trunk/test/mach-o/libresolve-z.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/mach-o/libresolve-z.yaml?rev=212713&view=auto
==============================================================================
--- lld/trunk/test/mach-o/libresolve-z.yaml (added)
+++ lld/trunk/test/mach-o/libresolve-z.yaml Thu Jul 10 06:46:13 2014
@@ -0,0 +1,21 @@
+# RUN: lld -flavor darwin -arch x86_64 -r -test_libresolution \
+# RUN:        -path_exists /usr/lib \
+# RUN:        -path_exists /usr/local/lib \
+# RUN:        -path_exists /usr/lib/libSystem.dylib \
+# RUN:        -path_exists hasFoo \
+# RUN:        -path_exists hasFoo/libFoo.dylib \
+# RUN:        -path_exists /hasBar \
+# RUN:        -path_exists /hasBar/libBar.dylib \
+# RUN:        -L hasFoo \
+# RUN:        -L /hasBar \
+# RUN:        -Z \
+# RUN:        -lFoo -lBar \
+# RUN: 2>&1 | FileCheck %s
+
+# CHECK: Library search paths:
+# CHECK:     hasFoo
+# CHECK:     /hasBar
+# CHECK-NOT:     /usr/lib
+# CHECK-NOT:     /usr/local/lib
+# CHECK: Found library hasFoo/libFoo.dylib
+# CHECK: Found library /hasBar/libBar.dylib





More information about the llvm-commits mailing list