Skip to content

Commit 0d2bb35

Browse files
committed
Destructure TomlConfig and add missing default_linker config
1 parent 47c2813 commit 0d2bb35

File tree

1 file changed

+53
-25
lines changed

1 file changed

+53
-25
lines changed

src/bootstrap/src/core/config/config.rs

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use crate::core::config::toml::rust::{
4444
BootstrapOverrideLld, Rust, RustOptimize, check_incompatible_options_for_ci_rustc,
4545
default_lld_opt_in_targets, parse_codegen_backends,
4646
};
47-
use crate::core::config::toml::target::Target;
47+
use crate::core::config::toml::target::{Target, TomlTarget};
4848
use crate::core::config::{
4949
CompilerBuiltins, DebuginfoLevel, DryRun, GccCiMode, LlvmLibunwind, Merge, ReplaceOpt,
5050
RustcLto, SplitDebuginfo, StringOrBool, threads_from_config,
@@ -831,56 +831,84 @@ impl Config {
831831

832832
if let Some(t) = toml.target {
833833
for (triple, cfg) in t {
834+
let TomlTarget {
835+
cc: target_cc,
836+
cxx: target_cxx,
837+
ar: target_ar,
838+
ranlib: target_ranlib,
839+
default_linker: target_default_linker,
840+
linker: target_linker,
841+
split_debuginfo: target_split_debuginfo,
842+
llvm_config: target_llvm_config,
843+
llvm_has_rust_patches: target_llvm_has_rust_patches,
844+
llvm_filecheck: target_llvm_filecheck,
845+
llvm_libunwind: target_llvm_libunwind,
846+
sanitizers: target_sanitizers,
847+
profiler: target_profiler,
848+
rpath: target_rpath,
849+
crt_static: target_crt_static,
850+
musl_root: target_musl_root,
851+
musl_libdir: target_musl_libdir,
852+
wasi_root: target_wasi_root,
853+
qemu_rootfs: target_qemu_rootfs,
854+
no_std: target_no_std,
855+
codegen_backends: target_codegen_backends,
856+
runner: target_runner,
857+
optimized_compiler_builtins: target_optimized_compiler_builtins,
858+
jemalloc: target_jemalloc,
859+
} = cfg;
860+
834861
let mut target = Target::from_triple(&triple);
835862

836-
if let Some(ref s) = cfg.llvm_config {
863+
if let Some(ref s) = target_llvm_config {
837864
if download_rustc_commit.is_some() && triple == *host_target.triple {
838865
panic!(
839866
"setting llvm_config for the host is incompatible with download-rustc"
840867
);
841868
}
842869
target.llvm_config = Some(src.join(s));
843870
}
844-
if let Some(patches) = cfg.llvm_has_rust_patches {
871+
if let Some(patches) = target_llvm_has_rust_patches {
845872
assert!(
846-
build_submodules == Some(false) || cfg.llvm_config.is_some(),
873+
build_submodules == Some(false) || target_llvm_config.is_some(),
847874
"use of `llvm-has-rust-patches` is restricted to cases where either submodules are disabled or llvm-config been provided"
848875
);
849876
target.llvm_has_rust_patches = Some(patches);
850877
}
851-
if let Some(ref s) = cfg.llvm_filecheck {
878+
if let Some(ref s) = target_llvm_filecheck {
852879
target.llvm_filecheck = Some(src.join(s));
853880
}
854-
target.llvm_libunwind = cfg.llvm_libunwind.as_ref().map(|v| {
881+
target.llvm_libunwind = target_llvm_libunwind.as_ref().map(|v| {
855882
v.parse().unwrap_or_else(|_| {
856883
panic!("failed to parse target.{triple}.llvm-libunwind")
857884
})
858885
});
859-
if let Some(s) = cfg.no_std {
886+
if let Some(s) = target_no_std {
860887
target.no_std = s;
861888
}
862-
target.cc = cfg.cc.map(PathBuf::from);
863-
target.cxx = cfg.cxx.map(PathBuf::from);
864-
target.ar = cfg.ar.map(PathBuf::from);
865-
target.ranlib = cfg.ranlib.map(PathBuf::from);
866-
target.linker = cfg.linker.map(PathBuf::from);
867-
target.crt_static = cfg.crt_static;
868-
target.musl_root = cfg.musl_root.map(PathBuf::from);
869-
target.musl_libdir = cfg.musl_libdir.map(PathBuf::from);
870-
target.wasi_root = cfg.wasi_root.map(PathBuf::from);
871-
target.qemu_rootfs = cfg.qemu_rootfs.map(PathBuf::from);
872-
target.runner = cfg.runner;
873-
target.sanitizers = cfg.sanitizers;
874-
target.profiler = cfg.profiler;
875-
target.rpath = cfg.rpath;
876-
target.optimized_compiler_builtins = cfg.optimized_compiler_builtins;
877-
target.jemalloc = cfg.jemalloc;
878-
if let Some(backends) = cfg.codegen_backends {
889+
target.cc = target_cc.map(PathBuf::from);
890+
target.cxx = target_cxx.map(PathBuf::from);
891+
target.ar = target_ar.map(PathBuf::from);
892+
target.ranlib = target_ranlib.map(PathBuf::from);
893+
target.linker = target_linker.map(PathBuf::from);
894+
target.crt_static = target_crt_static;
895+
target.default_linker = target_default_linker;
896+
target.musl_root = target_musl_root.map(PathBuf::from);
897+
target.musl_libdir = target_musl_libdir.map(PathBuf::from);
898+
target.wasi_root = target_wasi_root.map(PathBuf::from);
899+
target.qemu_rootfs = target_qemu_rootfs.map(PathBuf::from);
900+
target.runner = target_runner;
901+
target.sanitizers = target_sanitizers;
902+
target.profiler = target_profiler;
903+
target.rpath = target_rpath;
904+
target.optimized_compiler_builtins = target_optimized_compiler_builtins;
905+
target.jemalloc = target_jemalloc;
906+
if let Some(backends) = target_codegen_backends {
879907
target.codegen_backends =
880908
Some(parse_codegen_backends(backends, &format!("target.{triple}")))
881909
}
882910

883-
target.split_debuginfo = cfg.split_debuginfo.as_ref().map(|v| {
911+
target.split_debuginfo = target_split_debuginfo.as_ref().map(|v| {
884912
v.parse().unwrap_or_else(|_| {
885913
panic!("invalid value for target.{triple}.split-debuginfo")
886914
})

0 commit comments

Comments
 (0)