File tree 1 file changed +10
-2
lines changed
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -325,6 +325,14 @@ struct TomlTarget {
325
325
}
326
326
327
327
impl Config {
328
+ fn path_from_python ( var_key : & str ) -> PathBuf {
329
+ match env:: var_os ( var_key) {
330
+ // Do not trust paths from Python and normalize them slightly (#49785).
331
+ Some ( var_val) => Path :: new ( & var_val) . components ( ) . collect ( ) ,
332
+ _ => panic ! ( "expected '{}' to be set" , var_key) ,
333
+ }
334
+ }
335
+
328
336
pub fn default_opts ( ) -> Config {
329
337
let mut config = Config :: default ( ) ;
330
338
config. llvm_enabled = true ;
@@ -348,9 +356,9 @@ impl Config {
348
356
config. deny_warnings = true ;
349
357
350
358
// set by bootstrap.py
351
- config. src = env:: var_os ( "SRC" ) . map ( PathBuf :: from) . expect ( "'SRC' to be set" ) ;
352
359
config. build = INTERNER . intern_str ( & env:: var ( "BUILD" ) . expect ( "'BUILD' to be set" ) ) ;
353
- config. out = env:: var_os ( "BUILD_DIR" ) . map ( PathBuf :: from) . expect ( "'BUILD_DIR' set" ) ;
360
+ config. src = Config :: path_from_python ( "SRC" ) ;
361
+ config. out = Config :: path_from_python ( "BUILD_DIR" ) ;
354
362
355
363
let stage0_root = config. out . join ( & config. build ) . join ( "stage0/bin" ) ;
356
364
config. initial_rustc = stage0_root. join ( exe ( "rustc" , & config. build ) ) ;
You can’t perform that action at this time.
0 commit comments