diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp --- a/clang/lib/Driver/ToolChains/Linux.cpp +++ b/clang/lib/Driver/ToolChains/Linux.cpp @@ -343,7 +343,7 @@ } unsigned Linux::GetDefaultDwarfVersion() const { - if (getTriple().isAndroid()) + if (getTriple().isAndroid() || getTriple().isRISCV()) return 4; return ToolChain::GetDefaultDwarfVersion(); } diff --git a/clang/test/Driver/clang-g-opts.c b/clang/test/Driver/clang-g-opts.c --- a/clang/test/Driver/clang-g-opts.c +++ b/clang/test/Driver/clang-g-opts.c @@ -37,3 +37,7 @@ // CHECK-WITH-G-STANDALONE: "-debug-info-kind=standalone" // CHECK-WITH-G-STANDALONE: "-dwarf-version=2" + +// RUN: %clang -### -S %s -g --target=riscv64-linux-gnu 2>&1 \ +// RUN: | FileCheck --check-prefix=VERSION4 %s +// VERSION4: "-dwarf-version=4"