@@ -1211,13 +1211,19 @@ impl Config {
1211
1211
}
1212
1212
}
1213
1213
1214
+ pub ( crate ) fn get_builder_toml ( & self , build_name : & str ) -> Result < TomlConfig , toml:: de:: Error > {
1215
+ let builder_config_path =
1216
+ self . out . join ( self . build . triple ) . join ( build_name) . join ( BUILDER_CONFIG_FILENAME ) ;
1217
+ Self :: get_toml ( & builder_config_path)
1218
+ }
1219
+
1214
1220
#[ cfg( test) ]
1215
- fn get_toml ( _: & Path ) -> Result < TomlConfig , toml:: de:: Error > {
1221
+ pub ( crate ) fn get_toml ( _: & Path ) -> Result < TomlConfig , toml:: de:: Error > {
1216
1222
Ok ( TomlConfig :: default ( ) )
1217
1223
}
1218
1224
1219
1225
#[ cfg( not( test) ) ]
1220
- fn get_toml ( file : & Path ) -> Result < TomlConfig , toml:: de:: Error > {
1226
+ pub ( crate ) fn get_toml ( file : & Path ) -> Result < TomlConfig , toml:: de:: Error > {
1221
1227
let contents =
1222
1228
t ! ( fs:: read_to_string( file) , format!( "config file {} not found" , file. display( ) ) ) ;
1223
1229
// Deserialize to Value and then TomlConfig to prevent the Deserialize impl of
@@ -2840,6 +2846,106 @@ impl Config {
2840
2846
}
2841
2847
}
2842
2848
2849
+ /// Compares the current `Llvm` options against those in the CI LLVM builder and detects any incompatible options.
2850
+ /// It does this by destructuring the `Llvm` instance to make sure every `Llvm` field is covered and not missing.
2851
+ pub ( crate ) fn check_incompatible_options_for_ci_llvm (
2852
+ current_config_toml : TomlConfig ,
2853
+ ci_config_toml : TomlConfig ,
2854
+ ) -> Result < ( ) , String > {
2855
+ macro_rules! err {
2856
+ ( $current: expr, $expected: expr) => {
2857
+ if let Some ( current) = & $current {
2858
+ if Some ( current) != $expected. as_ref( ) {
2859
+ return Err ( format!(
2860
+ "ERROR: Setting `llvm.{}` is incompatible with `llvm.download-ci-llvm`. \
2861
+ Current value: {:?}, Expected value(s): {}{:?}",
2862
+ stringify!( $expected) . replace( "_" , "-" ) ,
2863
+ $current,
2864
+ if $expected. is_some( ) { "None/" } else { "" } ,
2865
+ $expected,
2866
+ ) ) ;
2867
+ } ;
2868
+ } ;
2869
+ } ;
2870
+ }
2871
+
2872
+ macro_rules! warn {
2873
+ ( $current: expr, $expected: expr) => {
2874
+ if let Some ( current) = & $current {
2875
+ if Some ( current) != $expected. as_ref( ) {
2876
+ println!(
2877
+ "WARNING: `llvm.{}` has no effect with `llvm.download-ci-llvm`. \
2878
+ Current value: {:?}, Expected value(s): {}{:?}",
2879
+ stringify!( $expected) . replace( "_" , "-" ) ,
2880
+ $current,
2881
+ if $expected. is_some( ) { "None/" } else { "" } ,
2882
+ $expected,
2883
+ ) ;
2884
+ } ;
2885
+ } ;
2886
+ } ;
2887
+ }
2888
+
2889
+ let ( Some ( current_llvm_config) , Some ( ci_llvm_config) ) =
2890
+ ( current_config_toml. llvm , ci_config_toml. llvm )
2891
+ else {
2892
+ return Ok ( ( ) ) ;
2893
+ } ;
2894
+
2895
+ let Llvm {
2896
+ optimize,
2897
+ thin_lto,
2898
+ release_debuginfo,
2899
+ assertions : _,
2900
+ tests : _,
2901
+ plugins,
2902
+ ccache : _,
2903
+ static_libstdcpp : _,
2904
+ libzstd,
2905
+ ninja : _,
2906
+ targets,
2907
+ experimental_targets,
2908
+ link_jobs : _,
2909
+ link_shared : _,
2910
+ version_suffix,
2911
+ clang_cl,
2912
+ cflags,
2913
+ cxxflags,
2914
+ ldflags,
2915
+ use_libcxx,
2916
+ use_linker,
2917
+ allow_old_toolchain,
2918
+ polly,
2919
+ clang,
2920
+ enable_warnings,
2921
+ download_ci_llvm : _,
2922
+ build_config,
2923
+ } = ci_llvm_config;
2924
+
2925
+ err ! ( current_llvm_config. optimize, optimize) ;
2926
+ err ! ( current_llvm_config. thin_lto, thin_lto) ;
2927
+ err ! ( current_llvm_config. release_debuginfo, release_debuginfo) ;
2928
+ err ! ( current_llvm_config. libzstd, libzstd) ;
2929
+ err ! ( current_llvm_config. targets, targets) ;
2930
+ err ! ( current_llvm_config. experimental_targets, experimental_targets) ;
2931
+ err ! ( current_llvm_config. clang_cl, clang_cl) ;
2932
+ err ! ( current_llvm_config. version_suffix, version_suffix) ;
2933
+ err ! ( current_llvm_config. cflags, cflags) ;
2934
+ err ! ( current_llvm_config. cxxflags, cxxflags) ;
2935
+ err ! ( current_llvm_config. ldflags, ldflags) ;
2936
+ err ! ( current_llvm_config. use_libcxx, use_libcxx) ;
2937
+ err ! ( current_llvm_config. use_linker, use_linker) ;
2938
+ err ! ( current_llvm_config. allow_old_toolchain, allow_old_toolchain) ;
2939
+ err ! ( current_llvm_config. polly, polly) ;
2940
+ err ! ( current_llvm_config. clang, clang) ;
2941
+ err ! ( current_llvm_config. build_config, build_config) ;
2942
+ err ! ( current_llvm_config. plugins, plugins) ;
2943
+
2944
+ warn ! ( current_llvm_config. enable_warnings, enable_warnings) ;
2945
+
2946
+ Ok ( ( ) )
2947
+ }
2948
+
2843
2949
/// Compares the current Rust options against those in the CI rustc builder and detects any incompatible options.
2844
2950
/// It does this by destructuring the `Rust` instance to make sure every `Rust` field is covered and not missing.
2845
2951
fn check_incompatible_options_for_ci_rustc (
0 commit comments