2 # RUN: rm -rf %t; split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/archive-foo.s -o %t/archive-foo.o
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/archive-baz.s -o %t/archive-baz.o
5 # RUN: llvm-ar rcs %t/libfoo.a %t/archive-foo.o
6 # RUN: llvm-ar rcs %t/libbaz.a %t/archive-baz.o
7 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/obj.s -o %t/obj.o
8 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/obj-bar.s -o %t/obj-bar.o
10 # RUN: %lld -dylib -lSystem %t/obj.o -load_hidden %t/libfoo.a -o %t/test.dylib
11 # RUN: llvm-nm %t/test.dylib | FileCheck %s
12 # RUN: %lld -dylib -lSystem -L%t %t/obj.o -hidden-lfoo -o %t/test2.dylib
13 # RUN: llvm-nm %t/test2.dylib | FileCheck %s
17 ## If an archive has already been loaded without -load_hidden earlier in the command line,
18 ## -load_hidden does not have an effect.
19 # RUN: %lld -dylib -lSystem %t/obj.o %t/libfoo.a -load_hidden %t/libfoo.a -o %t/test-regular-then-hidden.dylib
20 # RUN: llvm-nm %t/test-regular-then-hidden.dylib | FileCheck %s --check-prefix=REGULAR-THEN-HIDDEN
21 # REGULAR-THEN-HIDDEN-DAG: T _foo
22 # REGULAR-THEN-HIDDEN-DAG: D _bar
24 ## If -load_hidden comes first, the symbols will have hidden visibility.
25 # RUN: %lld -dylib -lSystem %t/obj.o -load_hidden %t/libfoo.a %t/libfoo.a -o %t/test-hidden-then-regular.dylib
26 # RUN: llvm-nm %t/test-hidden-then-regular.dylib | FileCheck %s --check-prefix=HIDDEN-THEN-REGULAR
27 # HIDDEN-THEN-REGULAR-DAG: t _foo
28 # HIDDEN-THEN-REGULAR-DAG: d _bar
30 ## If both -load_hidden and -force_load are specified, the earlier one will have an effect.
31 # RUN: %lld -dylib -lSystem %t/obj.o %t/libfoo.a -force_load %t/libbaz.a -load_hidden %t/libbaz.a -o %t/test-force-then-hidden.dylib
32 # RUN: llvm-nm %t/test-force-then-hidden.dylib | FileCheck %s --check-prefix=FORCE-THEN-HIDDEN
33 # FORCE-THEN-HIDDEN: T _baz
34 # RUN: %lld -dylib -lSystem %t/obj.o %t/libfoo.a -load_hidden %t/libbaz.a -force_load %t/libbaz.a -o %t/test-hidden-then-force.dylib
35 # RUN: llvm-nm %t/test-hidden-then-force.dylib | FileCheck %s --check-prefix=HIDDEN-THEN-FORCE
36 # HIDDEN-THEN-FORCE-NOT: _baz
38 ## -load_hidden does not cause the library to be loaded eagerly.
39 # RUN: %lld -dylib -lSystem %t/obj.o -load_hidden %t/libfoo.a -load_hidden %t/libbaz.a -o %t/test-lazy.dylib
40 # RUN: llvm-nm %t/test-lazy.dylib | FileCheck %s --check-prefix=LAZY
43 ## Specifying the same library twice is fine.
44 # RUN: %lld -dylib -lSystem %t/obj.o -load_hidden %t/libfoo.a -load_hidden %t/libfoo.a -o %t/test-twice.dylib
45 # RUN: llvm-nm %t/test-twice.dylib | FileCheck %s --check-prefix=TWICE
49 ## -load_hidden causes the symbols to have "private external" visibility, so duplicate definitions
51 # RUN: not %lld -dylib -lSystem %t/obj.o %t/obj-bar.o -load_hidden %t/libfoo.a 2>&1 | FileCheck %s --check-prefix=DUP
52 # DUP: error: duplicate symbol: _bar