xref: /llvm-project/lld/test/MachO/lto-object-path.ll (revision 19f379420b7ca5870931c10dd692aa5191878038)
1; REQUIRES: x86
2; UNSUPPORTED: system-windows
3
4; RUN: rm -rf %t; mkdir %t
5; RUN: llc -filetype=obj %s -o %t/test-obj.o
6; RUN: opt -thinlto-bc %s -o %t/test.o
7; RUN: opt %s -o %t/test-nonthin.o
8
9; RUN: %lld %t/test.o -o %t/test
10; RUN: llvm-nm -pa %t/test | FileCheck %s --check-prefixes CHECK,NOOBJPATH
11
12; RUN: %lld %t/test-obj.o -o %t/test-obj -object_path_lto %t/lto-temps-obj
13; RUN: llvm-nm -pa %t/test-obj | FileCheck %s --check-prefixes CHECK,NOLTOFILES -DDIR=%t
14
15; RUN: env ZERO_AR_DATE=0 %lld %t/test.o -o %t/test -object_path_lto %t/lto-temps
16; RUN: llvm-nm -pa %t/test | FileCheck %s --check-prefixes CHECK,OBJPATH-DIR -DDIR=%t/lto-temps
17
18;; Ensure object path is still used if the cache is used
19; RUN: env ZERO_AR_DATE=0 %lld %t/test.o -o %t/test -object_path_lto %t/lto-temps -prune_interval_lto 20 -cache_path_lto %t/cache --thinlto-cache-policy=cache_size_files=1:cache_size_bytes=10
20; RUN: llvm-nm -pa %t/test | FileCheck %s --check-prefixes CHECK,OBJPATH-DIR -DDIR=%t/lto-temps
21;; And that dsymutil can read the result
22; RUN: dsymutil -f -o - %t/test | llvm-dwarfdump - | FileCheck %s --check-prefix=DSYM
23
24;; Test that the object path hardlinks to the cache when possible
25;; NB:
26;; 1) Need to delete current object path contents or hardlink will fail.
27;; 2) Note the cache policy is different from the test above (which is crafted
28;;    to ensure that the cache is pruned immediately; we want the opposite here).
29; RUN: rm -rf %t/lto-temps
30; RUN: %lld %t/test.o -o %t/test -object_path_lto %t/lto-temps -prune_interval_lto 20 -cache_path_lto %t/cache --thinlto-cache-policy=cache_size_files=10:cache_size_bytes=10000
31;; Get the link count.
32; RUN: ls -l %t/lto-temps/1.x86_64.lto.o | tr -s ' ' | cut -f 2 -d ' ' | FileCheck %s --check-prefix=HARDLINK
33
34;; check that the object path can be an existing file
35; RUN: touch %t/lto-tmp.o
36; RUN: env ZERO_AR_DATE=0 %lld %t/test-nonthin.o -o %t/test -object_path_lto %t/lto-tmp.o
37; RUN: llvm-nm -pa %t/test | FileCheck %s --check-prefixes CHECK,OBJPATH-FILE -DFILE=%t/lto-tmp.o
38; RUN: llvm-otool -l %t/lto-tmp.o | FileCheck %s --check-prefixes=MINOS
39
40
41; CHECK:             0000000000000000                - 00 0000    SO /tmp/test.cpp
42; NOOBJPATH-NEXT:    0000000000000000                - 03 0001   OSO /tmp/lto.tmp
43; NOLTOFILES-NEXT:   0000000000000000                - 03 0001   OSO [[DIR]]/test-obj.o
44;; check that modTime is nonzero when `-object_path_lto` is provided
45; OBJPATH-DIR-NEXT:  {{[0-9a-f]*[1-9a-f]+[0-9a-f]*}} - 03 0001   OSO [[DIR]]/1.x86_64.lto.o
46; OBJPATH-FILE-NEXT: {{[0-9a-f]*[1-9a-f]+[0-9a-f]*}} - 03 0001   OSO [[FILE]]
47; CHECK-NEXT:        {{[0-9a-f]+}}                   - 01 0000   FUN _main
48; CHECK-NEXT:        0000000000000001                - 00 0000   FUN
49; CHECK-NEXT:        0000000000000000                - 01 0000    SO
50; CHECK-NEXT:        {{[0-9a-f]+}}                   T _main
51; DSYM: DW_AT_name ("test.cpp")
52; HARDLINK: 2
53
54; MINOS: 10.15
55
56target triple = "x86_64-apple-macosx10.15.0"
57target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
58
59define void @main() #0 !dbg !4 {
60  ret void
61}
62
63!llvm.module.flags = !{ !0, !1 }
64!llvm.dbg.cu = !{!2}
65
66!0 = !{i32 7, !"Dwarf Version", i32 4}
67!1 = !{i32 2, !"Debug Info Version", i32 3}
68!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, emissionKind: FullDebug)
69!3 = !DIFile(filename: "test.cpp", directory: "/tmp")
70!4 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 1, type: !5, scopeLine: 1, unit: !2)
71!5 = !DISubroutineType(types: !6)
72!6 = !{}
73