1 // Check to make sure clang is somewhat picky about -g options. 2 // rdar://10383444 3 4 // Linux. 5 // RUN: %clang -### -c -g %s -target x86_64-linux-gnu 2>&1 \ 6 // RUN: | FileCheck -check-prefix=G -check-prefix=G_GDB %s 7 // RUN: %clang -### -c -g2 %s -target x86_64-linux-gnu 2>&1 \ 8 // RUN: | FileCheck -check-prefix=G %s 9 // RUN: %clang -### -c -g3 %s -target x86_64-linux-gnu 2>&1 \ 10 // RUN: | FileCheck -check-prefix=G %s 11 // RUN: %clang -### -c -ggdb %s -target x86_64-linux-gnu 2>&1 \ 12 // RUN: | FileCheck -check-prefix=G -check-prefix=G_GDB %s 13 // RUN: %clang -### -c -ggdb1 %s -target x86_64-linux-gnu 2>&1 \ 14 // RUN: | FileCheck -check-prefix=GLTO_ONLY -check-prefix=G_GDB %s 15 // RUN: %clang -### -c -ggdb3 %s -target x86_64-linux-gnu 2>&1 \ 16 // RUN: | FileCheck -check-prefix=G %s 17 // RUN: %clang -### -c -glldb %s -target x86_64-linux-gnu 2>&1 \ 18 // RUN: | FileCheck -check-prefix=G -check-prefix=G_LLDB %s 19 // RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \ 20 21 // Darwin. 22 // RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s 23 // RUN: %clang -### -c -g %s -target x86_64-apple-darwin 2>&1 \ 24 // RUN: | FileCheck -check-prefix=G_STANDALONE \ 25 // RUN: -check-prefix=G_DWARF2 \ 26 // RUN: -check-prefix=G_LLDB %s 27 // RUN: %clang -### -c -g %s -target x86_64-apple-darwin16 2>&1 \ 28 // RUN: | FileCheck -check-prefix=G_STANDALONE \ 29 // RUN: -check-prefix=G_DWARF4 \ 30 // RUN: -check-prefix=G_LLDB %s 31 // RUN: %clang -### -c -g2 %s -target x86_64-apple-darwin16 2>&1 \ 32 // RUN: | FileCheck -check-prefix=G_STANDALONE \ 33 // RUN: -check-prefix=G_DWARF4 %s 34 // RUN: %clang -### -c -g3 %s -target x86_64-apple-darwin16 2>&1 \ 35 // RUN: | FileCheck -check-prefix=G_STANDALONE \ 36 // RUN: -check-prefix=G_DWARF4 %s 37 // RUN: %clang -### -c -ggdb %s -target x86_64-apple-darwin16 2>&1 \ 38 // RUN: | FileCheck -check-prefix=G_STANDALONE \ 39 // RUN: -check-prefix=G_DWARF4 \ 40 // RUN: -check-prefix=G_GDB %s 41 // RUN: %clang -### -c -ggdb1 %s -target x86_64-apple-darwin16 2>&1 \ 42 // RUN: | FileCheck -check-prefix=GLTO_ONLY %s 43 // RUN: %clang -### -c -ggdb3 %s -target x86_64-apple-darwin16 2>&1 \ 44 // RUN: | FileCheck -check-prefix=G_STANDALONE \ 45 // RUN: -check-prefix=G_DWARF4 %s 46 // RUN: %clang -### -c -g %s -target x86_64-apple-macosx10.11 2>&1 \ 47 // RUN: | FileCheck -check-prefix=G_STANDALONE \ 48 // RUN: -check-prefix=G_DWARF4 %s 49 // RUN: %clang -### -c -g %s -target x86_64-apple-macosx10.10 2>&1 \ 50 // RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s 51 // RUN: %clang -### -c -g %s -target armv7-apple-ios9.0 2>&1 \ 52 // RUN: | FileCheck -check-prefix=G_STANDALONE \ 53 // RUN: -check-prefix=G_DWARF4 %s 54 // RUN: %clang -### -c -g %s -target armv7-apple-ios8.0 2>&1 \ 55 // RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s 56 // RUN: %clang -### -c -g %s -target armv7k-apple-watchos 2>&1 \ 57 // RUN: | FileCheck -check-prefix=G_STANDALONE \ 58 // RUN: -check-prefix=G_DWARF4 %s 59 // RUN: %clang -### -c -g %s -target arm64-apple-tvos9.0 2>&1 \ 60 // RUN: | FileCheck -check-prefix=G_STANDALONE \ 61 // RUN: -check-prefix=G_DWARF4 %s 62 63 // FreeBSD. 64 // RUN: %clang -### -c -g %s -target x86_64-pc-freebsd10.0 2>&1 \ 65 // RUN: | FileCheck -check-prefix=G_GDB %s 66 67 // On the PS4, -g defaults to -gno-column-info, and we always generate the 68 // arange section. 69 // RUN: %clang -### -c %s -target x86_64-scei-ps4 2>&1 \ 70 // RUN: | FileCheck -check-prefix=NOG_PS4 %s 71 // RUN: %clang -### -c %s -g -target x86_64-scei-ps4 2>&1 \ 72 // RUN: | FileCheck -check-prefix=G_PS4 %s 73 // RUN: %clang -### -c %s -g -target x86_64-scei-ps4 2>&1 \ 74 // RUN: | FileCheck -check-prefix=G_SCE %s 75 // RUN: %clang -### -c %s -g -target x86_64-scei-ps4 2>&1 \ 76 // RUN: | FileCheck -check-prefix=NOCI %s 77 // RUN: %clang -### -c %s -g -gcolumn-info -target x86_64-scei-ps4 2>&1 \ 78 // RUN: | FileCheck -check-prefix=CI %s 79 80 // RUN: %clang -### -c -gdwarf-2 %s 2>&1 \ 81 // RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s 82 // 83 // RUN: %clang -### -c -gfoo %s 2>&1 | FileCheck -check-prefix=G_NO %s 84 // RUN: %clang -### -c -g -g0 %s 2>&1 | FileCheck -check-prefix=G_NO %s 85 // RUN: %clang -### -c -ggdb0 %s 2>&1 | FileCheck -check-prefix=G_NO %s 86 // RUN: %clang -### -c -glldb -g0 %s 2>&1 | FileCheck -check-prefix=G_NO %s 87 // RUN: %clang -### -c -glldb -g1 %s 2>&1 \ 88 // RUN: | FileCheck -check-prefix=GLTO_ONLY -check-prefix=G_LLDB %s 89 // 90 // PS4 defaults to sce; -ggdb0 changes tuning but turns off debug info, 91 // then -g turns it back on without affecting tuning. 92 // RUN: %clang -### -c -ggdb0 -g -target x86_64-scei-ps4 %s 2>&1 \ 93 // RUN: | FileCheck -check-prefix=G -check-prefix=G_GDB %s 94 // 95 // RUN: %clang -### -c -g1 %s 2>&1 \ 96 // RUN: | FileCheck -check-prefix=GLTO_ONLY %s 97 // RUN: %clang -### -c -gmlt %s 2>&1 \ 98 // RUN: | FileCheck -check-prefix=GLTO_ONLY %s 99 // RUN: %clang -### -c -gline-tables-only %s 2>&1 \ 100 // RUN: | FileCheck -check-prefix=GLTO_ONLY %s 101 // RUN: %clang -### -c -gline-tables-only %s -target x86_64-apple-darwin 2>&1 \ 102 // RUN: | FileCheck -check-prefix=GLTO_ONLY %s 103 // RUN: %clang -### -c -gline-tables-only %s -target i686-pc-openbsd 2>&1 \ 104 // RUN: | FileCheck -check-prefix=GLTO_ONLY_DWARF2 %s 105 // RUN: %clang -### -c -gline-tables-only %s -target x86_64-pc-freebsd10.0 2>&1 \ 106 // RUN: | FileCheck -check-prefix=GLTO_ONLY_DWARF2 %s 107 // RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-linux-gnu 2>&1 \ 108 // RUN: | FileCheck -check-prefix=G_ONLY %s 109 // RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-apple-darwin16 2>&1 \ 110 // RUN: | FileCheck -check-prefix=G_STANDALONE -check-prefix=G_DWARF4 %s 111 // RUN: %clang -### -c -gline-tables-only -g %s -target i686-pc-openbsd 2>&1 \ 112 // RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s 113 // RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-pc-freebsd10.0 2>&1 \ 114 // RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s 115 // RUN: %clang -### -c -gline-tables-only -g %s -target i386-pc-solaris 2>&1 \ 116 // RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s 117 // RUN: %clang -### -c -gline-tables-only -g0 %s 2>&1 \ 118 // RUN: | FileCheck -check-prefix=GLTO_NO %s 119 // 120 // RUN: %clang -### -c -grecord-gcc-switches -gno-record-gcc-switches \ 121 // RUN: -gstrict-dwarf -gno-strict-dwarf %s 2>&1 \ 122 // RUN: | FileCheck -check-prefix=GIGNORE %s 123 // 124 // RUN: %clang -### -c -ggnu-pubnames %s 2>&1 | FileCheck -check-prefix=GOPT %s 125 // 126 // RUN: %clang -### -c -gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=GARANGE %s 127 // 128 // RUN: %clang -### -fdebug-types-section %s 2>&1 \ 129 // RUN: | FileCheck -check-prefix=FDTS %s 130 // 131 // RUN: %clang -### -fdebug-types-section -fno-debug-types-section %s 2>&1 \ 132 // RUN: | FileCheck -check-prefix=NOFDTS %s 133 // 134 // RUN: %clang -### -g -gno-column-info %s 2>&1 \ 135 // RUN: | FileCheck -check-prefix=NOCI %s 136 // 137 // RUN: %clang -### -g -target x86_64-unknown-unknown %s 2>&1 \ 138 // | FileCheck -check-prefix=CI %s 139 // 140 // RUN: %clang -### -gmodules %s 2>&1 \ 141 // RUN: | FileCheck -check-prefix=GEXTREFS %s 142 // 143 // RUN: %clang -### -gmodules -g %s 2>&1 \ 144 // RUN: | FileCheck -check-prefix=GEXTREFS %s 145 // 146 // RUN: %clang -### -gline-tables-only -gmodules %s 2>&1 \ 147 // RUN: | FileCheck -check-prefix=GEXTREFS %s 148 // 149 // RUN: %clang -### -gmodules -gline-tables-only %s 2>&1 \ 150 // RUN: | FileCheck -check-prefix=GLTO_ONLY %s 151 // 152 // G: "-cc1" 153 // G: "-debug-info-kind=limited" 154 // 155 // NOG_PS4: "-cc1" 156 // NOG_PS4-NOT "-dwarf-version= 157 // NOG_PS4: "-generate-arange-section" 158 // NOG_PS4-NOT: "-dwarf-version= 159 // 160 // G_PS4: "-cc1" 161 // G_PS4: "-dwarf-version= 162 // G_PS4: "-generate-arange-section" 163 // 164 // G_NO: "-cc1" 165 // G_NO-NOT: -debug-info-kind= 166 // 167 // GLTO_ONLY: "-cc1" 168 // GLTO_ONLY-NOT: "-dwarf-ext-refs" 169 // GLTO_ONLY: "-debug-info-kind=line-tables-only" 170 // GLTO_ONLY-NOT: "-dwarf-ext-refs" 171 // 172 // GLTO_ONLY_DWARF2: "-cc1" 173 // GLTO_ONLY_DWARF2: "-debug-info-kind=line-tables-only" 174 // GLTO_ONLY_DWARF2: "-dwarf-version=2" 175 // 176 // G_ONLY: "-cc1" 177 // G_ONLY: "-debug-info-kind=limited" 178 // 179 // These tests assert that "-gline-tables-only" "-g" uses the latter, 180 // but otherwise not caring about the DebugInfoKind. 181 // G_ONLY_DWARF2: "-cc1" 182 // G_ONLY_DWARF2: "-debug-info-kind={{standalone|limited}}" 183 // G_ONLY_DWARF2: "-dwarf-version=2" 184 // 185 // G_STANDALONE: "-cc1" 186 // G_STANDALONE: "-debug-info-kind=standalone" 187 // G_DWARF4: "-dwarf-version=4" 188 // 189 // G_GDB: "-debugger-tuning=gdb" 190 // G_LLDB: "-debugger-tuning=lldb" 191 // G_SCE: "-debugger-tuning=sce" 192 // 193 // This tests asserts that "-gline-tables-only" "-g0" disables debug info. 194 // GLTO_NO: "-cc1" 195 // GLTO_NO-NOT: -debug-info-kind= 196 // 197 // GIGNORE-NOT: "argument unused during compilation" 198 // 199 // GOPT: -generate-gnu-dwarf-pub-sections 200 // 201 // GARANGE: -generate-arange-section 202 // 203 // FDTS: "-backend-option" "-generate-type-units" 204 // 205 // NOFDTS-NOT: "-backend-option" "-generate-type-units" 206 // 207 // CI: "-dwarf-column-info" 208 // 209 // NOCI-NOT: "-dwarf-column-info" 210 // 211 // GEXTREFS: "-dwarf-ext-refs" "-fmodule-format=obj" "-debug-info-kind={{standalone|limited}}" 212 213 // RUN: not %clang -cc1 -debug-info-kind=watkind 2>&1 | FileCheck -check-prefix=BADSTRING1 %s 214 // BADSTRING1: error: invalid value 'watkind' in '-debug-info-kind=watkind' 215 // RUN: not %clang -cc1 -debugger-tuning=gmodal 2>&1 | FileCheck -check-prefix=BADSTRING2 %s 216 // BADSTRING2: error: invalid value 'gmodal' in '-debugger-tuning=gmodal' 217