Skip to content

Commit 42211bc

Browse files
committed
[RISCV] Disable generation of asynchronous unwind tables for RISCV baremetal
The below culprit patch enabled the generation of asynchronous unwind tables (-funwind-tables=2) by default for RISCV for both linux and RISCVToolChain baremetal object. However, since there are 2 baremetal toolchain objects for RISCV, this created a discrepancy between their behavior. Moreover, enabling the generation of asynchronous unwind tables based on whether `-gcc-toolchain` option is present or not doesn't seem to be the best criteria to decide on the same. Culprit Patch - https://reviews.llvm.org/D145164
1 parent 168002e commit 42211bc

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

clang/lib/Driver/ToolChains/RISCVToolchain.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ RISCVToolChain::GetUnwindLibType(const llvm::opt::ArgList &Args) const {
8686
return ToolChain::UNW_None;
8787
}
8888

89+
ToolChain::UnwindTableLevel RISCVToolChain::getDefaultUnwindTableLevel(
90+
const llvm::opt::ArgList &Args) const {
91+
return UnwindTableLevel::None;
92+
}
93+
8994
void RISCVToolChain::addClangTargetOptions(
9095
const llvm::opt::ArgList &DriverArgs,
9196
llvm::opt::ArgStringList &CC1Args,

clang/lib/Driver/ToolChains/RISCVToolchain.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class LLVM_LIBRARY_VISIBILITY RISCVToolChain : public Generic_ELF {
2828
RuntimeLibType GetDefaultRuntimeLibType() const override;
2929
UnwindLibType
3030
GetUnwindLibType(const llvm::opt::ArgList &Args) const override;
31+
UnwindTableLevel
32+
getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override;
3133
void
3234
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
3335
llvm::opt::ArgStringList &CC1Args) const override;

clang/test/Driver/clang-translation.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,3 +421,11 @@
421421
// MIPSN32R6EL: "-target-cpu" "mips64r6"
422422
// MIPSN32R6EL: "-target-abi" "n32"
423423
// MIPSN32R6EL: "-mfloat-abi" "hard"
424+
425+
// RUN: %clang --target=riscv32-unknown-elf --gcc-toolchain="" -### %s 2>&1 | FileCheck %s -check-prefix=NOUWTABLE
426+
// RUN: %clang --target=riscv32-unknown-elf --gcc-toolchain="" -fasynchronous-unwind-tables -### %s 2>&1 | FileCheck %s -check-prefix=UWTABLE
427+
// RUN: %clang --target=riscv64-unknown-elf --gcc-toolchain="" -### %s 2>&1 | FileCheck %s -check-prefix=NOUWTABLE
428+
// RUN: %clang --target=riscv64-unknown-elf --gcc-toolchain="" -fasynchronous-unwind-tables -### %s 2>&1 | FileCheck %s -check-prefix=UWTABLE
429+
//
430+
// UWTABLE: "-funwind-tables=2"
431+
// NOUWTABLE-NOT: "-funwind-tables=2"

0 commit comments

Comments
 (0)