From 192c1e3f91f4364f452ff23e57340aaaa2d83b80 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Tue, 3 Sep 2019 16:30:21 +0000 Subject: [PATCH] clang: default to DWARF 4 for FreeBSD 12.0 and later 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 | 6 ++++++ lib/Driver/ToolChains/FreeBSD.h | 2 +- test/Driver/debug-options.c | 8 ++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/Driver/ToolChains/FreeBSD.cpp b/lib/Driver/ToolChains/FreeBSD.cpp index 314a742f9c..8b7f369338 100644 --- a/lib/Driver/ToolChains/FreeBSD.cpp +++ b/lib/Driver/ToolChains/FreeBSD.cpp @@ -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 { diff --git a/lib/Driver/ToolChains/FreeBSD.h b/lib/Driver/ToolChains/FreeBSD.h index adfe21da37..d17b3808ff 100644 --- a/lib/Driver/ToolChains/FreeBSD.h +++ b/lib/Driver/ToolChains/FreeBSD.h @@ -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; } diff --git a/test/Driver/debug-options.c b/test/Driver/debug-options.c index dce72ff17d..154c7891f8 100644 --- a/test/Driver/debug-options.c +++ b/test/Driver/debug-options.c @@ -66,8 +66,12 @@ // 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 \ -- 2.40.0