diff options
| -rw-r--r-- | lld/lib/Driver/DarwinLdDriver.cpp | 7 | ||||
| -rw-r--r-- | lld/lib/Driver/DarwinLdOptions.td | 2 | ||||
| -rw-r--r-- | lld/test/mach-o/libresolve-z.yaml | 21 |
3 files changed, 28 insertions, 2 deletions
diff --git a/lld/lib/Driver/DarwinLdDriver.cpp b/lld/lib/Driver/DarwinLdDriver.cpp index 34eca5da39a..27946a79f06 100644 --- a/lld/lib/Driver/DarwinLdDriver.cpp +++ b/lld/lib/Driver/DarwinLdDriver.cpp @@ -302,8 +302,11 @@ bool DarwinLdDriver::parse(int argc, const char *argv[], 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. diff --git a/lld/lib/Driver/DarwinLdOptions.td b/lld/lib/Driver/DarwinLdOptions.td index a7dd40afe51..7aa67773e17 100644 --- a/lld/lib/Driver/DarwinLdOptions.td +++ b/lld/lib/Driver/DarwinLdOptions.td @@ -66,6 +66,8 @@ def bundle_loader : Separate<["-"], "bundle_loader">, 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>; diff --git a/lld/test/mach-o/libresolve-z.yaml b/lld/test/mach-o/libresolve-z.yaml new file mode 100644 index 00000000000..8edc28d686c --- /dev/null +++ b/lld/test/mach-o/libresolve-z.yaml @@ -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 |

