@@ -20,7 +20,7 @@ use serde_derive::Deserialize;
20
20
21
21
use crate :: builder:: crate_description;
22
22
use crate :: builder:: Cargo ;
23
- use crate :: builder:: { Builder , Kind , RunConfig , ShouldRun , Step } ;
23
+ use crate :: builder:: { Builder , Kind , PathSet , RunConfig , ShouldRun , Step , TaskPath } ;
24
24
use crate :: cache:: { Interned , INTERNER } ;
25
25
use crate :: config:: { LlvmLibunwind , RustcLto , TargetSelection } ;
26
26
use crate :: dist;
@@ -995,6 +995,44 @@ pub struct CodegenBackend {
995
995
pub backend : Interned < String > ,
996
996
}
997
997
998
+ fn needs_codegen_config ( run : & RunConfig < ' _ > ) -> bool {
999
+ let mut needs_codegen_cfg = false ;
1000
+ for path_set in & run. paths {
1001
+ needs_codegen_cfg = match path_set {
1002
+ PathSet :: Set ( set) => set. iter ( ) . any ( |p| is_codegen_cfg_needed ( p, run) ) ,
1003
+ PathSet :: Suite ( suite) => is_codegen_cfg_needed ( & suite, run) ,
1004
+ }
1005
+ }
1006
+ needs_codegen_cfg
1007
+ }
1008
+
1009
+ const CODEGEN_BACKEND_PREFIX : & str = "rustc_codegen_" ;
1010
+
1011
+ fn is_codegen_cfg_needed ( path : & TaskPath , run : & RunConfig < ' _ > ) -> bool {
1012
+ if path. path . to_str ( ) . unwrap ( ) . contains ( & CODEGEN_BACKEND_PREFIX ) {
1013
+ let mut needs_codegen_backend_config = true ;
1014
+ for & backend in & run. builder . config . rust_codegen_backends {
1015
+ if path
1016
+ . path
1017
+ . to_str ( )
1018
+ . unwrap ( )
1019
+ . ends_with ( & ( CODEGEN_BACKEND_PREFIX . to_owned ( ) + & backend) )
1020
+ {
1021
+ needs_codegen_backend_config = false ;
1022
+ }
1023
+ }
1024
+ if needs_codegen_backend_config {
1025
+ run. builder . info (
1026
+ "Warning: no codegen-backends config matched the requested path to build a codegen backend. \
1027
+ Help: add backend to codegen-backends in config.toml.",
1028
+ ) ;
1029
+ return true ;
1030
+ }
1031
+ }
1032
+
1033
+ return false ;
1034
+ }
1035
+
998
1036
impl Step for CodegenBackend {
999
1037
type Output = ( ) ;
1000
1038
const ONLY_HOSTS : bool = true ;
@@ -1006,6 +1044,10 @@ impl Step for CodegenBackend {
1006
1044
}
1007
1045
1008
1046
fn make_run ( run : RunConfig < ' _ > ) {
1047
+ if needs_codegen_config ( & run) {
1048
+ return ;
1049
+ }
1050
+
1009
1051
for & backend in & run. builder . config . rust_codegen_backends {
1010
1052
if backend == "llvm" {
1011
1053
continue ; // Already built as part of rustc
0 commit comments