summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/lib/Driver/DarwinLdDriver.cpp8
-rw-r--r--lld/lib/Driver/DarwinLdOptions.td2
-rw-r--r--lld/test/mach-o/libresolve-one-syslibroot.yaml8
-rw-r--r--lld/test/mach-o/libresolve-simple.yaml12
-rw-r--r--lld/test/mach-o/libresolve-user-paths.yaml20
5 files changed, 45 insertions, 5 deletions
diff --git a/lld/lib/Driver/DarwinLdDriver.cpp b/lld/lib/Driver/DarwinLdDriver.cpp
index 64107d80629..34eca5da39a 100644
--- a/lld/lib/Driver/DarwinLdDriver.cpp
+++ b/lld/lib/Driver/DarwinLdDriver.cpp
@@ -296,8 +296,12 @@ bool DarwinLdDriver::parse(int argc, const char *argv[],
syslibRoots.push_back(syslibRoot->getValue());
}
- // FIXME: handle -L options: these get added *before* the default paths,
- // possibly modified by any syslibroot options.
+ // Paths specified with -L come first, and are not considered system paths for
+ // the case where there is precisely 1 -syslibroot.
+ for (auto libPath : parsedArgs->filtered(OPT_L)) {
+ ctx.addModifiedSearchDir(libPath->getValue(), syslibRoots, false);
+ }
+
ctx.addModifiedSearchDir("/usr/lib", syslibRoots, true);
ctx.addModifiedSearchDir("/usr/local/lib", syslibRoots, true);
diff --git a/lld/lib/Driver/DarwinLdOptions.td b/lld/lib/Driver/DarwinLdOptions.td
index f88f92cee52..a7dd40afe51 100644
--- a/lld/lib/Driver/DarwinLdOptions.td
+++ b/lld/lib/Driver/DarwinLdOptions.td
@@ -64,7 +64,7 @@ def bundle_loader : Separate<["-"], "bundle_loader">,
// library options
def grp_libs : OptionGroup<"libs">, HelpText<"LIBRARY OPTIONS">;
-def L : Joined<["-"], "L">,
+def L : JoinedOrSeparate<["-"], "L">,
HelpText<"Add directory to library search path">, Group<grp_libs>;
def all_load : Flag<["-"], "all_load">,
HelpText<"Forces all members of all static libraries to be loaded">,
diff --git a/lld/test/mach-o/libresolve-one-syslibroot.yaml b/lld/test/mach-o/libresolve-one-syslibroot.yaml
index f447a9b55c8..bf2e2a3bfc6 100644
--- a/lld/test/mach-o/libresolve-one-syslibroot.yaml
+++ b/lld/test/mach-o/libresolve-one-syslibroot.yaml
@@ -2,8 +2,11 @@
# RUN: -path_exists /usr/lib \
# RUN: -path_exists /Applications/MySDK/usr/local/lib \
# RUN: -path_exists /Applications/MySDK/usr/local/lib/libSystem.a \
+# RUN: -path_exists /hasFoo \
+# RUN: -path_exists /hasFoo/foo.o \
# RUN: -syslibroot /Applications/MySDK \
-# RUN: -lSystem \
+# RUN: -L/hasFoo \
+# RUN: -lSystem -lfoo.o \
# RUN: 2>&1 | FileCheck %s
# When just one -syslibroot is specified, we apparently want to skip *system*
@@ -12,8 +15,11 @@
# no mention of /usr/lib.
# CHECK: Library search paths:
+# CHECK: /hasFoo
# CHECK-NOT: /usr/lib
# CHECK-NOT: /usr/local/lib
# CHECK: /Applications/MySDK/usr/local/lib
+# CHECK-NOT: /usr/lib
# CHECK-NOT: /usr/local/lib
# CHECK: Found library /Applications/MySDK/usr/local/lib/libSystem.a
+# CHECK: Found library /hasFoo/foo.o
diff --git a/lld/test/mach-o/libresolve-simple.yaml b/lld/test/mach-o/libresolve-simple.yaml
index f4c793ffd10..eba0ef18909 100644
--- a/lld/test/mach-o/libresolve-simple.yaml
+++ b/lld/test/mach-o/libresolve-simple.yaml
@@ -2,10 +2,20 @@
# RUN: -path_exists /usr/lib \
# RUN: -path_exists /usr/local/lib \
# RUN: -path_exists /usr/lib/libSystem.dylib \
-# RUN: -lSystem \
+# 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: -lSystem -lFoo -lBar \
# RUN: 2>&1 | FileCheck %s
# CHECK: Library search paths:
+# CHECK: hasFoo
+# CHECK: /hasBar
# CHECK: /usr/lib
# CHECK: /usr/local/lib
# CHECK: Found library /usr/lib/libSystem.dylib
+# CHECK: Found library hasFoo/libFoo.dylib
+# CHECK: Found library /hasBar/libBar.dylib
diff --git a/lld/test/mach-o/libresolve-user-paths.yaml b/lld/test/mach-o/libresolve-user-paths.yaml
new file mode 100644
index 00000000000..c35a3c6c918
--- /dev/null
+++ b/lld/test/mach-o/libresolve-user-paths.yaml
@@ -0,0 +1,20 @@
+# RUN: lld -flavor darwin -arch x86_64 -r -test_libresolution \
+# RUN: -path_exists hasFoo \
+# RUN: -path_exists hasFoo/libFoo.dylib \
+# RUN: -path_exists /hasBar \
+# RUN: -path_exists /hasBar/libBar.dylib \
+# RUN: -path_exists /SDK/hasFoo \
+# RUN: -path_exists /SDK/hasFoo/libFoo.dylib \
+# RUN: -path_exists /SDK/hasBar \
+# RUN: -path_exists /SDK/hasBar/libBar.dylib \
+# RUN: -syslibroot /SDK \
+# RUN: -L hasFoo \
+# RUN: -L /hasBar \
+# RUN: -lFoo -lBar \
+# RUN: 2>&1 | FileCheck %s
+
+# CHECK: Library search paths:
+# CHECK: hasFoo
+# CHECK: /SDK/hasBar
+# CHECK: Found library hasFoo/libFoo.dylib
+# CHECK: Found library /SDK/hasBar/libBar.dylib
OpenPOWER on IntegriCloud