2 ; RUN: rm -rf %t; split-file %s %t
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
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
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
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
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
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
32 target triple = "x86_64-apple-macosx10.15.0"
33 target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
36 !llvm.linker.options = !{!0}
42 ;--- no-lc-linker-opt.ll
43 target triple = "x86_64-apple-macosx10.15.0"
44 target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"