@@ -128,6 +128,7 @@ pub struct ConfigInfo {
128
128
// just to set the `gcc_path` field to display it.
129
129
pub no_download : bool ,
130
130
pub no_default_features : bool ,
131
+ pub backend : Option < String > ,
131
132
}
132
133
133
134
impl ConfigInfo {
@@ -178,6 +179,14 @@ impl ConfigInfo {
178
179
return Err ( "Expected a value after `--cg_gcc-path`, found nothing" . to_string ( ) )
179
180
}
180
181
} ,
182
+ "--use-backend" => match args. next ( ) {
183
+ Some ( backend) if !backend. is_empty ( ) => self . backend = Some ( backend) ,
184
+ _ => {
185
+ return Err (
186
+ "Expected an argument after `--use-backend`, found nothing" . into ( )
187
+ )
188
+ }
189
+ } ,
181
190
"--no-default-features" => self . no_default_features = true ,
182
191
_ => return Ok ( false ) ,
183
192
}
@@ -377,39 +386,25 @@ impl ConfigInfo {
377
386
"debug"
378
387
} ;
379
388
380
- let has_builtin_backend = env
381
- . get ( "BUILTIN_BACKEND" )
382
- . map ( |backend| !backend. is_empty ( ) )
383
- . unwrap_or ( false ) ;
384
-
385
389
let mut rustflags = Vec :: new ( ) ;
386
- if has_builtin_backend {
387
- // It means we're building inside the rustc testsuite, so some options need to be handled
388
- // a bit differently.
389
- self . cg_backend_path = "gcc" . to_string ( ) ;
390
-
391
- match env. get ( "RUSTC_SYSROOT" ) {
392
- Some ( rustc_sysroot) if !rustc_sysroot. is_empty ( ) => {
393
- rustflags. extend_from_slice ( & [ "--sysroot" . to_string ( ) , rustc_sysroot. clone ( ) ] ) ;
394
- }
395
- _ => { }
396
- }
397
- // This should not be needed, but is necessary for the CI in the rust repository.
398
- // FIXME: Remove when the rust CI switches to the master version of libgccjit.
399
- rustflags. push ( "-Cpanic=abort" . to_string ( ) ) ;
390
+ self . cg_backend_path = current_dir
391
+ . join ( "target" )
392
+ . join ( channel)
393
+ . join ( & format ! ( "librustc_codegen_gcc.{}" , self . dylib_ext) )
394
+ . display ( )
395
+ . to_string ( ) ;
396
+ self . sysroot_path = current_dir
397
+ . join ( "build_sysroot/sysroot" )
398
+ . display ( )
399
+ . to_string ( ) ;
400
+ if let Some ( backend) = & self . backend {
401
+ rustflags. push ( format ! ( "-Zcodegen-backend={}" , backend) ) ;
400
402
} else {
401
- self . cg_backend_path = current_dir
402
- . join ( "target" )
403
- . join ( channel)
404
- . join ( & format ! ( "librustc_codegen_gcc.{}" , self . dylib_ext) )
405
- . display ( )
406
- . to_string ( ) ;
407
- self . sysroot_path = current_dir
408
- . join ( "build_sysroot/sysroot" )
409
- . display ( )
410
- . to_string ( ) ;
411
- rustflags. extend_from_slice ( & [ "--sysroot" . to_string ( ) , self . sysroot_path . clone ( ) ] ) ;
412
- } ;
403
+ rustflags. extend_from_slice ( & [
404
+ "--sysroot" . to_string ( ) , self . sysroot_path . clone ( ) ,
405
+ format ! ( "-Zcodegen-backend={}" , self . cg_backend_path) ,
406
+ ] ) ;
407
+ }
413
408
414
409
// This environment variable is useful in case we want to change options of rustc commands.
415
410
if let Some ( cg_rustflags) = env. get ( "CG_RUSTFLAGS" ) {
@@ -427,10 +422,7 @@ impl ConfigInfo {
427
422
rustflags. push ( "-Csymbol-mangling-version=v0" . to_string ( ) ) ;
428
423
}
429
424
430
- rustflags. extend_from_slice ( & [
431
- "-Cdebuginfo=2" . to_string ( ) ,
432
- format ! ( "-Zcodegen-backend={}" , self . cg_backend_path) ,
433
- ] ) ;
425
+ rustflags. push ( "-Cdebuginfo=2" . to_string ( ) ) ;
434
426
435
427
// Since we don't support ThinLTO, disable LTO completely when not trying to do LTO.
436
428
// TODO(antoyo): remove when we can handle ThinLTO.
@@ -504,7 +496,8 @@ impl ConfigInfo {
504
496
--config-file : Location of the config file to be used
505
497
--cg_gcc-path : Location of the rustc_codegen_gcc root folder (used
506
498
when ran from another directory)
507
- --no-default-features : Add `--no-default-features` flag to cargo commands"
499
+ --no-default-features : Add `--no-default-features` flag to cargo commands
500
+ --use-backend : Useful only for rustc testsuite"
508
501
) ;
509
502
}
510
503
}
0 commit comments