1; RUN: rm -f %t*.o.thinlto.bc
2; RUN: rm -f %t*.o.imports
3
4; First generate bitcode with a module summary index for each file
5; RUN: opt -module-summary %s -o %t1.o
6; RUN: opt -module-summary %p/Inputs/thinlto_emit_linked_objects.ll -o %t2.o
7; RUN: opt %s -o %t3.o
8
9; Next do the ThinLink step, specifying thinlto-index-only so that the gold
10; plugin exits after generating individual indexes. The objects the linker
11; decided to include in the link should be emitted into the file specified
12; after 'thinlto-index-only='. In this version of the test, only %t1.o will
13; be included in the link, and not %t2.o since it is within
14; a library (--start-lib/--end-lib pair) and not strongly referenced.
15; Note that the support for detecting this is in gold v1.12.
16; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \
17; RUN:    --plugin-opt=thinlto \
18; RUN:    --plugin-opt=thinlto-index-only=%t.index \
19; RUN:    --plugin-opt=thinlto-emit-imports-files \
20; RUN:    -m elf_x86_64 \
21; RUN:    -o %t4 \
22; RUN:    %t1.o %t3.o \
23; RUN:    --start-lib %t2.o --end-lib
24
25; Ensure that the expected output files are created, even for the file
26; the linker decided not to include in the link.
27; RUN: ls %t1.o.thinlto.bc
28; RUN: ls %t2.o.thinlto.bc
29; RUN: ls %t3.o.thinlto.bc
30; RUN: ls %t1.o.imports
31; RUN: ls %t2.o.imports
32; RUN: ls %t3.o.imports
33
34; RUN: cat %t.index | FileCheck %s
35; CHECK: thinlto_emit_linked_objects.ll.tmp1.o
36; CHECK-NOT: thinlto_emit_linked_objects.ll.tmp2.o
37; CHECK-NOT: thinlto_emit_linked_objects.ll.tmp3.o
38
39target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
40target triple = "x86_64-unknown-linux-gnu"
41
42define i32 @main() {
43entry:
44  ret i32 0
45}
46