At the time of writing, clang/docs/CommandGuide/clang.rst states
Enable generation of unwind information. This allows exceptions to be thrown through Clang compiled stack frames. This is on by default in x86-64.
However, this doesn't seem to actually turn on unwind information for a number of targets (note that the precise triple matters - e.g. a recent patch enabled asynchronous unwind tables by default on RISC-V Linux targets, which hides this issue somewhat):
$ cat test.cpp
int main(void) {
return 0;
}
$ for TGT in mips64 riscv64 sparc64 systemz; do echo $TGT; ./llvm-project/build/default/bin/clang++ -target $TGT test.cpp -fexceptions -S -o - | grep cfi; done
mips64
riscv64
sparc64
systemz
And here's what you get when explicitly enabling unwind tables:
$ for TGT in mips64 riscv64 sparc64 systemz; do echo $TGT; ./llvm-project/build/default/bin/clang++ -target $TGT test.cpp -funwind-tables -S -o - | grep cfi; done
mips64
.cfi_startproc
.cfi_def_cfa_offset 32
.cfi_offset 31, -8
.cfi_offset 30, -16
.cfi_def_cfa_register 30
.cfi_endproc
riscv64
.cfi_startproc
.cfi_def_cfa_offset 32
.cfi_offset ra, -8
.cfi_offset s0, -16
.cfi_def_cfa s0, 0
.cfi_endproc
sparc64
.cfi_startproc
.cfi_def_cfa_register %fp
.cfi_window_save
.cfi_register %o7, %i7
.cfi_endproc
systemz
.cfi_startproc
.cfi_offset %r11, -72
.cfi_offset %r15, -40
.cfi_def_cfa_offset 328
.cfi_def_cfa_register %r11
.cfi_endproc
Given the quoted documentation, I think I'd expect this same output for -fexceptions. Thanks to @mtvec for raising this issue.
At the time of writing,
clang/docs/CommandGuide/clang.rststatesHowever, this doesn't seem to actually turn on unwind information for a number of targets (note that the precise triple matters - e.g. a recent patch enabled asynchronous unwind tables by default on RISC-V Linux targets, which hides this issue somewhat):
And here's what you get when explicitly enabling unwind tables:
Given the quoted documentation, I think I'd expect this same output for
-fexceptions. Thanks to @mtvec for raising this issue.