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