Skip to content

Commit df38e64

Browse files
committed
deprecate -Csoft-float because it is unsound (and not fixable)
1 parent 9b82580 commit df38e64

File tree

5 files changed

+39
-2
lines changed

5 files changed

+39
-2
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

+7-1
Original file line numberDiff line numberDiff 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);

compiler/rustc_session/messages.ftl

+10
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ session_sanitizer_not_supported = {$us} sanitizer is not supported for this targ
107107
session_sanitizers_not_supported = {$us} sanitizers are not supported for this target
108108
109109
session_skipping_const_checks = skipping const checks
110+
111+
session_soft_float_deprecated =
112+
`-Csoft-float` is unsound and deprecated; use a corresponding *eabi target instead
113+
.note = it will be removed or ignored in a future version of Rust
114+
session_soft_float_deprecated_issue = see issue #129893 <https://github.com/rust-lang/rust/issues/129893> for more information
115+
116+
session_soft_float_ignored =
117+
`-Csoft-float` is ignored on this target; it only has an effect on *eabihf targets
118+
.note = this may become a hard error in a future version of Rust
119+
110120
session_split_debuginfo_unstable_platform = `-Csplit-debuginfo={$debuginfo}` is unstable on this platform
111121
112122
session_split_lto_unit_requires_lto = `-Zsplit-lto-unit` requires `-Clto`, `-Clto=thin`, or `-Clinker-plugin-lto`

compiler/rustc_session/src/errors.rs

+11
Original file line numberDiff line numberDiff line change
@@ -484,3 +484,14 @@ pub(crate) struct FunctionReturnThunkExternRequiresNonLargeCodeModel;
484484
pub(crate) struct FailedToCreateProfiler {
485485
pub(crate) err: String,
486486
}
487+
488+
#[derive(Diagnostic)]
489+
#[diag(session_soft_float_ignored)]
490+
#[note]
491+
pub(crate) struct SoftFloatIgnored;
492+
493+
#[derive(Diagnostic)]
494+
#[diag(session_soft_float_deprecated)]
495+
#[note]
496+
#[note(session_soft_float_deprecated_issue)]
497+
pub(crate) struct SoftFloatDeprecated;

compiler/rustc_session/src/options.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1615,7 +1615,7 @@ options! {
16151615
save_temps: bool = (false, parse_bool, [UNTRACKED],
16161616
"save all temporary output files during compilation (default: no)"),
16171617
soft_float: bool = (false, parse_bool, [TRACKED],
1618-
"use soft float ABI (*eabihf targets only) (default: no)"),
1618+
"deprecated option: use soft float ABI (*eabihf targets only) (default: no)"),
16191619
#[rustc_lint_opt_deny_field_access("use `Session::split_debuginfo` instead of this field")]
16201620
split_debuginfo: Option<SplitDebuginfo> = (None, parse_split_debuginfo, [TRACKED],
16211621
"how to handle split-debuginfo, a platform-specific option"),

compiler/rustc_session/src/session.rs

+10
Original file line numberDiff line numberDiff 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.

0 commit comments

Comments
 (0)