File tree Expand file tree Collapse file tree 4 files changed +35
-1
lines changed
rustc_codegen_llvm/src/back Expand file tree Collapse file tree 4 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -185,7 +185,13 @@ pub(crate) fn target_machine_factory(
185185 let reloc_model = to_llvm_relocation_model ( sess. relocation_model ( ) ) ;
186186
187187 let ( opt_level, _) = to_llvm_opt_settings ( optlvl) ;
188- let use_softfp = sess. opts . cg . soft_float ;
188+ let use_softfp = if sess. target . arch == "arm" && sess. target . abi == "eabihf" {
189+ sess. opts . cg . soft_float
190+ } else {
191+ // `validate_commandline_args_with_session_available` has already warned about this being ignored.
192+ // Let's make sure LLVM doesn't suddenly start using this flag on more targets.
193+ false
194+ } ;
189195
190196 let ffunction_sections =
191197 sess. opts . unstable_opts . function_sections . unwrap_or ( sess. target . function_sections ) ;
Original file line number Diff line number Diff line change @@ -18,6 +18,14 @@ session_embed_source_insufficient_dwarf_version = `-Zembed-source=y` requires at
1818
1919session_embed_source_requires_debug_info = `-Zembed-source=y` requires debug information to be enabled
2020
21+ session_soft_float_deprecated =
22+ `-Csoft-float` is unsound and deprecated; use a corresponding *eabi target instead
23+ .note = it will be removed or ignored in a future version of Rust
24+ session_soft_float_deprecated_issue = see issue #129893 <https://github.com/rust-lang/rust/issues/129893> for more information
25+
26+ session_soft_float_ignored =
27+ `-Csoft-float` is ignored on this target; it only has an effect on *eabihf targets
28+
2129session_expr_parentheses_needed = parentheses are required to parse this as an expression
2230
2331session_failed_to_create_profiler = failed to create profiler: { $err }
Original file line number Diff line number Diff line change @@ -484,3 +484,13 @@ pub(crate) struct FunctionReturnThunkExternRequiresNonLargeCodeModel;
484484pub ( crate ) struct FailedToCreateProfiler {
485485 pub ( crate ) err : String ,
486486}
487+
488+ #[ derive( Diagnostic ) ]
489+ #[ diag( session_soft_float_ignored) ]
490+ pub ( crate ) struct SoftFloatIgnored ;
491+
492+ #[ derive( Diagnostic ) ]
493+ #[ diag( session_soft_float_deprecated) ]
494+ #[ note]
495+ #[ note( session_soft_float_deprecated_issue) ]
496+ pub ( crate ) struct SoftFloatDeprecated ;
Original file line number Diff line number Diff line change @@ -1340,6 +1340,16 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
13401340 }
13411341 }
13421342 }
1343+
1344+ if sess. opts . cg . soft_float {
1345+ if sess. target . arch == "arm" && sess. target . abi == "eabihf" {
1346+ sess. dcx ( ) . emit_warn ( errors:: SoftFloatDeprecated ) ;
1347+ } else {
1348+ // All `use_softfp` does is the equivalent of `-mfloat-abi` in GCC/clang, which only exists on ARM targets.
1349+ // We document this flag to only affect `*eabihf` targets, so let's show a warning for all other targets.
1350+ sess. dcx ( ) . emit_warn ( errors:: SoftFloatIgnored ) ;
1351+ }
1352+ }
13431353}
13441354
13451355/// Holds data on the current incremental compilation session, if there is one.
You can’t perform that action at this time.
0 commit comments