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