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 // RUN: %clang -### -c %s -gsce -target x86_64-unknown-linux 2>&1 \ 80 // RUN: | FileCheck -check-prefix=NOCI %s 81 82 // RUN: %clang -### -c -gdwarf-2 %s 2>&1 \ 83 // RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s 84 // 85 // RUN: not %clang -### -c -gfoo %s 2>&1 | FileCheck -check-prefix=G_ERR %s 86 // RUN: %clang -### -c -g -g0 %s 2>&1 | FileCheck -check-prefix=G_NO %s 87 // RUN: %clang -### -c -ggdb0 %s 2>&1 | FileCheck -check-prefix=G_NO %s 88 // RUN: %clang -### -c -glldb -g0 %s 2>&1 | FileCheck -check-prefix=G_NO %s 89 // RUN: %clang -### -c -glldb -g1 %s 2>&1 \ 90 // RUN: | FileCheck -check-prefix=GLTO_ONLY -check-prefix=G_LLDB %s 91 // 92 // PS4 defaults to sce; -ggdb0 changes tuning but turns off debug info, 93 // then -g turns it back on without affecting tuning. 94 // RUN: %clang -### -c -ggdb0 -g -target x86_64-scei-ps4 %s 2>&1 \ 95 // RUN: | FileCheck -check-prefix=G -check-prefix=G_GDB %s 96 // 97 // RUN: %clang -### -c -g1 %s 2>&1 \ 98 // RUN: | FileCheck -check-prefix=GLTO_ONLY %s 99 // RUN: %clang -### -c -gmlt %s 2>&1 \ 100 // RUN: | FileCheck -check-prefix=GLTO_ONLY %s 101 // RUN: %clang -### -c -gline-tables-only %s 2>&1 \ 102 // RUN: | FileCheck -check-prefix=GLTO_ONLY %s 103 // RUN: %clang -### -c -gline-tables-only %s -target x86_64-apple-darwin 2>&1 \ 104 // RUN: | FileCheck -check-prefix=GLTO_ONLY %s 105 // RUN: %clang -### -c -gline-tables-only %s -target i686-pc-openbsd 2>&1 \ 106 // RUN: | FileCheck -check-prefix=GLTO_ONLY_DWARF2 %s 107 // RUN: %clang -### -c -gline-tables-only %s -target x86_64-pc-freebsd10.0 2>&1 \ 108 // RUN: | FileCheck -check-prefix=GLTO_ONLY_DWARF2 %s 109 // RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-linux-gnu 2>&1 \ 110 // RUN: | FileCheck -check-prefix=G_ONLY %s 111 // RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-apple-darwin16 2>&1 \ 112 // RUN: | FileCheck -check-prefix=G_STANDALONE -check-prefix=G_DWARF4 %s 113 // RUN: %clang -### -c -gline-tables-only -g %s -target i686-pc-openbsd 2>&1 \ 114 // RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s 115 // RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-pc-freebsd10.0 2>&1 \ 116 // RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s 117 // RUN: %clang -### -c -gline-tables-only -g %s -target i386-pc-solaris 2>&1 \ 118 // RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s 119 // RUN: %clang -### -c -gline-tables-only -g0 %s 2>&1 \ 120 // RUN: | FileCheck -check-prefix=GLTO_NO %s 121 // 122 // RUN: %clang -### -c -grecord-gcc-switches %s 2>&1 \ 123 // | FileCheck -check-prefix=GRECORD %s 124 // RUN: %clang -### -c -gno-record-gcc-switches %s 2>&1 \ 125 // | FileCheck -check-prefix=GNO_RECORD %s 126 // RUN: %clang -### -c -grecord-gcc-switches -gno-record-gcc-switches %s 2>&1 \ 127 // | FileCheck -check-prefix=GNO_RECORD %s/ 128 // RUN: %clang -### -c -grecord-gcc-switches -o - %s 2>&1 \ 129 // | FileCheck -check-prefix=GRECORD_O %s 130 // RUN: %clang -### -c -O3 -ffunction-sections -grecord-gcc-switches %s 2>&1 \ 131 // | FileCheck -check-prefix=GRECORD_OPT %s 132 // 133 // RUN: %clang -### -c -gstrict-dwarf -gno-strict-dwarf %s 2>&1 \ 134 // RUN: | FileCheck -check-prefix=GIGNORE %s 135 // 136 // RUN: %clang -### -c -ggnu-pubnames %s 2>&1 | FileCheck -check-prefix=GOPT %s 137 // 138 // RUN: %clang -### -c -gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=GARANGE %s 139 // 140 // RUN: %clang -### -fdebug-types-section %s 2>&1 \ 141 // RUN: | FileCheck -check-prefix=FDTS %s 142 // 143 // RUN: %clang -### -fdebug-types-section -fno-debug-types-section %s 2>&1 \ 144 // RUN: | FileCheck -check-prefix=NOFDTS %s 145 // 146 // RUN: %clang -### -g -gno-column-info %s 2>&1 \ 147 // RUN: | FileCheck -check-prefix=NOCI %s 148 // 149 // RUN: %clang -### -g -target x86_64-unknown-unknown %s 2>&1 \ 150 // | FileCheck -check-prefix=CI %s 151 // 152 // RUN: %clang -### -gmodules %s 2>&1 \ 153 // RUN: | FileCheck -check-prefix=GEXTREFS %s 154 // 155 // RUN: %clang -### -gmodules -g %s 2>&1 \ 156 // RUN: | FileCheck -check-prefix=GEXTREFS %s 157 // 158 // RUN: %clang -### -gline-tables-only -gmodules %s 2>&1 \ 159 // RUN: | FileCheck -check-prefix=GEXTREFS %s 160 // 161 // RUN: %clang -### -gmodules -gline-tables-only %s 2>&1 \ 162 // RUN: | FileCheck -check-prefix=GLTO_ONLY %s 163 // 164 // G: "-cc1" 165 // G: "-debug-info-kind=limited" 166 // 167 // NOG_PS4: "-cc1" 168 // NOG_PS4-NOT "-dwarf-version= 169 // NOG_PS4: "-generate-arange-section" 170 // NOG_PS4-NOT: "-dwarf-version= 171 // 172 // G_PS4: "-cc1" 173 // G_PS4: "-dwarf-version= 174 // G_PS4: "-generate-arange-section" 175 // 176 // G_ERR: error: unknown argument: 177 // 178 // G_NO: "-cc1" 179 // G_NO-NOT: -debug-info-kind= 180 // 181 // GLTO_ONLY: "-cc1" 182 // GLTO_ONLY-NOT: "-dwarf-ext-refs" 183 // GLTO_ONLY: "-debug-info-kind=line-tables-only" 184 // GLTO_ONLY-NOT: "-dwarf-ext-refs" 185 // 186 // GLTO_ONLY_DWARF2: "-cc1" 187 // GLTO_ONLY_DWARF2: "-debug-info-kind=line-tables-only" 188 // GLTO_ONLY_DWARF2: "-dwarf-version=2" 189 // 190 // G_ONLY: "-cc1" 191 // G_ONLY: "-debug-info-kind=limited" 192 // 193 // These tests assert that "-gline-tables-only" "-g" uses the latter, 194 // but otherwise not caring about the DebugInfoKind. 195 // G_ONLY_DWARF2: "-cc1" 196 // G_ONLY_DWARF2: "-debug-info-kind={{standalone|limited}}" 197 // G_ONLY_DWARF2: "-dwarf-version=2" 198 // 199 // G_STANDALONE: "-cc1" 200 // G_STANDALONE: "-debug-info-kind=standalone" 201 // G_DWARF4: "-dwarf-version=4" 202 // 203 // G_GDB: "-debugger-tuning=gdb" 204 // G_LLDB: "-debugger-tuning=lldb" 205 // G_SCE: "-debugger-tuning=sce" 206 // 207 // This tests asserts that "-gline-tables-only" "-g0" disables debug info. 208 // GLTO_NO: "-cc1" 209 // GLTO_NO-NOT: -debug-info-kind= 210 // 211 // GRECORD: "-dwarf-debug-flags" 212 // GRECORD: -### -c -grecord-gcc-switches 213 // 214 // GNO_RECORD-NOT: "-dwarf-debug-flags" 215 // GNO_RECORD-NOT: -### -c -grecord-gcc-switches 216 // 217 // GRECORD_O: "-dwarf-debug-flags" 218 // GRECORD_O: -### -c -grecord-gcc-switches -o - 219 // 220 // GRECORD_OPT: -### -c -O3 -ffunction-sections -grecord-gcc-switches 221 // 222 // GIGNORE-NOT: "argument unused during compilation" 223 // 224 // GOPT: -ggnu-pubnames 225 // 226 // GARANGE: -generate-arange-section 227 // 228 // FDTS: "-backend-option" "-generate-type-units" 229 // 230 // NOFDTS-NOT: "-backend-option" "-generate-type-units" 231 // 232 // CI: "-dwarf-column-info" 233 // 234 // NOCI-NOT: "-dwarf-column-info" 235 // 236 // GEXTREFS: "-dwarf-ext-refs" "-fmodule-format=obj" "-debug-info-kind={{standalone|limited}}" 237 238 // RUN: not %clang -cc1 -debug-info-kind=watkind 2>&1 | FileCheck -check-prefix=BADSTRING1 %s 239 // BADSTRING1: error: invalid value 'watkind' in '-debug-info-kind=watkind' 240 // RUN: not %clang -cc1 -debugger-tuning=gmodal 2>&1 | FileCheck -check-prefix=BADSTRING2 %s 241 // BADSTRING2: error: invalid value 'gmodal' in '-debugger-tuning=gmodal' 242 243 // RUN: %clang -### -fdebug-macro %s 2>&1 | FileCheck -check-prefix=MACRO %s 244 // RUN: %clang -### -fno-debug-macro %s 2>&1 | FileCheck -check-prefix=NOMACRO %s 245 // RUN: %clang -### %s 2>&1 | FileCheck -check-prefix=NOMACRO %s 246 // MACRO: "-debug-info-macro" 247 // NOMACRO-NOT: "-debug-info-macro" 248