[lld] r212712 - [mach-o]: support user-specified (-L) library search paths
Tim Northover
tnorthover at apple.com
Thu Jul 10 04:46:08 PDT 2014
Author: tnorthover
Date: Thu Jul 10 06:46:08 2014
New Revision: 212712
URL: http://llvm.org/viewvc/llvm-project?rev=212712&view=rev
Log:
[mach-o]: support user-specified (-L) library search paths
Added:
lld/trunk/test/mach-o/libresolve-user-paths.yaml
Modified:
lld/trunk/lib/Driver/DarwinLdDriver.cpp
lld/trunk/lib/Driver/DarwinLdOptions.td
lld/trunk/test/mach-o/libresolve-one-syslibroot.yaml
lld/trunk/test/mach-o/libresolve-simple.yaml
Modified: lld/trunk/lib/Driver/DarwinLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=212712&r1=212711&r2=212712&view=diff
==============================================================================
--- lld/trunk/lib/Driver/DarwinLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/DarwinLdDriver.cpp Thu Jul 10 06:46:08 2014
@@ -296,8 +296,12 @@ bool DarwinLdDriver::parse(int argc, con
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);
Modified: lld/trunk/lib/Driver/DarwinLdOptions.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdOptions.td?rev=212712&r1=212711&r2=212712&view=diff
==============================================================================
--- lld/trunk/lib/Driver/DarwinLdOptions.td (original)
+++ lld/trunk/lib/Driver/DarwinLdOptions.td Thu Jul 10 06:46:08 2014
@@ -64,7 +64,7 @@ def bundle_loader : Separate<["-"], "bun
// 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">,
Modified: lld/trunk/test/mach-o/libresolve-one-syslibroot.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/mach-o/libresolve-one-syslibroot.yaml?rev=212712&r1=212711&r2=212712&view=diff
==============================================================================
--- lld/trunk/test/mach-o/libresolve-one-syslibroot.yaml (original)
+++ lld/trunk/test/mach-o/libresolve-one-syslibroot.yaml Thu Jul 10 06:46:08 2014
@@ -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
Modified: lld/trunk/test/mach-o/libresolve-simple.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/mach-o/libresolve-simple.yaml?rev=212712&r1=212711&r2=212712&view=diff
==============================================================================
--- lld/trunk/test/mach-o/libresolve-simple.yaml (original)
+++ lld/trunk/test/mach-o/libresolve-simple.yaml Thu Jul 10 06:46:08 2014
@@ -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
Added: lld/trunk/test/mach-o/libresolve-user-paths.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/mach-o/libresolve-user-paths.yaml?rev=212712&view=auto
==============================================================================
--- lld/trunk/test/mach-o/libresolve-user-paths.yaml (added)
+++ lld/trunk/test/mach-o/libresolve-user-paths.yaml Thu Jul 10 06:46:08 2014
@@ -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
More information about the llvm-commits
mailing list