From: Manman Ren Date: Tue, 2 Jul 2013 23:15:25 +0000 (+0000) Subject: Debug Info: set default to gdwarf-2 for Darwin. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8ed38d8046e642c2d81775ada2ecee821f2e2a02;p=clang Debug Info: set default to gdwarf-2 for Darwin. Darwin systems currently do not support dwarf version 3 or above. When we are ready, we can bump the default to gdwarf-4 for Darwin. For other systems, the default is dwarf version 3, if everything goes smoothly, we can bump the version to 4. rdar://13591116 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185483 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 7d634f55bc..d483149993 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -2521,8 +2521,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, 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. diff --git a/test/CodeGen/dwarf-version.c b/test/CodeGen/dwarf-version.c index 739f18db0a..6624b67538 100644 --- a/test/CodeGen/dwarf-version.c +++ b/test/CodeGen/dwarf-version.c @@ -1,6 +1,8 @@ // 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; } @@ -8,3 +10,5 @@ int main (void) { // 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} diff --git a/test/Driver/clang-g-opts.c b/test/Driver/clang-g-opts.c index f5d09fda3d..ee4eed7e89 100644 --- a/test/Driver/clang-g-opts.c +++ b/test/Driver/clang-g-opts.c @@ -5,5 +5,6 @@ // RUN: %clang -### -S %s -g0 -g 2>&1 | FileCheck --check-prefix=CHECK-WITH-G %s // CHECK-WITHOUT-G-NOT: "-g" -// CHECK-WITH-G: "-g" +// Can be -gdwarf. +// CHECK-WITH-G: "-g diff --git a/test/Driver/debug-options.c b/test/Driver/debug-options.c index 981fa90880..490b74656c 100644 --- a/test/Driver/debug-options.c +++ b/test/Driver/debug-options.c @@ -26,7 +26,8 @@ // RUN: | FileCheck -check-prefix=GIGNORE %s // // G: "-cc1" -// G: "-g" +// Can be -gdwarf. +// G: "-g // // G_D2: "-cc1" // G_D2: "-gdwarf-2" @@ -41,7 +42,7 @@ // // G_ONLY: "-cc1" // G_ONLY-NOT: "-gline-tables-only" -// G_ONLY: "-g" +// G_ONLY: "-g // G_ONLY-NOT: "-gline-tables-only" // // GLTO_NO: "-cc1"