@@ -250,6 +250,8 @@ pub struct Config {
250
250
pub llvm_ldflags : Option < String > ,
251
251
pub llvm_use_libcxx : bool ,
252
252
253
+ pub gcc_download_gccjit : bool ,
254
+
253
255
// rust codegen options
254
256
pub rust_optimize : RustOptimize ,
255
257
pub rust_codegen_units : Option < u32 > ,
@@ -592,6 +594,7 @@ pub(crate) struct TomlConfig {
592
594
build : Option < Build > ,
593
595
install : Option < Install > ,
594
596
llvm : Option < Llvm > ,
597
+ gcc : Option < Gcc > ,
595
598
rust : Option < Rust > ,
596
599
target : Option < HashMap < String , TomlTarget > > ,
597
600
dist : Option < Dist > ,
@@ -626,7 +629,7 @@ trait Merge {
626
629
impl Merge for TomlConfig {
627
630
fn merge (
628
631
& mut self ,
629
- TomlConfig { build, install, llvm, rust, dist, target, profile : _, change_id } : Self ,
632
+ TomlConfig { build, install, llvm, rust, dist, target, profile : _, change_id, gcc } : Self ,
630
633
replace : ReplaceOpt ,
631
634
) {
632
635
fn do_merge < T : Merge > ( x : & mut Option < T > , y : Option < T > , replace : ReplaceOpt ) {
@@ -644,6 +647,7 @@ impl Merge for TomlConfig {
644
647
do_merge ( & mut self . llvm , llvm, replace) ;
645
648
do_merge ( & mut self . rust , rust, replace) ;
646
649
do_merge ( & mut self . dist , dist, replace) ;
650
+ do_merge ( & mut self . gcc , gcc, replace) ;
647
651
assert ! ( target. is_none( ) , "merging target-specific config is not currently supported" ) ;
648
652
}
649
653
}
@@ -899,6 +903,13 @@ define_config! {
899
903
}
900
904
}
901
905
906
+ define_config ! {
907
+ /// TOML representation of how the GCC backend is configured.
908
+ struct Gcc {
909
+ download_gccjit: Option <bool > = "download-gccjit" ,
910
+ }
911
+ }
912
+
902
913
#[ derive( Clone , Debug , Deserialize ) ]
903
914
#[ serde( untagged) ]
904
915
pub enum StringOrBool {
@@ -1724,6 +1735,14 @@ impl Config {
1724
1735
ci_channel. clone_into ( & mut config. channel ) ;
1725
1736
}
1726
1737
1738
+ if let Some ( gcc) = toml. gcc {
1739
+ let Gcc { download_gccjit } = gcc;
1740
+ config. gcc_download_gccjit = download_gccjit. unwrap_or ( false ) ;
1741
+ }
1742
+ if config. gcc_enabled ( config. build ) {
1743
+ config. maybe_download_gccjit ( ) ;
1744
+ }
1745
+
1727
1746
if let Some ( llvm) = toml. llvm {
1728
1747
let Llvm {
1729
1748
optimize : optimize_toml,
@@ -2329,6 +2348,18 @@ impl Config {
2329
2348
self . codegen_backends ( target) . contains ( & "llvm" . to_owned ( ) )
2330
2349
}
2331
2350
2351
+ pub fn gcc_enabled ( & self , target : TargetSelection ) -> bool {
2352
+ self . codegen_backends ( target) . contains ( & "gcc" . to_owned ( ) )
2353
+ }
2354
+
2355
+ pub fn libgccjit_folder ( & self , gcc_sha : & str ) -> PathBuf {
2356
+ assert ! ( self . gcc_download_gccjit) ;
2357
+ let cache_prefix = format ! ( "libgccjit-{gcc_sha}" ) ;
2358
+ let cache_dst =
2359
+ self . bootstrap_cache_path . as_ref ( ) . cloned ( ) . unwrap_or_else ( || self . out . join ( "cache" ) ) ;
2360
+ cache_dst. join ( cache_prefix)
2361
+ }
2362
+
2332
2363
pub fn llvm_libunwind ( & self , target : TargetSelection ) -> LlvmLibunwind {
2333
2364
self . target_config
2334
2365
. get ( & target)
0 commit comments