@@ -807,8 +807,11 @@ impl Session {
807
807
// This is used to control the emission of the `uwtable` attribute on
808
808
// LLVM functions.
809
809
//
810
- // At the very least, unwind tables are needed when compiling with
811
- // `-C panic=unwind`.
810
+ // Unwind tables are needed when compiling with `-C panic=unwind`, but
811
+ // LLVM won't omit unwind tables unless the function is also marked as
812
+ // `nounwind`, so users are allowed to disable `uwtable` emission.
813
+ // Historically rustc always emits `uwtable` attributes by default, so
814
+ // even they can be disabled, they're still emitted by default.
812
815
//
813
816
// On some targets (including windows), however, exceptions include
814
817
// other events such as illegal instructions, segfaults, etc. This means
@@ -821,13 +824,10 @@ impl Session {
821
824
// If a target requires unwind tables, then they must be emitted.
822
825
// Otherwise, we can defer to the `-C force-unwind-tables=<yes/no>`
823
826
// value, if it is provided, or disable them, if not.
824
- if self . panic_strategy ( ) == PanicStrategy :: Unwind {
825
- true
826
- } else if self . target . requires_uwtable {
827
- true
828
- } else {
829
- self . opts . cg . force_unwind_tables . unwrap_or ( self . target . default_uwtable )
830
- }
827
+ self . target . requires_uwtable
828
+ || self . opts . cg . force_unwind_tables . unwrap_or (
829
+ self . panic_strategy ( ) == PanicStrategy :: Unwind || self . target . default_uwtable ,
830
+ )
831
831
}
832
832
833
833
/// Returns the symbol name for the registrar function,
@@ -1483,13 +1483,6 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
1483
1483
1484
1484
// Unwind tables cannot be disabled if the target requires them.
1485
1485
if let Some ( include_uwtables) = sess. opts . cg . force_unwind_tables {
1486
- if sess. panic_strategy ( ) == PanicStrategy :: Unwind && !include_uwtables {
1487
- sess. err (
1488
- "panic=unwind requires unwind tables, they cannot be disabled \
1489
- with `-C force-unwind-tables=no`.",
1490
- ) ;
1491
- }
1492
-
1493
1486
if sess. target . requires_uwtable && !include_uwtables {
1494
1487
sess. err (
1495
1488
"target requires unwind tables, they cannot be disabled with \
0 commit comments