xref: /llvm-project/clang/test/Driver/debug-options-as.c (revision cbb5f03f5042aa6d7c5d17963eba192861c9165c)
1 // XFAIL: target={{.*}}-aix{{.*}}
2 
3 // Check to make sure clang is somewhat picky about -g options.
4 // (Delived from debug-options.c)
5 // RUN: %clang -### -c -save-temps -integrated-as -g %s 2>&1 \
6 // RUN:   | FileCheck -check-prefix=SAVE %s
7 //
8 // SAVE: "-cc1"{{.*}}"-E"{{.*}}"-debug-info-kind=
9 // SAVE: "-cc1"{{.*}}"-emit-llvm-bc"{{.*}}"-debug-info-kind=
10 // SAVE: "-cc1"{{.*}}"-S"{{.*}}"-debug-info-kind=
11 // SAVE: "-cc1as"
12 // SAVE-NOT: -debug-info-kind=
13 
14 // Make sure that '-ggdb0' is not accidentally mistaken for '-g'
15 // RUN: %clang -### -ggdb0 -c -integrated-as -x assembler %s 2>&1 \
16 // RUN:   | FileCheck -check-prefix=GGDB0 %s
17 //
18 // GGDB0: "-cc1as"
19 // GGDB0-NOT: -debug-info-kind=
20 
21 // Check to make sure clang with -g on a .s file gets passed.
22 // This requires a target that defaults to DWARF.
23 // RUN: %clang -### --target=x86_64-linux-gnu -c -integrated-as -g -x assembler %s 2>&1 \
24 // RUN:   | FileCheck %s
25 //
26 // CHECK: "-cc1as"
27 // CHECK: "-debug-info-kind=constructor"
28 
29 // Check that a plain -g, without any -gdwarf, for a MSVC target, doesn't
30 // trigger producing DWARF output.
31 // RUN: %clang -### --target=x86_64-windows-msvc -c -integrated-as -g -x assembler %s 2>&1 \
32 // RUN:   | FileCheck -check-prefix=MSVC %s
33 //
34 // MSVC: "-cc1as"
35 // MSVC-NOT: "-debug-info-kind=constructor"
36 
37 // Check that clang-cl with the -Z7 option works the same, not triggering
38 // any DWARF output.
39 //
40 // RUN: %clang_cl -### --target=x86_64-pc-windows-msvc -c -Z7 -x assembler -- %s 2>&1 \
41 // RUN:   | FileCheck -check-prefix=MSVC %s
42 
43 // Check to make sure clang with -g on a .s file gets passed -dwarf-debug-producer.
44 // RUN: %clang -### -c -integrated-as -g -x assembler %s 2>&1 \
45 // RUN:   | FileCheck -check-prefix=P %s
46 //
47 // P: "-cc1as"
48 // P: "-dwarf-debug-producer"
49 
50 // Check that -gdwarf64 is passed to cc1as.
51 // RUN: %clang -### -c -gdwarf64 -gdwarf-5 -target x86_64 -integrated-as -x assembler %s 2>&1 \
52 // RUN:   | FileCheck -check-prefix=GDWARF64_ON %s
53 // RUN: %clang -### -c -gdwarf64 -gdwarf-4 -target x86_64 -integrated-as -x assembler %s 2>&1 \
54 // RUN:   | FileCheck -check-prefix=GDWARF64_ON %s
55 // RUN: %clang -### -c -gdwarf64 -gdwarf-3 -target x86_64 -integrated-as -x assembler %s 2>&1 \
56 // RUN:   | FileCheck -check-prefix=GDWARF64_ON %s
57 // GDWARF64_ON: "-cc1as"
58 // GDWARF64_ON: "-gdwarf64"
59 
60 // Check that -gdwarf64 can be reverted with -gdwarf32.
61 // RUN: %clang -### -c -gdwarf64 -gdwarf32 -gdwarf-4 -target x86_64 -integrated-as -x assembler %s 2>&1 \
62 // RUN:   | FileCheck -check-prefix=GDWARF64_OFF %s
63 // GDWARF64_OFF: "-cc1as"
64 // GDWARF64_OFF-NOT: "-gdwarf64"
65 
66 // Check that an error is reported if -gdwarf64 cannot be used.
67 // RUN: not %clang -### -c -gdwarf64 -gdwarf-2 --target=x86_64 -integrated-as -x assembler %s 2>&1 \
68 // RUN:   | FileCheck -check-prefix=GDWARF64_VER %s
69 // RUN: not %clang -### -c -gdwarf64 -gdwarf-4 --target=i386-linux-gnu %s 2>&1 \
70 // RUN:   | FileCheck -check-prefix=GDWARF64_32ARCH %s
71 // RUN: not %clang -### -c -gdwarf64 -gdwarf-4 -target x86_64-apple-darwin %s 2>&1 \
72 // RUN:   | FileCheck -check-prefix=GDWARF64_ELF %s
73 //
74 // GDWARF64_VER:  error: invalid argument '-gdwarf64' only allowed with 'DWARFv3 or greater'
75 // GDWARF64_32ARCH: error: invalid argument '-gdwarf64' only allowed with '64 bit architecture'
76 // GDWARF64_ELF: error: invalid argument '-gdwarf64' only allowed with 'ELF platforms'
77 
78 // Check that -gdwarf-N can be placed before other options of the "-g" group.
79 // RUN: %clang -### -c -g -gdwarf-3 -target %itanium_abi_triple -fintegrated-as -x assembler %s 2>&1 \
80 // RUN:   | FileCheck -check-prefix=DWARF3 %s
81 // RUN: %clang -### -c -gdwarf-3 -g -target %itanium_abi_triple -fintegrated-as -x assembler %s 2>&1 \
82 // RUN:   | FileCheck -check-prefix=DWARF3 %s
83 // RUN: %clang -### -c -g -gdwarf-5 -target %itanium_abi_triple -fintegrated-as -x assembler %s 2>&1 \
84 // RUN:   | FileCheck -check-prefix=DWARF5 %s
85 // RUN: %clang -### -c -gdwarf-5 -g -target %itanium_abi_triple -fintegrated-as -x assembler %s 2>&1 \
86 // RUN:   | FileCheck -check-prefix=DWARF5 %s
87 
88 // DWARF3: "-cc1as"
89 // DWARF3: "-dwarf-version=3"
90 // DWARF5: "-cc1as"
91 // DWARF5: "-dwarf-version=5"
92