Skip to content

Commit 1bba9cf

Browse files
committed
rustbuild: include channel in sanitizers installed name
Allows parallel install of different rust channels Signed-off-by: Marc-Antoine Perennou <[email protected]>
1 parent dc4242d commit 1bba9cf

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

src/bootstrap/native.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ impl Step for Sanitizers {
571571
}
572572

573573
let out_dir = builder.native_dir(self.target).join("sanitizers");
574-
let runtimes = supported_sanitizers(&out_dir, self.target);
574+
let runtimes = supported_sanitizers(&out_dir, self.target, &builder.config.channel);
575575
if runtimes.is_empty() {
576576
return runtimes;
577577
}
@@ -635,7 +635,11 @@ pub struct SanitizerRuntime {
635635
}
636636

637637
/// Returns sanitizers available on a given target.
638-
fn supported_sanitizers(out_dir: &Path, target: Interned<String>) -> Vec<SanitizerRuntime> {
638+
fn supported_sanitizers(
639+
out_dir: &Path,
640+
target: Interned<String>,
641+
channel: &str,
642+
) -> Vec<SanitizerRuntime> {
639643
let mut result = Vec::new();
640644
match &*target {
641645
"x86_64-apple-darwin" => {
@@ -644,7 +648,7 @@ fn supported_sanitizers(out_dir: &Path, target: Interned<String>) -> Vec<Sanitiz
644648
cmake_target: format!("clang_rt.{}_osx_dynamic", s),
645649
path: out_dir
646650
.join(&format!("build/lib/darwin/libclang_rt.{}_osx_dynamic.dylib", s)),
647-
name: format!("librustc_rt.{}.dylib", s),
651+
name: format!("librustc-{}_rt.{}.dylib", channel, s),
648652
});
649653
}
650654
}
@@ -653,7 +657,7 @@ fn supported_sanitizers(out_dir: &Path, target: Interned<String>) -> Vec<Sanitiz
653657
result.push(SanitizerRuntime {
654658
cmake_target: format!("clang_rt.{}-x86_64", s),
655659
path: out_dir.join(&format!("build/lib/linux/libclang_rt.{}-x86_64.a", s)),
656-
name: format!("librustc_rt.{}.a", s),
660+
name: format!("librustc-{}_rt.{}.a", channel, s),
657661
});
658662
}
659663
}
@@ -662,7 +666,7 @@ fn supported_sanitizers(out_dir: &Path, target: Interned<String>) -> Vec<Sanitiz
662666
result.push(SanitizerRuntime {
663667
cmake_target: format!("clang_rt.{}-x86_64", s),
664668
path: out_dir.join(&format!("build/lib/fuchsia/libclang_rt.{}-x86_64.a", s)),
665-
name: format!("librustc_rt.{}.a", s),
669+
name: format!("librustc-{}_rt.{}.a", channel, s),
666670
});
667671
}
668672
}
@@ -671,7 +675,7 @@ fn supported_sanitizers(out_dir: &Path, target: Interned<String>) -> Vec<Sanitiz
671675
result.push(SanitizerRuntime {
672676
cmake_target: format!("clang_rt.{}-aarch64", s),
673677
path: out_dir.join(&format!("build/lib/fuchsia/libclang_rt.{}-aarch64.a", s)),
674-
name: format!("librustc_rt.{}.a", s),
678+
name: format!("librustc-{}_rt.{}.a", channel, s),
675679
});
676680
}
677681
}

src/librustc_codegen_ssa/back/link.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -765,20 +765,23 @@ fn link_sanitizer_runtime(sess: &Session, crate_type: config::CrateType, linker:
765765
let default_sysroot = filesearch::get_or_default_sysroot();
766766
let default_tlib =
767767
filesearch::make_target_lib_path(&default_sysroot, sess.opts.target_triple.triple());
768+
let channel = option_env!("CFG_RELEASE_CHANNEL")
769+
.map(|channel| format!("-{}", channel))
770+
.unwrap_or_default();
768771

769772
match sess.opts.target_triple.triple() {
770773
"x86_64-apple-darwin" => {
771774
// On Apple platforms, the sanitizer is always built as a dylib, and
772775
// LLVM will link to `@rpath/*.dylib`, so we need to specify an
773776
// rpath to the library as well (the rpath should be absolute, see
774777
// PR #41352 for details).
775-
let libname = format!("rustc_rt.{}", name);
778+
let libname = format!("rustc{}_rt.{}", channel, name);
776779
let rpath = default_tlib.to_str().expect("non-utf8 component in path");
777780
linker.args(&["-Wl,-rpath".into(), "-Xlinker".into(), rpath.into()]);
778781
linker.link_dylib(Symbol::intern(&libname));
779782
}
780783
"x86_64-unknown-linux-gnu" | "x86_64-fuchsia" | "aarch64-fuchsia" => {
781-
let filename = format!("librustc_rt.{}.a", name);
784+
let filename = format!("librustc{}_rt.{}.a", channel, name);
782785
let path = default_tlib.join(&filename);
783786
linker.link_whole_rlib(&path);
784787
}

src/librustc_codegen_ssa/build.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {
2+
println!("cargo:rerun-if-changed=build.rs");
3+
println!("cargo:rerun-if-env-changed=CFG_RELEASE_CHANNEL");
4+
}

0 commit comments

Comments
 (0)