xref: /llvm-project/lld/test/ELF/lto/thinlto-object-suffix-replace.ll (revision 4512dda6af1bb22cf836c9e8aa0f054d2b52ec17)
1; REQUIRES: x86
2;; Test to make sure the thinlto-object-suffix-replace option is handled
3;; correctly.
4; RUN: rm -rf %t && mkdir %t && cd %t
5
6;; Generate bitcode file with summary, as well as a minimized bitcode without
7; the debug metadata for the thin link.
8; RUN: opt --thinlto-bc %s -thin-link-bitcode-file=1.thinlink.bc -o 1.o
9
10;; First perform the thin link on the normal bitcode file, and save the
11;; resulting index.
12; RUN: ld.lld --plugin-opt=thinlto-index-only -shared 1.o -o 3
13; RUN: cp 1.o.thinlto.bc 1.o.thinlto.bc.orig
14
15;; Next perform the thin link on the minimized bitcode file, and compare dump
16;; of the resulting index to the above dump to ensure they are identical.
17; RUN: rm -f 1.o.thinlto.bc
18;; Make sure it isn't inadvertently using the regular bitcode file.
19; RUN: rm -f 1.o
20; RUN: ld.lld --plugin-opt=thinlto-index-only --plugin-opt=thinlto-object-suffix-replace=".thinlink.bc;.o" \
21; RUN:   -shared 1.thinlink.bc -o 3
22; RUN: cmp 1.o.thinlto.bc.orig 1.o.thinlto.bc
23;; Also check that this works without the --plugin-opt= prefix.
24; RUN: ld.lld --thinlto-index-only --thinlto-object-suffix-replace=".thinlink.bc;.o" \
25; RUN:   -shared 1.thinlink.bc -o 3
26; RUN: cmp 1.o.thinlto.bc.orig 1.o.thinlto.bc
27
28;; Ensure lld generates error if object suffix replace option does not have 'old;new' format
29; RUN: rm -f 1.o.thinlto.bc
30; RUN: not ld.lld --plugin-opt=thinlto-index-only --plugin-opt=thinlto-object-suffix-replace="abc:def" -shared 1.thinlink.bc \
31; RUN:   -o 3 2>&1 | FileCheck %s --check-prefix=ERR1
32; ERR1: --plugin-opt=thinlto-object-suffix-replace= expects 'old;new' format, but got abc:def
33
34;; If filename does not end with old suffix, no suffix change should occur,
35;; so ".thinlto.bc" will simply be appended to the input file name.
36; RUN: rm -f 1.thinlink.bc.thinlto.bc
37; RUN: ld.lld --plugin-opt=thinlto-index-only --plugin-opt=thinlto-object-suffix-replace=".abc;.o" -shared 1.thinlink.bc -o /dev/null
38; RUN: ls 1.thinlink.bc.thinlto.bc
39
40target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
41target triple = "x86_64-unknown-linux-gnu"
42
43define void @f() {
44entry:
45  ret void
46}
47
48!llvm.dbg.cu = !{}
49
50!1 = !{i32 2, !"Debug Info Version", i32 3}
51!llvm.module.flags = !{!1}
52