File tree Expand file tree Collapse file tree 4 files changed +15
-0
lines changed Expand file tree Collapse file tree 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 =
8484
8585codegen_ssa_insufficient_vs_code_product = VS Code is a different product, and is not sufficient.
8686
87+ codegen_ssa_cpu_required = target requires to explicitly specify a cpu with `-C target-cpu`
88+
8789codegen_ssa_invalid_link_ordinal_nargs = incorrect number of arguments to `#[link_ordinal]`
8890 .note = the attribute requires exactly one argument
8991
Original file line number Diff line number Diff line change @@ -616,6 +616,11 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
616616 return ongoing_codegen;
617617 }
618618
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+
619624 let cgu_name_builder = & mut CodegenUnitNameBuilder :: new ( tcx) ;
620625
621626 // 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;
491491#[ diag( codegen_ssa_insufficient_vs_code_product) ]
492492pub ( crate ) struct InsufficientVSCodeProduct ;
493493
494+ #[ derive( Diagnostic ) ]
495+ #[ diag( codegen_ssa_cpu_required) ]
496+ pub ( crate ) struct CpuRequired ;
497+
494498#[ derive( Diagnostic ) ]
495499#[ diag( codegen_ssa_processing_dymutil_failed) ]
496500#[ note]
Original file line number Diff line number Diff line change @@ -2240,6 +2240,9 @@ pub struct TargetOptions {
22402240 /// Default CPU to pass to LLVM. Corresponds to `llc -mcpu=$cpu`. Defaults
22412241 /// to "generic".
22422242 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 ,
22432246 /// Default target features to pass to LLVM. These features overwrite
22442247 /// `-Ctarget-cpu` but can be overwritten with `-Ctarget-features`.
22452248 /// Corresponds to `llc -mattr=$features`.
@@ -2676,6 +2679,7 @@ impl Default for TargetOptions {
26762679 link_script : None ,
26772680 asm_args : cvs ! [ ] ,
26782681 cpu : "generic" . into ( ) ,
2682+ need_explicit_cpu : false ,
26792683 features : "" . into ( ) ,
26802684 direct_access_external_data : None ,
26812685 dynamic_linking : false ,
You can’t perform that action at this time.
0 commit comments