1; REQUIRES: x86 2; RUN: rm -rf %t; split-file %s %t 3 4; RUN: llc -filetype=obj %t/q.ll -o %t/q.o 5; RUN: llvm-ar cru %t/libq.a %t/q.o 6 7; RUN: llc -filetype=obj %t/f.ll -o %t/f.nolto.o 8; RUN: opt --thinlto-bc %t/f.ll -o %t/f.thinlto.o 9; RUN: opt %t/f.ll -o %t/f.lto.o 10 11; RUN: llc -filetype=obj %t/b.ll -o %t/b.nolto.o 12; RUN: opt --thinlto-bc %t/b.ll -o %t/b.thinlto.o 13; RUN: opt %t/b.ll -o %t/b.lto.o 14 15; (1) NoLTO-NoLTO 16; RUN: %lld -dylib -lSystem -L%t %t/f.nolto.o %t/b.nolto.o -o %t/nolto-nolto.out 17; RUN: llvm-objdump --syms %t/nolto-nolto.out | FileCheck %s 18 19; (2) NoLTO-ThinLTO 20; RUN: %lld -dylib -lSystem -L%t %t/f.nolto.o %t/b.thinlto.o -o %t/nolto-thinlto.out 21; RUN: llvm-objdump --syms %t/nolto-thinlto.out | FileCheck %s 22 23; (3) ThinLTO-NoLTO 24; RUN: %lld -dylib -lSystem -L%t %t/f.thinlto.o %t/b.nolto.o -o %t/thinlto-nolto.out 25; RUN: llvm-objdump --syms %t/thinlto-nolto.out | FileCheck %s 26 27; (4) NoLTO-LTO 28; RUN: %lld -dylib -lSystem -L%t %t/f.nolto.o %t/b.lto.o -o %t/nolto-lto.out 29; RUN: llvm-objdump --syms %t/nolto-lto.out | FileCheck %s 30 31; (5) LTO-NoLTO 32; RUN: %lld -dylib -lSystem -L%t %t/f.lto.o %t/b.nolto.o -o %t/lto-nolto.out 33; RUN: llvm-objdump --syms %t/lto-nolto.out | FileCheck %s 34 35; (6) LTO-ThinLTO 36; RUN: %lld -dylib -lSystem -L%t %t/f.lto.o %t/b.thinlto.o -o %t/lto-thinlto.out 37; RUN: llvm-objdump --syms %t/lto-thinlto.out | FileCheck %s 38 39; (7) ThinLTO-NoLTO 40; RUN: %lld -dylib -lSystem -L%t %t/f.thinlto.o %t/b.lto.o -o %t/thinlto-lto.out 41; RUN: llvm-objdump --syms %t/thinlto-lto.out | FileCheck %s 42 43; We expect to resolve _weak1 from f.ll and _weak2 from b.ll as per the input order. 44; As _weak2 from q.ll pulled in via LC_LINKER_OPTION is processed 45; in the second pass, it won't prevail due to _weak2 from b.ll. 46 47; CHECK: w O __TEXT,f _weak1 48; CHECK: w O __TEXT,b _weak2 49 50;--- q.ll 51target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 52target triple = "x86_64-apple-macosx10.15.0" 53 54define i32 @weak2() section "__TEXT,q" { 55 ret i32 2 56} 57 58;--- f.ll 59target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 60target triple = "x86_64-apple-macosx10.15.0" 61 62!0 = !{!"-lq"} 63!llvm.linker.options = !{!0} 64 65define weak i32 @weak1() section "__TEXT,f" { 66 %call = call i32 @weak2() 67 %add = add nsw i32 %call, 1 68 ret i32 %add 69} 70 71declare i32 @weak2(...) 72 73;--- b.ll 74target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 75target triple = "x86_64-apple-macosx10.15.0" 76 77define weak i32 @weak1() section "__TEXT,b" { 78 ret i32 3 79} 80 81define weak i32 @weak2() section "__TEXT,b" { 82 ret i32 4 83} 84