]> granicus.if.org Git - clang/commitdiff
clang: default to DWARF 4 for FreeBSD 12.0 and later
authorEd Maste <emaste@freebsd.org>
Tue, 3 Sep 2019 16:30:21 +0000 (16:30 +0000)
committerEd Maste <emaste@freebsd.org>
Tue, 3 Sep 2019 16:30:21 +0000 (16:30 +0000)
Older FreeBSD versions included GDB 6.1 and had other tools that were
unable to handle debug information newer than DWARF 2.  Those tools have
since been updated.  (An old version of GDB is still kept for kernel
crash handling, but the kernel is compiled with an explicit -gdwarf2.)

Reviewed by: dim
Differential Revision: https://reviews.llvm.org/D66760

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@370779 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains/FreeBSD.cpp
lib/Driver/ToolChains/FreeBSD.h
test/Driver/debug-options.c

index 314a742f9cafcb151484bbbe29d31b84285f3fb5..8b7f3693384e4f7d3e8d72be5a78b97b91fbe4bb 100644 (file)
@@ -364,6 +364,12 @@ ToolChain::CXXStdlibType FreeBSD::GetDefaultCXXStdlibType() const {
   return ToolChain::CST_Libstdcxx;
 }
 
+unsigned FreeBSD::GetDefaultDwarfVersion() const {
+  if (getTriple().getOSMajorVersion() < 12)
+    return 2;
+  return 4;
+}
+
 void FreeBSD::addLibStdCxxIncludePaths(
     const llvm::opt::ArgList &DriverArgs,
     llvm::opt::ArgStringList &CC1Args) const {
index adfe21da372f308f394407de64d996ba19d0dd04..d17b3808ffaccaa295a71008197b433188b9d21b 100644 (file)
@@ -69,7 +69,7 @@ public:
       const llvm::opt::ArgList &Args) const override;
   bool isPIEDefault() const override;
   SanitizerMask getSupportedSanitizers() const override;
-  unsigned GetDefaultDwarfVersion() const override { return 2; }
+  unsigned GetDefaultDwarfVersion() const override;
   // Until dtrace (via CTF) and LLDB can deal with distributed debug info,
   // FreeBSD defaults to standalone/full debug info.
   bool GetDefaultStandaloneDebug() const override { return true; }
index dce72ff17d792d20b685bd1d00728c242db3ec2a..154c7891f8785212ec6ae7fca643de0a0d4664d3 100644 (file)
 // RUN:                         -check-prefix=G_DWARF4 %s
 
 // FreeBSD.
-// RUN: %clang -### -c -g %s -target x86_64-pc-freebsd10.0 2>&1 \
-// RUN:             | FileCheck -check-prefix=G_GDB %s
+// RUN: %clang -### -c -g %s -target x86_64-pc-freebsd11.0 2>&1 \
+// RUN:             | FileCheck -check-prefix=G_GDB \
+// RUN:                         -check-prefix=G_DWARF2 %s
+// RUN: %clang -### -c -g %s -target x86_64-pc-freebsd12.0 2>&1 \
+// RUN:             | FileCheck -check-prefix=G_GDB \
+// RUN:                         -check-prefix=G_DWARF4 %s
 
 // Windows.
 // RUN: %clang -### -c -g %s -target x86_64-w64-windows-gnu 2>&1 \