1
Fork 0

Remove sanitizer runtime crates

This commit is contained in:
Tomasz Miąsko 2019-10-06 00:00:00 +00:00
parent adc6572500
commit 78e7eeeaa1
16 changed files with 0 additions and 404 deletions

View file

@ -3348,17 +3348,6 @@ dependencies = [
"smallvec 1.0.0", "smallvec 1.0.0",
] ]
[[package]]
name = "rustc_asan"
version = "0.0.0"
dependencies = [
"alloc",
"build_helper",
"cmake",
"compiler_builtins",
"core",
]
[[package]] [[package]]
name = "rustc_ast_lowering" name = "rustc_ast_lowering"
version = "0.0.0" version = "0.0.0"
@ -3680,17 +3669,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "rustc_lsan"
version = "0.0.0"
dependencies = [
"alloc",
"build_helper",
"cmake",
"compiler_builtins",
"core",
]
[[package]] [[package]]
name = "rustc_macros" name = "rustc_macros"
version = "0.1.0" version = "0.1.0"
@ -3752,17 +3730,6 @@ dependencies = [
"syntax", "syntax",
] ]
[[package]]
name = "rustc_msan"
version = "0.0.0"
dependencies = [
"alloc",
"build_helper",
"cmake",
"compiler_builtins",
"core",
]
[[package]] [[package]]
name = "rustc_parse" name = "rustc_parse"
version = "0.0.0" version = "0.0.0"
@ -3935,17 +3902,6 @@ dependencies = [
"syntax", "syntax",
] ]
[[package]]
name = "rustc_tsan"
version = "0.0.0"
dependencies = [
"alloc",
"build_helper",
"cmake",
"compiler_builtins",
"core",
]
[[package]] [[package]]
name = "rustc_typeck" name = "rustc_typeck"
version = "0.0.0" version = "0.0.0"
@ -4307,10 +4263,6 @@ dependencies = [
"panic_unwind", "panic_unwind",
"profiler_builtins", "profiler_builtins",
"rand 0.7.0", "rand 0.7.0",
"rustc_asan",
"rustc_lsan",
"rustc_msan",
"rustc_tsan",
"unwind", "unwind",
"wasi 0.9.0+wasi-snapshot-preview1", "wasi 0.9.0+wasi-snapshot-preview1",
] ]

View file

@ -984,10 +984,6 @@ impl Step for Src {
"src/libcore", "src/libcore",
"src/libpanic_abort", "src/libpanic_abort",
"src/libpanic_unwind", "src/libpanic_unwind",
"src/librustc_asan",
"src/librustc_lsan",
"src/librustc_msan",
"src/librustc_tsan",
"src/libstd", "src/libstd",
"src/libunwind", "src/libunwind",
"src/libtest", "src/libtest",

View file

@ -1,7 +1,5 @@
use std::fs::File;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
use std::thread;
use std::time::{SystemTime, UNIX_EPOCH}; use std::time::{SystemTime, UNIX_EPOCH};
use std::{env, fs}; use std::{env, fs};
@ -181,108 +179,6 @@ pub fn up_to_date(src: &Path, dst: &Path) -> bool {
} }
} }
#[must_use]
pub struct NativeLibBoilerplate {
pub src_dir: PathBuf,
pub out_dir: PathBuf,
}
impl NativeLibBoilerplate {
/// On macOS we don't want to ship the exact filename that compiler-rt builds.
/// This conflicts with the system and ours is likely a wildly different
/// version, so they can't be substituted.
///
/// As a result, we rename it here but we need to also use
/// `install_name_tool` on macOS to rename the commands listed inside of it to
/// ensure it's linked against correctly.
pub fn fixup_sanitizer_lib_name(&self, sanitizer_name: &str) {
if env::var("TARGET").unwrap() != "x86_64-apple-darwin" {
return;
}
let dir = self.out_dir.join("build/lib/darwin");
let name = format!("clang_rt.{}_osx_dynamic", sanitizer_name);
let src = dir.join(&format!("lib{}.dylib", name));
let new_name = format!("lib__rustc__{}.dylib", name);
let dst = dir.join(&new_name);
println!("{} => {}", src.display(), dst.display());
fs::rename(&src, &dst).unwrap();
let status = Command::new("install_name_tool")
.arg("-id")
.arg(format!("@rpath/{}", new_name))
.arg(&dst)
.status()
.expect("failed to execute `install_name_tool`");
assert!(status.success());
}
}
impl Drop for NativeLibBoilerplate {
fn drop(&mut self) {
if !thread::panicking() {
t!(File::create(self.out_dir.join("rustbuild.timestamp")));
}
}
}
// Perform standard preparations for native libraries that are build only once for all stages.
// Emit rerun-if-changed and linking attributes for Cargo, check if any source files are
// updated, calculate paths used later in actual build with CMake/make or C/C++ compiler.
// If Err is returned, then everything is up-to-date and further build actions can be skipped.
// Timestamps are created automatically when the result of `native_lib_boilerplate` goes out
// of scope, so all the build actions should be completed until then.
pub fn native_lib_boilerplate(
src_dir: &Path,
out_name: &str,
link_name: &str,
search_subdir: &str,
) -> Result<NativeLibBoilerplate, ()> {
rerun_if_changed_anything_in_dir(src_dir);
let out_dir =
env::var_os("RUSTBUILD_NATIVE_DIR").unwrap_or_else(|| env::var_os("OUT_DIR").unwrap());
let out_dir = PathBuf::from(out_dir).join(out_name);
t!(fs::create_dir_all(&out_dir));
if link_name.contains('=') {
println!("cargo:rustc-link-lib={}", link_name);
} else {
println!("cargo:rustc-link-lib=static={}", link_name);
}
println!("cargo:rustc-link-search=native={}", out_dir.join(search_subdir).display());
let timestamp = out_dir.join("rustbuild.timestamp");
if !up_to_date(Path::new("build.rs"), &timestamp) || !up_to_date(src_dir, &timestamp) {
Ok(NativeLibBoilerplate { src_dir: src_dir.to_path_buf(), out_dir })
} else {
Err(())
}
}
pub fn sanitizer_lib_boilerplate(
sanitizer_name: &str,
) -> Result<(NativeLibBoilerplate, String), ()> {
let (link_name, search_path, apple) = match &*env::var("TARGET").unwrap() {
"x86_64-unknown-linux-gnu" => {
(format!("clang_rt.{}-x86_64", sanitizer_name), "build/lib/linux", false)
}
"x86_64-apple-darwin" => {
(format!("clang_rt.{}_osx_dynamic", sanitizer_name), "build/lib/darwin", true)
}
_ => return Err(()),
};
let to_link = if apple {
format!("dylib=__rustc__{}", link_name)
} else {
format!("static={}", link_name)
};
// This env var is provided by rustbuild to tell us where `compiler-rt`
// lives.
let dir = env::var_os("RUST_COMPILER_RT_ROOT").unwrap();
let lib = native_lib_boilerplate(dir.as_ref(), sanitizer_name, &to_link, search_path)?;
Ok((lib, link_name))
}
fn dir_up_to_date(src: &Path, threshold: SystemTime) -> bool { fn dir_up_to_date(src: &Path, threshold: SystemTime) -> bool {
t!(fs::read_dir(src)).map(|e| t!(e)).all(|e| { t!(fs::read_dir(src)).map(|e| t!(e)).all(|e| {
let meta = t!(e.metadata()); let meta = t!(e.metadata());

View file

@ -1,20 +0,0 @@
[package]
authors = ["The Rust Project Developers"]
build = "build.rs"
name = "rustc_asan"
version = "0.0.0"
edition = "2018"
[lib]
name = "rustc_asan"
path = "lib.rs"
test = false
[build-dependencies]
build_helper = { path = "../build_helper" }
cmake = "0.1.38"
[dependencies]
alloc = { path = "../liballoc" }
core = { path = "../libcore" }
compiler_builtins = "0.1.0"

View file

@ -1,30 +0,0 @@
use build_helper::sanitizer_lib_boilerplate;
use std::env;
use cmake::Config;
fn main() {
println!("cargo:rerun-if-env-changed=RUSTC_BUILD_SANITIZERS");
if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) {
return;
}
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
build_helper::restore_library_path();
let (native, target) = match sanitizer_lib_boilerplate("asan") {
Ok(native) => native,
_ => return,
};
Config::new(&native.src_dir)
.define("COMPILER_RT_BUILD_SANITIZERS", "ON")
.define("COMPILER_RT_BUILD_BUILTINS", "OFF")
.define("COMPILER_RT_BUILD_XRAY", "OFF")
.define("LLVM_CONFIG_PATH", llvm_config)
.out_dir(&native.out_dir)
.build_target(&target)
.build();
native.fixup_sanitizer_lib_name("asan");
}
println!("cargo:rerun-if-env-changed=LLVM_CONFIG");
}

View file

@ -1,10 +0,0 @@
#![sanitizer_runtime]
#![feature(nll)]
#![feature(sanitizer_runtime)]
#![feature(staged_api)]
#![no_std]
#![unstable(
feature = "sanitizer_runtime_lib",
reason = "internal implementation detail of sanitizers",
issue = "none"
)]

View file

@ -1,20 +0,0 @@
[package]
authors = ["The Rust Project Developers"]
build = "build.rs"
name = "rustc_lsan"
version = "0.0.0"
edition = "2018"
[lib]
name = "rustc_lsan"
path = "lib.rs"
test = false
[build-dependencies]
build_helper = { path = "../build_helper" }
cmake = "0.1.38"
[dependencies]
alloc = { path = "../liballoc" }
core = { path = "../libcore" }
compiler_builtins = "0.1.0"

View file

@ -1,29 +0,0 @@
use build_helper::sanitizer_lib_boilerplate;
use std::env;
use cmake::Config;
fn main() {
println!("cargo:rerun-if-env-changed=RUSTC_BUILD_SANITIZERS");
if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) {
return;
}
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
build_helper::restore_library_path();
let (native, target) = match sanitizer_lib_boilerplate("lsan") {
Ok(native) => native,
_ => return,
};
Config::new(&native.src_dir)
.define("COMPILER_RT_BUILD_SANITIZERS", "ON")
.define("COMPILER_RT_BUILD_BUILTINS", "OFF")
.define("COMPILER_RT_BUILD_XRAY", "OFF")
.define("LLVM_CONFIG_PATH", llvm_config)
.out_dir(&native.out_dir)
.build_target(&target)
.build();
}
println!("cargo:rerun-if-env-changed=LLVM_CONFIG");
}

View file

@ -1,10 +0,0 @@
#![sanitizer_runtime]
#![feature(nll)]
#![feature(sanitizer_runtime)]
#![feature(staged_api)]
#![no_std]
#![unstable(
feature = "sanitizer_runtime_lib",
reason = "internal implementation detail of sanitizers",
issue = "none"
)]

View file

@ -1,20 +0,0 @@
[package]
authors = ["The Rust Project Developers"]
build = "build.rs"
name = "rustc_msan"
version = "0.0.0"
edition = "2018"
[lib]
name = "rustc_msan"
path = "lib.rs"
test = false
[build-dependencies]
build_helper = { path = "../build_helper" }
cmake = "0.1.38"
[dependencies]
alloc = { path = "../liballoc" }
core = { path = "../libcore" }
compiler_builtins = "0.1.0"

View file

@ -1,29 +0,0 @@
use build_helper::sanitizer_lib_boilerplate;
use std::env;
use cmake::Config;
fn main() {
println!("cargo:rerun-if-env-changed=RUSTC_BUILD_SANITIZERS");
if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) {
return;
}
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
build_helper::restore_library_path();
let (native, target) = match sanitizer_lib_boilerplate("msan") {
Ok(native) => native,
_ => return,
};
Config::new(&native.src_dir)
.define("COMPILER_RT_BUILD_SANITIZERS", "ON")
.define("COMPILER_RT_BUILD_BUILTINS", "OFF")
.define("COMPILER_RT_BUILD_XRAY", "OFF")
.define("LLVM_CONFIG_PATH", llvm_config)
.out_dir(&native.out_dir)
.build_target(&target)
.build();
}
println!("cargo:rerun-if-env-changed=LLVM_CONFIG");
}

View file

@ -1,10 +0,0 @@
#![sanitizer_runtime]
#![feature(nll)]
#![feature(sanitizer_runtime)]
#![feature(staged_api)]
#![no_std]
#![unstable(
feature = "sanitizer_runtime_lib",
reason = "internal implementation detail of sanitizers",
issue = "none"
)]

View file

@ -1,20 +0,0 @@
[package]
authors = ["The Rust Project Developers"]
build = "build.rs"
name = "rustc_tsan"
version = "0.0.0"
edition = "2018"
[lib]
name = "rustc_tsan"
path = "lib.rs"
test = false
[build-dependencies]
build_helper = { path = "../build_helper" }
cmake = "0.1.38"
[dependencies]
alloc = { path = "../liballoc" }
core = { path = "../libcore" }
compiler_builtins = "0.1.0"

View file

@ -1,30 +0,0 @@
use build_helper::sanitizer_lib_boilerplate;
use std::env;
use cmake::Config;
fn main() {
println!("cargo:rerun-if-env-changed=RUSTC_BUILD_SANITIZERS");
if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) {
return;
}
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
build_helper::restore_library_path();
let (native, target) = match sanitizer_lib_boilerplate("tsan") {
Ok(native) => native,
_ => return,
};
Config::new(&native.src_dir)
.define("COMPILER_RT_BUILD_SANITIZERS", "ON")
.define("COMPILER_RT_BUILD_BUILTINS", "OFF")
.define("COMPILER_RT_BUILD_XRAY", "OFF")
.define("LLVM_CONFIG_PATH", llvm_config)
.out_dir(&native.out_dir)
.build_target(&target)
.build();
native.fixup_sanitizer_lib_name("tsan");
}
println!("cargo:rerun-if-env-changed=LLVM_CONFIG");
}

View file

@ -1,10 +0,0 @@
#![sanitizer_runtime]
#![feature(nll)]
#![feature(sanitizer_runtime)]
#![feature(staged_api)]
#![no_std]
#![unstable(
feature = "sanitizer_runtime_lib",
reason = "internal implementation detail of sanitizers",
issue = "none"
)]

View file

@ -34,16 +34,6 @@ features = [ "rustc-dep-of-std" ] # enable build support for integrating into li
[dev-dependencies] [dev-dependencies]
rand = "0.7" rand = "0.7"
[target.x86_64-apple-darwin.dependencies]
rustc_asan = { path = "../librustc_asan" }
rustc_tsan = { path = "../librustc_tsan" }
[target.x86_64-unknown-linux-gnu.dependencies]
rustc_asan = { path = "../librustc_asan" }
rustc_lsan = { path = "../librustc_lsan" }
rustc_msan = { path = "../librustc_msan" }
rustc_tsan = { path = "../librustc_tsan" }
[target.'cfg(any(all(target_arch = "wasm32", not(target_os = "emscripten")), all(target_vendor = "fortanix", target_env = "sgx")))'.dependencies] [target.'cfg(any(all(target_arch = "wasm32", not(target_os = "emscripten")), all(target_vendor = "fortanix", target_env = "sgx")))'.dependencies]
dlmalloc = { version = "0.1", features = ['rustc-dep-of-std'] } dlmalloc = { version = "0.1", features = ['rustc-dep-of-std'] }