@@ -39,6 +39,7 @@ use crate::core::config::toml::build::{Build, Tool};
3939use crate :: core:: config:: toml:: change_id:: ChangeId ;
4040use crate :: core:: config:: toml:: dist:: Dist ;
4141use crate :: core:: config:: toml:: install:: Install ;
42+ use crate :: core:: config:: toml:: llvm:: Llvm ;
4243use crate :: core:: config:: toml:: rust:: {
4344 LldMode , RustOptimize , check_incompatible_options_for_ci_rustc, validate_codegen_backends,
4445} ;
@@ -1049,7 +1050,126 @@ impl Config {
10491050 config. channel = channel;
10501051 }
10511052
1052- config. apply_llvm_config ( toml. llvm ) ;
1053+ let mut llvm_tests = None ;
1054+ let mut llvm_enzyme = None ;
1055+ let mut llvm_offload = None ;
1056+ let mut llvm_plugins = None ;
1057+
1058+ if let Some ( llvm) = toml. llvm {
1059+ let Llvm {
1060+ optimize : optimize_toml,
1061+ thin_lto,
1062+ release_debuginfo,
1063+ assertions : _,
1064+ tests,
1065+ enzyme,
1066+ plugins,
1067+ static_libstdcpp,
1068+ libzstd,
1069+ ninja,
1070+ targets,
1071+ experimental_targets,
1072+ link_jobs,
1073+ link_shared,
1074+ version_suffix,
1075+ clang_cl,
1076+ cflags,
1077+ cxxflags,
1078+ ldflags,
1079+ use_libcxx,
1080+ use_linker,
1081+ allow_old_toolchain,
1082+ offload,
1083+ polly,
1084+ clang,
1085+ enable_warnings,
1086+ download_ci_llvm,
1087+ build_config,
1088+ } = llvm;
1089+
1090+ set ( & mut config. ninja_in_file , ninja) ;
1091+ llvm_tests = tests;
1092+ llvm_enzyme = enzyme;
1093+ llvm_offload = offload;
1094+ llvm_plugins = plugins;
1095+ set ( & mut config. llvm_optimize , optimize_toml) ;
1096+ set ( & mut config. llvm_thin_lto , thin_lto) ;
1097+ set ( & mut config. llvm_release_debuginfo , release_debuginfo) ;
1098+ set ( & mut config. llvm_static_stdcpp , static_libstdcpp) ;
1099+ set ( & mut config. llvm_libzstd , libzstd) ;
1100+ if let Some ( v) = link_shared {
1101+ config. llvm_link_shared . set ( Some ( v) ) ;
1102+ }
1103+ config. llvm_targets . clone_from ( & targets) ;
1104+ config. llvm_experimental_targets . clone_from ( & experimental_targets) ;
1105+ config. llvm_link_jobs = link_jobs;
1106+ config. llvm_version_suffix . clone_from ( & version_suffix) ;
1107+ config. llvm_clang_cl . clone_from ( & clang_cl) ;
1108+
1109+ config. llvm_cflags . clone_from ( & cflags) ;
1110+ config. llvm_cxxflags . clone_from ( & cxxflags) ;
1111+ config. llvm_ldflags . clone_from ( & ldflags) ;
1112+ set ( & mut config. llvm_use_libcxx , use_libcxx) ;
1113+ config. llvm_use_linker . clone_from ( & use_linker) ;
1114+ config. llvm_allow_old_toolchain = allow_old_toolchain. unwrap_or ( false ) ;
1115+ config. llvm_offload = offload. unwrap_or ( false ) ;
1116+ config. llvm_polly = polly. unwrap_or ( false ) ;
1117+ config. llvm_clang = clang. unwrap_or ( false ) ;
1118+ config. llvm_enable_warnings = enable_warnings. unwrap_or ( false ) ;
1119+ config. llvm_build_config = build_config. clone ( ) . unwrap_or ( Default :: default ( ) ) ;
1120+
1121+ config. llvm_from_ci =
1122+ config. parse_download_ci_llvm ( download_ci_llvm, config. llvm_assertions ) ;
1123+
1124+ if config. llvm_from_ci {
1125+ let warn = |option : & str | {
1126+ println ! (
1127+ "WARNING: `{option}` will only be used on `compiler/rustc_llvm` build, not for the LLVM build."
1128+ ) ;
1129+ println ! (
1130+ "HELP: To use `{option}` for LLVM builds, set `download-ci-llvm` option to false."
1131+ ) ;
1132+ } ;
1133+
1134+ if static_libstdcpp. is_some ( ) {
1135+ warn ( "static-libstdcpp" ) ;
1136+ }
1137+
1138+ if link_shared. is_some ( ) {
1139+ warn ( "link-shared" ) ;
1140+ }
1141+
1142+ // FIXME(#129153): instead of all the ad-hoc `download-ci-llvm` checks that follow,
1143+ // use the `builder-config` present in tarballs since #128822 to compare the local
1144+ // config to the ones used to build the LLVM artifacts on CI, and only notify users
1145+ // if they've chosen a different value.
1146+
1147+ if libzstd. is_some ( ) {
1148+ println ! (
1149+ "WARNING: when using `download-ci-llvm`, the local `llvm.libzstd` option, \
1150+ like almost all `llvm.*` options, will be ignored and set by the LLVM CI \
1151+ artifacts builder config."
1152+ ) ;
1153+ println ! (
1154+ "HELP: To use `llvm.libzstd` for LLVM/LLD builds, set `download-ci-llvm` option to false."
1155+ ) ;
1156+ }
1157+ }
1158+
1159+ if !config. llvm_from_ci && config. llvm_thin_lto && link_shared. is_none ( ) {
1160+ // If we're building with ThinLTO on, by default we want to link
1161+ // to LLVM shared, to avoid re-doing ThinLTO (which happens in
1162+ // the link step) with each stage.
1163+ config. llvm_link_shared . set ( Some ( true ) ) ;
1164+ }
1165+ } else {
1166+ config. llvm_from_ci = config. parse_download_ci_llvm ( None , false ) ;
1167+ }
1168+
1169+ config. llvm_tests = llvm_tests. unwrap_or ( false ) ;
1170+ config. llvm_enzyme = llvm_enzyme. unwrap_or ( false ) ;
1171+ config. llvm_offload = llvm_offload. unwrap_or ( false ) ;
1172+ config. llvm_plugins = llvm_plugins. unwrap_or ( false ) ;
10531173
10541174 if let Some ( gcc) = toml. gcc {
10551175 config. gcc_ci_mode = match gcc. download_ci_gcc {
0 commit comments