Page MenuHomePhabricator

[Driver] Automatically enable -munwind-tables if -fseh-exceptions is enabled
ClosedPublic

Authored by mstorsjo on Dec 16 2018, 2:23 PM.

Details

Summary

For targets where SEH exceptions are used by default (on MinGW, only x86_64 so far), -munwind-tables are added automatically. If
-fseh-exeptions is enabled on a target where SEH exeptions are availble but not enabled by default yet (aarch64), we need to pass -munwind-tables if -fseh-exceptions was specified.

Once things have settled and this works fine in practice, the default can be switched from dwarf to SEH. Or is this unnecessary churn and we should just keep off this until the default can be changed?

Diff Detail

Repository
rC Clang

Event Timeline

mstorsjo created this revision.Dec 16 2018, 2:23 PM
rnk added inline comments.Dec 17 2018, 10:25 AM
lib/Driver/ToolChains/Clang.cpp
3929 ↗(On Diff #178410)

Can you put this logic in the Windows or mingw toolchain instead by overriding IsUnwindTablesDefault? -fseh-exceptions feels fairly target specific.

If not, this boolean default feels fairly complicated. Here's how I would restructure it:

bool UnwindTables = false;
if (!Freestanding)
  UnwindTables = TC.IsUnwindTablesDefault(Args) || TC.getSanitizerArgs().needsUnwindTables();
UnwindTables = Args.hasFlag(OPT_fasync..., OPT_fno_async..., UnwindTables);
UnwindTables = Args.hasFlag(OPT_munwind_tables, OPT_mno_unwind_tables, UnwindTables);

Basically, we have some defaults dictated by the toolchain, and then two boolean flags, where one takes precedence over the other. -fno-async by itself will disable unwind tables, but -munwind-tables -fno-asynchronous-unwind-tables will leave them enabled, despite not following the usual "last flag wins" logic.

mstorsjo marked 2 inline comments as done.Dec 17 2018, 12:22 PM
mstorsjo added inline comments.
lib/Driver/ToolChains/Clang.cpp
3929 ↗(On Diff #178410)

Can you put this logic in the Windows or mingw toolchain instead by overriding IsUnwindTablesDefault? -fseh-exceptions feels fairly target specific.

Yes, that seems to be doable. Thanks!

mstorsjo updated this revision to Diff 178513.Dec 17 2018, 12:23 PM
mstorsjo marked an inline comment as done.

Moved the added code to toolchains::MinGW::IsUnwindTablesDefault.

rnk accepted this revision.Dec 17 2018, 12:58 PM

lgtm

This revision is now accepted and ready to land.Dec 17 2018, 12:58 PM
This revision was automatically updated to reflect the committed changes.