1; REQUIRES: x86 2; RUN: rm -rf %t; split-file %s %t 3 4; RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/swift-foo.s -o %t/swift-foo.o 5; RUN: llvm-ar rcs %t/libswiftFoo.a %t/swift-foo.o 6; RUN: llvm-as %t/lc-linker-opt.ll -o %t/lc-linker-opt.o 7; RUN: llvm-as %t/no-lc-linker-opt.ll -o %t/no-lc-linker-opt.o 8 9; RUN: %lld -lSystem -force_load_swift_libs -L%t %t/lc-linker-opt.o -o \ 10; RUN: %t/lc-linker-opt -why_load 2>&1 | FileCheck %s --check-prefix=WHY-LOAD 11; RUN: llvm-objdump --macho --syms %t/lc-linker-opt | FileCheck %s --check-prefix=HAS-SWIFT 12 13; RUN: %lld -lSystem -L%t %t/lc-linker-opt.o -o %t/lc-linker-opt-no-force 14; RUN: llvm-objdump --macho --syms %t/lc-linker-opt-no-force | FileCheck %s --check-prefix=NO-SWIFT 15 16;; Swift libraries passed on the CLI don't get force-loaded! 17; RUN: %lld -lSystem -force_load_swift_libs -lswiftFoo -L%t %t/no-lc-linker-opt.o -o %t/no-lc-linker-opt 18; RUN: llvm-objdump --macho --syms %t/no-lc-linker-opt | FileCheck %s --check-prefix=NO-SWIFT 19 20;; Moreover, if a Swift library is passed on the CLI, that supersedes any 21;; LC_LINKER_OPTIONs that reference it. 22; RUN: %lld -lSystem -force_load_swift_libs -lswiftFoo -L%t %t/lc-linker-opt.o -o %t/both-cli-and-lc-linker-opt 23; RUN: llvm-objdump --macho --syms %t/both-cli-and-lc-linker-opt | FileCheck %s --check-prefix=NO-SWIFT 24; RUN: %lld -lSystem -force_load_swift_libs -L%t %t/lc-linker-opt.o -lswiftFoo -o %t/both-cli-and-lc-linker-opt 25; RUN: llvm-objdump --macho --syms %t/both-cli-and-lc-linker-opt | FileCheck %s --check-prefix=NO-SWIFT 26 27; WHY-LOAD: LC_LINKER_OPTION forced load of {{.*}}libswiftFoo.a(swift-foo.o) 28; HAS-SWIFT: _swift_foo 29; NO-SWIFT-NOT: _swift_foo 30 31;--- lc-linker-opt.ll 32target triple = "x86_64-apple-macosx10.15.0" 33target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 34 35!0 = !{!"-lswiftFoo"} 36!llvm.linker.options = !{!0} 37 38define void @main() { 39 ret void 40} 41 42;--- no-lc-linker-opt.ll 43target triple = "x86_64-apple-macosx10.15.0" 44target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 45 46define void @main() { 47 ret void 48} 49 50;--- swift-foo.s 51.globl _swift_foo 52_swift_foo: 53