1 /// Test -gsplit-dwarf and -gsplit-dwarf={split,single}.
2 
3 /// Interaction with -g (-g2).
4 // RUN: %clang -### -c -target x86_64 -g -gsplit-dwarf %s 2>&1 | FileCheck %s --check-prefixes=NOINLINE,SPLIT
5 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefixes=NOINLINE,SPLIT
6 // RUN: %clang -### -c -target x86_64 -g2 -gsplit-dwarf %s 2>&1 | FileCheck %s --check-prefixes=NOINLINE,SPLIT
7 /// -gsplit-dwarf=split is equivalent to -gsplit-dwarf.
8 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf=split -g %s 2>&1 | FileCheck %s --check-prefixes=NOINLINE,SPLIT
9 
10 // INLINE-NOT: "-fno-split-dwarf-inlining"
11 // NOINLINE:   "-fno-split-dwarf-inlining"
12 // SPLIT:      "-debug-info-kind=limited"
13 // SPLIT-SAME: "-ggnu-pubnames"
14 // SPLIT-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo"
15 
16 // RUN: %clang -### -c -target wasm32 -gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=SPLIT
17 // RUN: %clang -### -c -target amdgcn-amd-amdhsa -gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=SPLIT
18 
19 /// -gsplit-dwarf is a no-op on a non-ELF platform.
20 // RUN: %clang -### -c -target x86_64-apple-darwin  -gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=DARWIN
21 // DARWIN:     "-debug-info-kind=standalone"
22 // DARWIN-NOT: "-split-dwarf
23 
24 /// -gsplit-dwarf is a no-op if no -g is specified.
25 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf %s 2>&1 | FileCheck %s --check-prefix=G0
26 
27 /// -gno-split-dwarf disables debug fission.
28 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf -g -gno-split-dwarf %s 2>&1 | FileCheck %s --check-prefix=NOSPLIT
29 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf=single -g -gno-split-dwarf %s 2>&1 | FileCheck %s --check-prefix=NOSPLIT
30 // RUN: %clang -### -c -target x86_64 -gno-split-dwarf -g -gsplit-dwarf %s 2>&1 | FileCheck %s --check-prefixes=NOINLINE,SPLIT
31 
32 // NOSPLIT:     "-debug-info-kind=limited"
33 // NOSPLIT-NOT: "-ggnu-pubnames"
34 // NOSPLIT-NOT: "-split-dwarf
35 
36 /// Test -gsplit-dwarf=single.
37 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf=single -g %s 2>&1 | FileCheck %s --check-prefix=SINGLE
38 
39 // SINGLE: "-debug-info-kind=limited"
40 // SINGLE: "-split-dwarf-file" "split-debug.o"
41 // SINGLE-NOT: "-split-dwarf-output"
42 
43 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf=single -g -o %tfoo.o %s 2>&1 | FileCheck %s --check-prefix=SINGLE_WITH_FILENAME
44 
45 // SINGLE_WITH_FILENAME: "-split-dwarf-file" "{{.*}}foo.o"
46 // SINGLE_WITH_FILENAME-NOT: "-split-dwarf-output"
47 
48 /// Without -c, clang performs linking as well. The output is unchanged.
49 // RUN: %clang -### -target x86_64-unknown-linux-gnu -gsplit-dwarf -g %s -o ignore.d 2>&1 | FileCheck %s --check-prefix=SPLIT
50 
51 /// -fsplit-dwarf-inlining
52 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf=split -g -fsplit-dwarf-inlining %s 2>&1 | FileCheck %s --check-prefixes=INLINE,SPLIT
53 
54 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf=split -g -gno-pubnames %s 2>&1 | FileCheck %s --check-prefixes=NOPUBNAMES
55 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf=split -g -gno-gnu-pubnames %s 2>&1 | FileCheck %s --check-prefixes=NOPUBNAMES
56 // NOPUBNAMES:      "-debug-info-kind=limited"
57 // NOPUBNAMES-NOT:  "-ggnu-pubnames"
58 // NOPUBNAMES-SAME: "-split-dwarf-file" "split-debug.dwo" "-split-dwarf-output" "split-debug.dwo"
59 
60 /// Invoke objcopy if not using the integrated assembler.
61 // RUN: %clang -### -c -target x86_64-unknown-linux-gnu -fno-integrated-as -gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=OBJCOPY
62 // OBJCOPY:      objcopy" "--extract-dwo"
63 // OBJCOPY-NEXT: objcopy" "--strip-dwo"
64 
65 /// ... but not for assembly output.
66 // RUN: %clang -### -S -target x86_64-unknown-linux-gnu -fno-integrated-as -gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=NOOBJCOPY
67 // NOOBJCOPY-NOT: objcopy"
68 
69 /// Interaction with -g0.
70 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf -g0 -### %s 2>&1 | FileCheck %s --check-prefix=G0
71 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf=single -g0 %s 2>&1 | FileCheck %s --check-prefix=G0
72 // RUN: %clang -### -c -target x86_64 -g0 -gsplit-dwarf %s 2>&1 | FileCheck %s --check-prefixes=G0
73 // RUN: %clang -### -c -target x86_64 -g0 -gsplit-dwarf=single %s 2>&1 | FileCheck %s --check-prefix=G0
74 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf=single -g0 -fsplit-dwarf-inlining %s 2>&1 | FileCheck %s --check-prefix=G0
75 
76 // G0-NOT: "-debug-info-kind=
77 // G0-NOT: "-split-dwarf-
78 
79 /// Interaction with -g1 (-gmlt).
80 // RUN: %clang -### -S -target x86_64 -gsplit-dwarf -g1 %s 2>&1 | FileCheck %s --check-prefix=G1_WITH_SPLIT
81 // RUN: %clang -### -S -target x86_64 -gsplit-dwarf -g1 -fno-split-dwarf-inlining %s 2>&1 | FileCheck %s --check-prefix=G1_WITH_SPLIT
82 // RUN: %clang -### -S -target x86_64 -gmlt -gsplit-dwarf -fno-split-dwarf-inlining %s 2>&1 | FileCheck %s --check-prefix=G1_WITH_SPLIT
83 
84 // G1_WITH_SPLIT: "-debug-info-kind=line-tables-only"
85 // G1_WITH_SPLIT: "-split-dwarf-file"
86 // G1_WITH_SPLIT: "-split-dwarf-output"
87 
88 // RUN: %clang -### -S -target x86_64 -gsplit-dwarf -g1 -fsplit-dwarf-inlining %s 2>&1 | FileCheck %s --check-prefix=G1_NOSPLIT
89 
90 // G1_NOSPLIT: "-debug-info-kind=line-tables-only"
91 // G1_NOSPLIT-NOT: "-split-dwarf-file"
92 // G1_NOSPLIT-NOT: "-split-dwarf-output"
93