@@ -39,7 +39,7 @@ use crate::core::config::toml::build::{Build, Tool};
39
39
use crate :: core:: config:: toml:: change_id:: ChangeId ;
40
40
use crate :: core:: config:: toml:: dist:: Dist ;
41
41
use crate :: core:: config:: toml:: rust:: {
42
- LldMode , RustOptimize , check_incompatible_options_for_ci_rustc,
42
+ LldMode , RustOptimize , check_incompatible_options_for_ci_rustc, validate_codegen_backends ,
43
43
} ;
44
44
use crate :: core:: config:: toml:: target:: Target ;
45
45
use crate :: core:: config:: {
@@ -956,7 +956,68 @@ impl Config {
956
956
config. rust_profile_use = flags_rust_profile_use;
957
957
config. rust_profile_generate = flags_rust_profile_generate;
958
958
959
- config. apply_target_config ( toml. target ) ;
959
+ if let Some ( t) = toml. target {
960
+ for ( triple, cfg) in t {
961
+ let mut target = Target :: from_triple ( & triple) ;
962
+
963
+ if let Some ( ref s) = cfg. llvm_config {
964
+ if config. download_rustc_commit . is_some ( )
965
+ && triple == * config. host_target . triple
966
+ {
967
+ panic ! (
968
+ "setting llvm_config for the host is incompatible with download-rustc"
969
+ ) ;
970
+ }
971
+ target. llvm_config = Some ( config. src . join ( s) ) ;
972
+ }
973
+ if let Some ( patches) = cfg. llvm_has_rust_patches {
974
+ assert ! (
975
+ config. submodules == Some ( false ) || cfg. llvm_config. is_some( ) ,
976
+ "use of `llvm-has-rust-patches` is restricted to cases where either submodules are disabled or llvm-config been provided"
977
+ ) ;
978
+ target. llvm_has_rust_patches = Some ( patches) ;
979
+ }
980
+ if let Some ( ref s) = cfg. llvm_filecheck {
981
+ target. llvm_filecheck = Some ( config. src . join ( s) ) ;
982
+ }
983
+ target. llvm_libunwind = cfg. llvm_libunwind . as_ref ( ) . map ( |v| {
984
+ v. parse ( ) . unwrap_or_else ( |_| {
985
+ panic ! ( "failed to parse target.{triple}.llvm-libunwind" )
986
+ } )
987
+ } ) ;
988
+ if let Some ( s) = cfg. no_std {
989
+ target. no_std = s;
990
+ }
991
+ target. cc = cfg. cc . map ( PathBuf :: from) ;
992
+ target. cxx = cfg. cxx . map ( PathBuf :: from) ;
993
+ target. ar = cfg. ar . map ( PathBuf :: from) ;
994
+ target. ranlib = cfg. ranlib . map ( PathBuf :: from) ;
995
+ target. linker = cfg. linker . map ( PathBuf :: from) ;
996
+ target. crt_static = cfg. crt_static ;
997
+ target. musl_root = cfg. musl_root . map ( PathBuf :: from) ;
998
+ target. musl_libdir = cfg. musl_libdir . map ( PathBuf :: from) ;
999
+ target. wasi_root = cfg. wasi_root . map ( PathBuf :: from) ;
1000
+ target. qemu_rootfs = cfg. qemu_rootfs . map ( PathBuf :: from) ;
1001
+ target. runner = cfg. runner ;
1002
+ target. sanitizers = cfg. sanitizers ;
1003
+ target. profiler = cfg. profiler ;
1004
+ target. rpath = cfg. rpath ;
1005
+ target. optimized_compiler_builtins = cfg. optimized_compiler_builtins ;
1006
+ target. jemalloc = cfg. jemalloc ;
1007
+ if let Some ( backends) = cfg. codegen_backends {
1008
+ target. codegen_backends =
1009
+ Some ( validate_codegen_backends ( backends, & format ! ( "target.{triple}" ) ) )
1010
+ }
1011
+
1012
+ target. split_debuginfo = cfg. split_debuginfo . as_ref ( ) . map ( |v| {
1013
+ v. parse ( ) . unwrap_or_else ( |_| {
1014
+ panic ! ( "invalid value for target.{triple}.split-debuginfo" )
1015
+ } )
1016
+ } ) ;
1017
+
1018
+ config. target_config . insert ( TargetSelection :: from_user ( & triple) , target) ;
1019
+ }
1020
+ }
960
1021
config. apply_rust_config ( toml. rust , flags_warnings) ;
961
1022
962
1023
config. reproducible_artifacts = flags_reproducible_artifact;
0 commit comments