Skip to content

Commit 8cc7535

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 8cc7535

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/riscv-features.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@
3535
// FAST-UNALIGNED-ACCESS: "-target-feature" "+fast-unaligned-access"
3636
// NO-FAST-UNALIGNED-ACCESS: "-target-feature" "-fast-unaligned-access"
3737

38+
// RUN: %clang --target=riscv32-unknown-elf --gcc-toolchain="" -### %s 2>&1 | FileCheck %s -check-prefix=NOUWTABLE
39+
// RUN: %clang --target=riscv32-unknown-elf --gcc-toolchain="" -fasynchronous-unwind-tables -### %s 2>&1 | FileCheck %s -check-prefix=UWTABLE
40+
// RUN: %clang --target=riscv64-unknown-elf --gcc-toolchain="" -### %s 2>&1 | FileCheck %s -check-prefix=NOUWTABLE
41+
// RUN: %clang --target=riscv64-unknown-elf --gcc-toolchain="" -fasynchronous-unwind-tables -### %s 2>&1 | FileCheck %s -check-prefix=UWTABLE
42+
//
43+
// UWTABLE: "-funwind-tables=2"
44+
// NOUWTABLE-NOT: "-funwind-tables=2"
45+
3846
// RUN: %clang --target=riscv32-linux -### %s -fsyntax-only 2>&1 \
3947
// RUN: | FileCheck %s -check-prefix=DEFAULT-LINUX
4048
// RUN: %clang --target=riscv64-linux -### %s -fsyntax-only 2>&1 \

0 commit comments

Comments
 (0)