Skip to content

Commit 8e55395

Browse files
committed
show a warning when -Csoft-float is used on a non-eabihf target
1 parent 9b82580 commit 8e55395

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

compiler/rustc_codegen_llvm/messages.ftl

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ codegen_llvm_missing_features =
3939
codegen_llvm_multiple_source_dicompileunit = multiple source DICompileUnits found
4040
codegen_llvm_multiple_source_dicompileunit_with_llvm_err = multiple source DICompileUnits found: {$llvm_err}
4141
42+
codegen_llvm_soft_float_ignored =
43+
`-Csoft-float` is ignored on this target; it only has an effect on `*eabihf` targets
44+
4245
codegen_llvm_parse_bitcode = failed to parse bitcode for LTO module
4346
codegen_llvm_parse_bitcode_with_llvm_err = failed to parse bitcode for LTO module: {$llvm_err}
4447

compiler/rustc_codegen_llvm/src/back/write.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use crate::back::profiling::{
3535
selfprofile_after_pass_callback, selfprofile_before_pass_callback, LlvmSelfProfiler,
3636
};
3737
use crate::errors::{
38-
CopyBitcode, FromLlvmDiag, FromLlvmOptimizationDiag, LlvmError, UnknownCompression,
38+
self, CopyBitcode, FromLlvmDiag, FromLlvmOptimizationDiag, LlvmError, UnknownCompression,
3939
WithLlvmError, WriteBytecode,
4040
};
4141
use crate::llvm::diagnostic::OptimizationDiagnosticKind;
@@ -185,7 +185,16 @@ 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+
// All `use_softfp` does is the equivalent of `-mfloat-abi` in GCC/clang, which only exists on ARM targets.
192+
// We document this flag to only affect `*eabihf` targets, so let's show a warning for all other targets.
193+
if sess.opts.cg.soft_float {
194+
sess.dcx().emit_warn(errors::SoftFloatIgnored);
195+
}
196+
false
197+
};
189198

190199
let ffunction_sections =
191200
sess.opts.unstable_opts.function_sections.unwrap_or(sess.target.function_sections);

compiler/rustc_codegen_llvm/src/errors.rs

+4
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,7 @@ pub(crate) struct InvalidTargetFeaturePrefix<'a> {
231231
pub(crate) struct FixedX18InvalidArch<'a> {
232232
pub arch: &'a str,
233233
}
234+
235+
#[derive(Diagnostic)]
236+
#[diag(codegen_llvm_soft_float_ignored)]
237+
pub(crate) struct SoftFloatIgnored;

0 commit comments

Comments
 (0)