else if (A->getOption().matches(options::OPT_gdwarf_4))
CmdArgs.push_back("-gdwarf-4");
else if (!A->getOption().matches(options::OPT_g0) &&
- !A->getOption().matches(options::OPT_ggdb0))
- CmdArgs.push_back("-g");
+ !A->getOption().matches(options::OPT_ggdb0)) {
+ // Default is dwarf-2 for darwin.
+ if (getToolChain().getTriple().isOSDarwin())
+ CmdArgs.push_back("-gdwarf-2");
+ else
+ CmdArgs.push_back("-g");
+ }
}
// We ignore flags -gstrict-dwarf and -grecord-gcc-switches for now.
// RUN: %clang -target x86_64-linux-gnu -gdwarf-2 -S -emit-llvm -o - %s | FileCheck %s
// RUN: %clang -target x86_64-linux-gnu -gdwarf-3 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER3
// RUN: %clang -target x86_64-linux-gnu -gdwarf-4 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4
+// RUN: %clang -target x86_64-linux-gnu -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=LINUX
+// RUN: %clang -target x86_64-apple-darwin -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DARWIN
int main (void) {
return 0;
}
// CHECK: metadata !{i32 2, metadata !"Dwarf Version", i32 2}
// VER3: metadata !{i32 2, metadata !"Dwarf Version", i32 3}
// VER4: metadata !{i32 2, metadata !"Dwarf Version", i32 4}
+// LINUX: metadata !{i32 2, metadata !"Dwarf Version", i32 3}
+// DARWIN: metadata !{i32 2, metadata !"Dwarf Version", i32 2}
// RUN: | FileCheck -check-prefix=GIGNORE %s
//
// G: "-cc1"
-// G: "-g"
+// Can be -gdwarf.
+// G: "-g
//
// G_D2: "-cc1"
// G_D2: "-gdwarf-2"
//
// G_ONLY: "-cc1"
// G_ONLY-NOT: "-gline-tables-only"
-// G_ONLY: "-g"
+// G_ONLY: "-g
// G_ONLY-NOT: "-gline-tables-only"
//
// GLTO_NO: "-cc1"