@@ -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 > ,
@@ -617,6 +619,7 @@ pub(crate) struct TomlConfig {
617
619
build : Option < Build > ,
618
620
install : Option < Install > ,
619
621
llvm : Option < Llvm > ,
622
+ gcc : Option < Gcc > ,
620
623
rust : Option < Rust > ,
621
624
target : Option < HashMap < String , TomlTarget > > ,
622
625
dist : Option < Dist > ,
@@ -651,7 +654,7 @@ trait Merge {
651
654
impl Merge for TomlConfig {
652
655
fn merge (
653
656
& mut self ,
654
- TomlConfig { build, install, llvm, rust, dist, target, profile : _, change_id } : Self ,
657
+ TomlConfig { build, install, llvm, rust, dist, target, profile : _, change_id, gcc } : Self ,
655
658
replace : ReplaceOpt ,
656
659
) {
657
660
fn do_merge < T : Merge > ( x : & mut Option < T > , y : Option < T > , replace : ReplaceOpt ) {
@@ -669,6 +672,7 @@ impl Merge for TomlConfig {
669
672
do_merge ( & mut self . llvm , llvm, replace) ;
670
673
do_merge ( & mut self . rust , rust, replace) ;
671
674
do_merge ( & mut self . dist , dist, replace) ;
675
+ do_merge ( & mut self . gcc , gcc, replace) ;
672
676
assert ! ( target. is_none( ) , "merging target-specific config is not currently supported" ) ;
673
677
}
674
678
}
@@ -923,6 +927,13 @@ define_config! {
923
927
}
924
928
}
925
929
930
+ define_config ! {
931
+ /// TOML representation of how the GCC backend is configured.
932
+ struct Gcc {
933
+ download_gccjit: Option <bool > = "download-gccjit" ,
934
+ }
935
+ }
936
+
926
937
#[ derive( Clone , Debug , Deserialize ) ]
927
938
#[ serde( untagged) ]
928
939
pub enum StringOrBool {
@@ -1749,6 +1760,14 @@ impl Config {
1749
1760
config. omit_git_hash = omit_git_hash. unwrap_or ( default) ;
1750
1761
config. rust_info = GitInfo :: new ( config. omit_git_hash , & config. src ) ;
1751
1762
1763
+ if let Some ( gcc) = toml. gcc {
1764
+ let Gcc { download_gccjit } = gcc;
1765
+ config. gcc_download_gccjit = download_gccjit. unwrap_or ( false ) ;
1766
+ }
1767
+ if config. gcc_enabled ( config. build ) {
1768
+ config. maybe_download_gccjit ( ) ;
1769
+ }
1770
+
1752
1771
if let Some ( llvm) = toml. llvm {
1753
1772
let Llvm {
1754
1773
optimize : optimize_toml,
@@ -2315,6 +2334,18 @@ impl Config {
2315
2334
self . codegen_backends ( target) . contains ( & "llvm" . to_owned ( ) )
2316
2335
}
2317
2336
2337
+ pub fn gcc_enabled ( & self , target : TargetSelection ) -> bool {
2338
+ self . codegen_backends ( target) . contains ( & "gcc" . to_owned ( ) )
2339
+ }
2340
+
2341
+ pub fn libgccjit_folder ( & self , gcc_sha : & str ) -> PathBuf {
2342
+ assert ! ( self . gcc_download_gccjit) ;
2343
+ let cache_prefix = format ! ( "libgccjit-{gcc_sha}" ) ;
2344
+ let cache_dst =
2345
+ self . bootstrap_cache_path . as_ref ( ) . cloned ( ) . unwrap_or_else ( || self . out . join ( "cache" ) ) ;
2346
+ cache_dst. join ( cache_prefix)
2347
+ }
2348
+
2318
2349
pub fn llvm_libunwind ( & self , target : TargetSelection ) -> LlvmLibunwind {
2319
2350
self . target_config
2320
2351
. get ( & target)
0 commit comments