108 lines · plain
1# REQUIRES: x862 3################ Place dynlib in %tD, and archive in %tA4# RUN: rm -rf %t %tA %tD5# RUN: mkdir -p %t %tA %tD6#7# RUN: llvm-mc -filetype obj -triple x86_64-apple-darwin %p/Inputs/libhello.s -o %t/hello.o8# RUN: %lld -dylib -install_name @executable_path/libhello.dylib %t/hello.o -o %t/libhello.dylib9#10# RUN: llvm-mc -filetype obj -triple x86_64-apple-darwin %p/Inputs/libgoodbye.s -o %t/goodbye.o11# RUN: %lld -dylib -install_name @executable_path/libgoodbye.dylib %t/goodbye.o -o %tD/libgoodbye.dylib12# RUN: llvm-ar --format=darwin crs %tA/libgoodbye.a %t/goodbye.o13#14# RUN: llvm-mc -filetype obj -triple x86_64-apple-darwin %s -o %t/test.o15 16################ default, which is the same as -search_paths_first17# RUN: %no-lsystem-lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \18# RUN: -L%tA -L%tD -L%t -lhello -lgoodbye -lSystem %t/test.o \19# RUN: --print-dylib-search | FileCheck --check-prefix=ARCHIVESEARCH -DPATH=%t %s20# RUN: llvm-objdump --macho --dylibs-used %t/test | FileCheck --check-prefix=ARCHIVE %s21 22################ Test all permutations of -L%t{A,D} with -search_paths_first23# RUN: %no-lsystem-lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \24# RUN: -L%tA -L%tD -L%t -lhello -lgoodbye -lSystem %t/test.o -search_paths_first25# RUN: llvm-objdump --macho --dylibs-used %t/test | FileCheck --check-prefix=ARCHIVE %s26# RUN: %no-lsystem-lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \27# RUN: -L%tD -L%tA -L%t -lhello -lgoodbye -lSystem %t/test.o -search_paths_first28# RUN: llvm-objdump --macho --dylibs-used %t/test | FileCheck --check-prefix=DYLIB %s29# RUN: %no-lsystem-lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \30# RUN: -L%tA -L%t -lhello -lgoodbye -lSystem %t/test.o -search_paths_first31# RUN: llvm-objdump --macho --dylibs-used %t/test | FileCheck --check-prefix=ARCHIVE %s32# RUN: %no-lsystem-lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \33# RUN: -L%tD -L%t -lhello -lgoodbye -lSystem %t/test.o -search_paths_first34# RUN: llvm-objdump --macho --dylibs-used %t/test | FileCheck --check-prefix=DYLIB %s35 36################ Test all permutations of -L%t{A,D} with -search_dylibs_first37# RUN: env RC_TRACE_DYLIB_SEARCHING=1 %no-lsystem-lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \38# RUN: -L%tA -L%tD -L%t -lhello -lgoodbye -lSystem %t/test.o -search_dylibs_first \39# RUN: | FileCheck --check-prefix=DYLIBSEARCH -DPATH=%t %s40# RUN: llvm-objdump --macho --dylibs-used %t/test | FileCheck --check-prefix=DYLIB %s41# RUN: %no-lsystem-lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \42# RUN: -L%tD -L%tA -L%t -lhello -lgoodbye -lSystem %t/test.o -search_dylibs_first43# RUN: llvm-objdump --macho --dylibs-used %t/test | FileCheck --check-prefix=DYLIB %s44# RUN: %no-lsystem-lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \45# RUN: -L%tA -L%t -lhello -lgoodbye -lSystem %t/test.o -search_dylibs_first46# RUN: llvm-objdump --macho --dylibs-used %t/test | FileCheck --check-prefix=ARCHIVE %s47# RUN: %no-lsystem-lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \48# RUN: -L%tD -L%t -lhello -lgoodbye -lSystem %t/test.o -search_dylibs_first49# RUN: llvm-objdump --macho --dylibs-used %t/test | FileCheck --check-prefix=DYLIB %s50 51################ Test that we try the tbd file before the binary for frameworks too.52# RUN: not %lld -dylib -F %t -framework Foo -o %t --print-dylib-search \53# RUN: | FileCheck --check-prefix=FRAMEWORKSEARCH -DPATH=%t %s54 55# DYLIB: @executable_path/libhello.dylib56# DYLIB: @executable_path/libgoodbye.dylib57# DYLIB: /usr/lib/libSystem.dylib58 59# DYLIBSEARCH: searched {{.*}}/MacOSX.sdk/usr/lib{{[/\\]}}libhello.tbd, not found60# DYLIBSEARCH-NEXT: searched {{.*}}/MacOSX.sdk/usr/lib{{[/\\]}}libhello.dylib, not found61# DYLIBSEARCH-NEXT: searched {{.*}}/MacOSX.sdk/usr/lib{{[/\\]}}libhello.so, not found62# DYLIBSEARCH-NEXT: searched [[PATH]]A{{[/\\]}}libhello.tbd, not found63# DYLIBSEARCH-NEXT: searched [[PATH]]A{{[/\\]}}libhello.dylib, not found64# DYLIBSEARCH: searched [[PATH]]{{[/\\]}}libhello.dylib, found65# DYLIBSEARCH: searched [[PATH]]D{{[/\\]}}libgoodbye.dylib, found66 67# ARCHIVE: @executable_path/libhello.dylib68# ARCHIVE-NOT: @executable_path/libgoodbye.dylib69# ARCHIVE: /usr/lib/libSystem.dylib70 71# ARCHIVESEARCH: searched {{.*}}/MacOSX.sdk/usr/lib{{[/\\]}}libhello.tbd, not found72# ARCHIVESEARCH-NEXT: searched {{.*}}/MacOSX.sdk/usr/lib{{[/\\]}}libhello.dylib, not found73# ARCHIVESEARCH-NEXT: searched {{.*}}/MacOSX.sdk/usr/lib{{[/\\]}}libhello.so, not found74# ARCHIVESEARCH-NEXT: searched {{.*}}/MacOSX.sdk/usr/lib{{[/\\]}}libhello.a, not found75# ARCHIVESEARCH-NEXT: searched [[PATH]]A{{[/\\]}}libhello.tbd, not found76# ARCHIVESEARCH-NEXT: searched [[PATH]]A{{[/\\]}}libhello.dylib, not found77# ARCHIVESEARCH-NEXT: searched [[PATH]]A{{[/\\]}}libhello.so, not found78# ARCHIVESEARCH-NEXT: searched [[PATH]]A{{[/\\]}}libhello.a, not found79# ARCHIVESEARCH: searched [[PATH]]{{[/\\]}}libhello.dylib, found80# ARCHIVESEARCH: searched [[PATH]]A{{[/\\]}}libgoodbye.a, found81 82# FRAMEWORKSEARCH: searched [[PATH]]{{[/\\]}}Foo.framework{{[/\\]}}Foo.tbd, not found83# FRAMEWORKSEARCH-NEXT: searched [[PATH]]{{[/\\]}}Foo.framework{{[/\\]}}Foo, not found84 85.section __TEXT,__text86.global _main87 88_main:89 movl $0x2000004, %eax # write()90 mov $1, %rdi # stdout91 movq _hello_world@GOTPCREL(%rip), %rsi92 mov $13, %rdx # length93 syscall94 95 movl $0x2000004, %eax # write()96 mov $1, %rdi # stdout97 movq _hello_its_me@GOTPCREL(%rip), %rsi98 mov $15, %rdx # length99 syscall100 101 movl $0x2000004, %eax # write()102 mov $1, %rdi # stdout103 movq _goodbye_world@GOTPCREL(%rip), %rsi104 mov $15, %rdx # length105 syscall106 mov $0, %rax107 ret108