From: Brad Smith Date: Fri, 13 Jun 2014 03:35:37 +0000 (+0000) Subject: Use dwarf-2 by default on OpenBSD and FreeBSD. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=378e7f9b78dfd2fa5d1830b32d053d8b283bd117;p=platform%2Fupstream%2Fllvm.git Use dwarf-2 by default on OpenBSD and FreeBSD. The Tools.cpp part of the patch partially based on a patch from FreeBSD's LLVM tree. llvm-svn: 210883 --- diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index d4ce04a..0df398b 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -2885,8 +2885,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // FIXME: we should support specifying dwarf version with // -gline-tables-only. CmdArgs.push_back("-gline-tables-only"); - // Default is dwarf-2 for darwin. - if (getToolChain().getTriple().isOSDarwin()) + // Default is dwarf-2 for Darwin, OpenBSD and FreeBSD. + const llvm::Triple &Triple = getToolChain().getTriple(); + if (Triple.isOSDarwin() || Triple.getOS() == llvm::Triple::OpenBSD || + Triple.getOS() == llvm::Triple::FreeBSD) CmdArgs.push_back("-gdwarf-2"); } else if (A->getOption().matches(options::OPT_gdwarf_2)) CmdArgs.push_back("-gdwarf-2"); @@ -2896,8 +2898,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-gdwarf-4"); else if (!A->getOption().matches(options::OPT_g0) && !A->getOption().matches(options::OPT_ggdb0)) { - // Default is dwarf-2 for darwin. - if (getToolChain().getTriple().isOSDarwin()) + // Default is dwarf-2 for Darwin, OpenBSD and FreeBSD. + const llvm::Triple &Triple = getToolChain().getTriple(); + if (Triple.isOSDarwin() || Triple.getOS() == llvm::Triple::OpenBSD || + Triple.getOS() == llvm::Triple::FreeBSD) CmdArgs.push_back("-gdwarf-2"); else CmdArgs.push_back("-g"); diff --git a/clang/test/CodeGen/dwarf-version.c b/clang/test/CodeGen/dwarf-version.c index 6c0f097..0c67b4f 100644 --- a/clang/test/CodeGen/dwarf-version.c +++ b/clang/test/CodeGen/dwarf-version.c @@ -1,14 +1,14 @@ -// RUN: %clang -target x86_64-linux-gnu -gdwarf-2 -S -emit-llvm -o - %s | FileCheck %s +// RUN: %clang -target x86_64-linux-gnu -gdwarf-2 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2 // 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 +// RUN: %clang -target x86_64-linux-gnu -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4 +// RUN: %clang -target x86_64-apple-darwin -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2 +// RUN: %clang -target powerpc-unknown-openbsd -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2 +// RUN: %clang -target powerpc-unknown-freebsd -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2 int main (void) { return 0; } -// CHECK: metadata !{i32 2, metadata !"Dwarf Version", i32 2} +// VER2: 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 4} -// DARWIN: metadata !{i32 2, metadata !"Dwarf Version", i32 2} diff --git a/clang/test/Driver/clang-g-opts.c b/clang/test/Driver/clang-g-opts.c index 9ca1fd3..7a52751 100644 --- a/clang/test/Driver/clang-g-opts.c +++ b/clang/test/Driver/clang-g-opts.c @@ -2,15 +2,23 @@ // RUN: %clang -### -S %s -g -target x86_64-linux-gnu 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-WITH-G %s // RUN: %clang -### -S %s -g -target x86_64-apple-darwin 2>&1 \ -// RUN: | FileCheck --check-prefix=CHECK-WITH-G-DARWIN %s +// RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s +// RUN: %clang -### -S %s -g -target i686-pc-openbsd 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s +// RUN: %clang -### -S %s -g -target x86_64-pc-freebsd10.0 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s // RUN: %clang -### -S %s -g0 2>&1 | FileCheck --check-prefix=CHECK-WITHOUT-G %s // RUN: %clang -### -S %s -g -g0 2>&1 | FileCheck --check-prefix=CHECK-WITHOUT-G %s // RUN: %clang -### -S %s -g0 -g -target x86_64-linux-gnu 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-WITH-G %s // RUN: %clang -### -S %s -g0 -g -target x86_64-apple-darwin 2>&1 \ -// RUN: | FileCheck --check-prefix=CHECK-WITH-G-DARWIN %s +// RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s +// RUN: %clang -### -S %s -g0 -g -target i686-pc-openbsd 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s +// RUN: %clang -### -S %s -g0 -g -target x86_64-pc-freebsd10.02>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s // CHECK-WITHOUT-G-NOT: "-g" // CHECK-WITH-G: "-g" -// CHECK-WITH-G-DARWIN: "-gdwarf-2" +// CHECK-WITH-G-DWARF2: "-gdwarf-2" diff --git a/clang/test/Driver/debug-options.c b/clang/test/Driver/debug-options.c index 48f686b..e179ef0 100644 --- a/clang/test/Driver/debug-options.c +++ b/clang/test/Driver/debug-options.c @@ -38,11 +38,19 @@ // RUN: %clang -### -c -gline-tables-only %s 2>&1 \ // RUN: | FileCheck -check-prefix=GLTO_ONLY %s // RUN: %clang -### -c -gline-tables-only %s -target x86_64-apple-darwin 2>&1 \ -// RUN: | FileCheck -check-prefix=GLTO_ONLY_DARWIN %s +// RUN: | FileCheck -check-prefix=GLTO_ONLY_DWARF2 %s +// RUN: %clang -### -c -gline-tables-only %s -target i686-pc-openbsd 2>&1 \ +// RUN: | FileCheck -check-prefix=GLTO_ONLY_DWARF2 %s +// RUN: %clang -### -c -gline-tables-only %s -target x86_64-pc-freebsd10.0 2>&1 \ +// RUN: | FileCheck -check-prefix=GLTO_ONLY_DWARF2 %s // RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-linux-gnu 2>&1 \ // RUN: | FileCheck -check-prefix=G_ONLY %s // RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-apple-darwin 2>&1 \ -// RUN: | FileCheck -check-prefix=G_ONLY_DARWIN %s +// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s +// RUN: %clang -### -c -gline-tables-only -g %s -target i686-pc-openbsd 2>&1 \ +// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s +// RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-pc-freebsd10.0 2>&1 \ +// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s // RUN: %clang -### -c -gline-tables-only -g0 %s 2>&1 \ // RUN: | FileCheck -check-prefix=GLTO_NO %s // @@ -78,21 +86,21 @@ // GLTO_ONLY: "-gline-tables-only" // GLTO_ONLY-NOT: "-g" // -// GLTO_ONLY_DARWIN: "-cc1" -// GLTO_ONLY_DARWIN-NOT: "-g" -// GLTO_ONLY_DARWIN: "-gline-tables-only" -// GLTO_ONLY_DARWIN: "-gdwarf-2" -// GLTO_ONLY_DARWIN-NOT: "-g" +// GLTO_ONLY_DWARF2: "-cc1" +// GLTO_ONLY_DWARF2-NOT: "-g" +// GLTO_ONLY_DWARF2: "-gline-tables-only" +// GLTO_ONLY_DWARF2: "-gdwarf-2" +// GLTO_ONLY_DWARF2-NOT: "-g" // // G_ONLY: "-cc1" // G_ONLY-NOT: "-gline-tables-only" // G_ONLY: "-g" // G_ONLY-NOT: "-gline-tables-only" // -// G_ONLY_DARWIN: "-cc1" -// G_ONLY_DARWIN-NOT: "-gline-tables-only" -// G_ONLY_DARWIN: "-gdwarf-2" -// G_ONLY_DARWIN-NOT: "-gline-tables-only" +// G_ONLY_DWARF2: "-cc1" +// G_ONLY_DWARF2-NOT: "-gline-tables-only" +// G_ONLY_DWARF2: "-gdwarf-2" +// G_ONLY_DWARF2-NOT: "-gline-tables-only" // // GLTO_NO: "-cc1" // GLTO_NO-NOT: "-gline-tables-only"