]> git.lizzy.rs Git - rust.git/commitdiff
make codegen-backends directory name configurable
authorMarc-Antoine Perennou <Marc-Antoine@Perennou.com>
Fri, 2 Mar 2018 08:19:50 +0000 (09:19 +0100)
committerMarc-Antoine Perennou <Marc-Antoine@Perennou.com>
Fri, 2 Mar 2018 12:51:02 +0000 (13:51 +0100)
This allows to parallel-install several versions of rust system-wide
Fixes #48263

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
config.toml.example
src/bootstrap/builder.rs
src/bootstrap/compile.rs
src/bootstrap/config.rs
src/bootstrap/dist.rs
src/librustc_driver/lib.rs

index 8d1fa3eec5cf2df5d484cd51539293a5914a5c93..3dfd25aade1e4146dd5747ab2298e1a1ff97dbee 100644 (file)
 # bootstrap)
 #codegen-backends = ["llvm"]
 
+# This is the name of the directory in which codegen backends will get installed
+#codegen-backends-dir = "codegen-backends"
+
 # Flag indicating whether `libstd` calls an imported function to handle basic IO
 # when targeting WebAssembly. Enable this to debug tests for the `wasm32-unknown-unknown`
 # target, as without this option the test output will not be captured.
index b5946b44e05ef6316ab5881d7250f1e923548b61..2eec6c69739b777f3e8bbe758734149ddaf3537f 100644 (file)
@@ -462,7 +462,7 @@ fn run(self, builder: &Builder) -> Interned<PathBuf> {
 
     pub fn sysroot_codegen_backends(&self, compiler: Compiler) -> PathBuf {
         self.sysroot_libdir(compiler, compiler.host)
-            .with_file_name("codegen-backends")
+            .with_file_name(self.build.config.rust_codegen_backends_dir.clone())
     }
 
     /// Returns the compiler's libdir where it stores the dynamic libraries that
index 2c9f0ddb6c33d197f8bd05df8ef36359a4abb5f4..f8e0a1f5a923c77bd06234dd24d90c164b8be571 100644 (file)
@@ -514,7 +514,8 @@ fn rustc_cargo_env(build: &Build, cargo: &mut Command) {
     cargo.env("CFG_RELEASE", build.rust_release())
          .env("CFG_RELEASE_CHANNEL", &build.config.channel)
          .env("CFG_VERSION", build.rust_version())
-         .env("CFG_PREFIX", build.config.prefix.clone().unwrap_or_default());
+         .env("CFG_PREFIX", build.config.prefix.clone().unwrap_or_default())
+         .env("CFG_CODEGEN_BACKENDS_DIR", &build.config.rust_codegen_backends_dir);
 
     let libdir_relative = build.config.libdir_relative().unwrap_or(Path::new("lib"));
     cargo.env("CFG_LIBDIR_RELATIVE", libdir_relative);
index 6bc20181a0330a5a51eef0ae83defe310cb87e39..361fc704bc07b68f90b6396fa5bdc312f6cb1588 100644 (file)
@@ -96,6 +96,7 @@ pub struct Config {
     pub rust_debuginfo_tests: bool,
     pub rust_dist_src: bool,
     pub rust_codegen_backends: Vec<Interned<String>>,
+    pub rust_codegen_backends_dir: String,
 
     pub build: Interned<String>,
     pub hosts: Vec<Interned<String>>,
@@ -289,6 +290,7 @@ struct Rust {
     test_miri: Option<bool>,
     save_toolstates: Option<String>,
     codegen_backends: Option<Vec<String>>,
+    codegen_backends_dir: Option<String>,
     wasm_syscall: Option<bool>,
 }
 
@@ -330,6 +332,7 @@ pub fn parse(args: &[String]) -> Config {
         config.rust_dist_src = true;
         config.test_miri = false;
         config.rust_codegen_backends = vec![INTERNER.intern_str("llvm")];
+        config.rust_codegen_backends_dir = "codegen-backends".to_owned();
 
         config.rustc_error_format = flags.rustc_error_format;
         config.on_fail = flags.on_fail;
@@ -488,6 +491,8 @@ pub fn parse(args: &[String]) -> Config {
                     .collect();
             }
 
+            set(&mut config.rust_codegen_backends_dir, rust.codegen_backends_dir.clone());
+
             match rust.codegen_units {
                 Some(0) => config.rust_codegen_units = Some(num_cpus::get() as u32),
                 Some(n) => config.rust_codegen_units = Some(n),
index e7aed7eb4fead3de97f477fc3339542e0a9f7d59..05630b8431fb518997230e78fda48be1a968f4e4 100644 (file)
@@ -590,7 +590,8 @@ fn run(self, builder: &Builder) -> PathBuf {
         let mut src = builder.sysroot_libdir(compiler, target).to_path_buf();
         src.pop(); // Remove the trailing /lib folder from the sysroot_libdir
         cp_filtered(&src, &dst, &|path| {
-            path.file_name().and_then(|s| s.to_str()) != Some("codegen-backends")
+            path.file_name().and_then(|s| s.to_str()) !=
+                Some(build.config.rust_codegen_backends_dir.as_str())
         });
 
         let mut cmd = rust_installer(builder);
index 22c26b0643050546ca85a90e255c0254e25537b1..0f7a04e391bfb7d4b7346b56a9207321cdadd2c8 100644 (file)
@@ -303,7 +303,9 @@ fn get_trans_sysroot(backend_name: &str) -> fn() -> Box<TransCrate> {
     let sysroot = sysroot_candidates.iter()
         .map(|sysroot| {
             let libdir = filesearch::relative_target_lib_path(&sysroot, &target);
-            sysroot.join(libdir).with_file_name("codegen-backends")
+            sysroot.join(libdir)
+                .with_file_name(option_env!("CFG_CODEGEN_BACKENDS_DIR")
+                                .unwrap_or("codegen-backends"))
         })
         .filter(|f| {
             info!("codegen backend candidate: {}", f.display());