@@ -844,8 +844,11 @@ impl Session {
844
844
// This is used to control the emission of the `uwtable` attribute on
845
845
// LLVM functions.
846
846
//
847
- // At the very least, unwind tables are needed when compiling with
848
- // `-C panic=unwind`.
847
+ // Unwind tables are needed when compiling with `-C panic=unwind`, but
848
+ // LLVM won't omit unwind tables unless the function is also marked as
849
+ // `nounwind`, so users are allowed to disable `uwtable` emission.
850
+ // Historically rustc always emits `uwtable` attributes by default, so
851
+ // even they can be disabled, they're still emitted by default.
849
852
//
850
853
// On some targets (including windows), however, exceptions include
851
854
// other events such as illegal instructions, segfaults, etc. This means
@@ -858,13 +861,10 @@ impl Session {
858
861
// If a target requires unwind tables, then they must be emitted.
859
862
// Otherwise, we can defer to the `-C force-unwind-tables=<yes/no>`
860
863
// value, if it is provided, or disable them, if not.
861
- if self . panic_strategy ( ) == PanicStrategy :: Unwind {
862
- true
863
- } else if self . target . requires_uwtable {
864
- true
865
- } else {
866
- self . opts . cg . force_unwind_tables . unwrap_or ( self . target . default_uwtable )
867
- }
864
+ self . target . requires_uwtable
865
+ || self . opts . cg . force_unwind_tables . unwrap_or (
866
+ self . panic_strategy ( ) == PanicStrategy :: Unwind || self . target . default_uwtable ,
867
+ )
868
868
}
869
869
870
870
/// Returns the symbol name for the registrar function,
@@ -1536,13 +1536,6 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
1536
1536
1537
1537
// Unwind tables cannot be disabled if the target requires them.
1538
1538
if let Some ( include_uwtables) = sess. opts . cg . force_unwind_tables {
1539
- if sess. panic_strategy ( ) == PanicStrategy :: Unwind && !include_uwtables {
1540
- sess. err (
1541
- "panic=unwind requires unwind tables, they cannot be disabled \
1542
- with `-C force-unwind-tables=no`.",
1543
- ) ;
1544
- }
1545
-
1546
1539
if sess. target . requires_uwtable && !include_uwtables {
1547
1540
sess. err (
1548
1541
"target requires unwind tables, they cannot be disabled with \
0 commit comments