From 18cf4196f66c9e11ff744d85d2803af8d593dbe3 Mon Sep 17 00:00:00 2001 From: Martin Date: Sun, 25 Mar 2018 17:37:34 +0200 Subject: [PATCH] LLVM 6+: Default to Dwarf debuginfos v3 At least on Linux it appears to default to v4 or newer, which druntime's rt.backtrace.dwarf doesn't handle yet. This fixes tests/codegen/exception_stack_trace.d on Linux. --- driver/targetmachine.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/driver/targetmachine.cpp b/driver/targetmachine.cpp index d75a31b2c..70a09127c 100644 --- a/driver/targetmachine.cpp +++ b/driver/targetmachine.cpp @@ -458,6 +458,12 @@ createTargetMachine(const std::string targetTriple, const std::string arch, if (targetOptions.MCOptions.ABIName.empty()) targetOptions.MCOptions.ABIName = getABI(triple); +#if LDC_LLVM_VER >= 600 + // druntime isn't ready for Dwarf v4+ debuginfos (e.g., in rt.backtrace.dwarf). + if (targetOptions.MCOptions.DwarfVersion == 0) + targetOptions.MCOptions.DwarfVersion = 3; +#endif + auto ldcFloatABI = floatABI; if (ldcFloatABI == FloatABI::Default) { switch (triple.getArch()) {