[PATCH] D157663: [Driver] Default riscv*- triples to -fdebug-default-version=4

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 10 20:49:21 PDT 2023


MaskRay updated this revision to Diff 549233.
MaskRay retitled this revision from "[Driver] Default riscv*-linux* to -fdebug-default-version=4" to "[Driver] Default riscv*- triples to -fdebug-default-version=4".
MaskRay edited the summary of this revision.
MaskRay added a comment.

Thanks for mentioning RISCVToolChain/Haiku.

Update ToolChain::


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157663/new/

https://reviews.llvm.org/D157663

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/clang-g-opts.c


Index: clang/test/Driver/clang-g-opts.c
===================================================================
--- clang/test/Driver/clang-g-opts.c
+++ clang/test/Driver/clang-g-opts.c
@@ -37,3 +37,8 @@
 
 // CHECK-WITH-G-STANDALONE: "-debug-info-kind=standalone"
 // CHECK-WITH-G-STANDALONE: "-dwarf-version=2"
+
+/// TODO: Special case before R_RISCV_SET_ULEB128 linker support becomes more widely available.
+// RUN: %clang -### -S %s -g --target=riscv64-linux-gnu 2>&1 | FileCheck --check-prefix=VERSION4 %s
+// RUN: %clang -### -S %s -g --target=riscv64-unknown-elf 2>&1 | FileCheck --check-prefix=VERSION4 %s
+// VERSION4: "-dwarf-version=4"
Index: clang/lib/Driver/ToolChain.cpp
===================================================================
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -427,6 +427,14 @@
   return UnwindTableLevel::None;
 }
 
+unsigned ToolChain::GetDefaultDwarfVersion() const {
+  // TODO: Remove the special case when R_RISCV_SET_ULEB128 linker support
+  // becomes more widely available.
+  if (getTriple().isRISCV())
+    return 4;
+  return 5;
+}
+
 Tool *ToolChain::getClang() const {
   if (!Clang)
     Clang.reset(new tools::Clang(*this, useIntegratedBackend()));
Index: clang/include/clang/Driver/ToolChain.h
===================================================================
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -561,7 +561,7 @@
 
   // Return the DWARF version to emit, in the absence of arguments
   // to the contrary.
-  virtual unsigned GetDefaultDwarfVersion() const { return 5; }
+  virtual unsigned GetDefaultDwarfVersion() const;
 
   // Some toolchains may have different restrictions on the DWARF version and
   // may need to adjust it. E.g. NVPTX may need to enforce DWARF2 even when host


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157663.549233.patch
Type: text/x-patch
Size: 1823 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230811/35229da6/attachment.bin>


More information about the cfe-commits mailing list