File tree 4 files changed +15
-0
lines changed
4 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,8 @@ codegen_ssa_incorrect_cgu_reuse_type =
84
84
85
85
codegen_ssa_insufficient_vs_code_product = VS Code is a different product, and is not sufficient.
86
86
87
+ codegen_ssa_cpu_required = target requires to explicitly specify a cpu with `-C target-cpu`
88
+
87
89
codegen_ssa_invalid_link_ordinal_nargs = incorrect number of arguments to `#[link_ordinal]`
88
90
.note = the attribute requires exactly one argument
89
91
Original file line number Diff line number Diff line change @@ -616,6 +616,11 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
616
616
return ongoing_codegen;
617
617
}
618
618
619
+ if tcx. sess . target . need_explicit_cpu && tcx. sess . opts . cg . target_cpu . is_none ( ) {
620
+ // The target has no default cpu, but none is set explicitly
621
+ tcx. dcx ( ) . emit_fatal ( errors:: CpuRequired ) ;
622
+ }
623
+
619
624
let cgu_name_builder = & mut CodegenUnitNameBuilder :: new ( tcx) ;
620
625
621
626
// Run the monomorphization collector and partition the collected items into
Original file line number Diff line number Diff line change @@ -491,6 +491,10 @@ pub(crate) struct CheckInstalledVisualStudio;
491
491
#[ diag( codegen_ssa_insufficient_vs_code_product) ]
492
492
pub ( crate ) struct InsufficientVSCodeProduct ;
493
493
494
+ #[ derive( Diagnostic ) ]
495
+ #[ diag( codegen_ssa_cpu_required) ]
496
+ pub ( crate ) struct CpuRequired ;
497
+
494
498
#[ derive( Diagnostic ) ]
495
499
#[ diag( codegen_ssa_processing_dymutil_failed) ]
496
500
#[ note]
Original file line number Diff line number Diff line change @@ -2240,6 +2240,9 @@ pub struct TargetOptions {
2240
2240
/// Default CPU to pass to LLVM. Corresponds to `llc -mcpu=$cpu`. Defaults
2241
2241
/// to "generic".
2242
2242
pub cpu : StaticCow < str > ,
2243
+ /// Wether a cpu needs to be explicitly set.
2244
+ /// Set to true if there is no default cpu. Defaults to false.
2245
+ pub need_explicit_cpu : bool ,
2243
2246
/// Default target features to pass to LLVM. These features overwrite
2244
2247
/// `-Ctarget-cpu` but can be overwritten with `-Ctarget-features`.
2245
2248
/// Corresponds to `llc -mattr=$features`.
@@ -2676,6 +2679,7 @@ impl Default for TargetOptions {
2676
2679
link_script : None ,
2677
2680
asm_args : cvs ! [ ] ,
2678
2681
cpu : "generic" . into ( ) ,
2682
+ need_explicit_cpu : false ,
2679
2683
features : "" . into ( ) ,
2680
2684
direct_access_external_data : None ,
2681
2685
dynamic_linking : false ,
You can’t perform that action at this time.
0 commit comments