diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2022-02-13 19:31:49 +0100 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2022-04-29 19:13:41 +0200 |
| commit | 2e65a8f2ca9e2d7ffd42ef8b2c21436d4997c35d (patch) | |
| tree | 70d0d9a94a34c6ddc1dbdf966a214257721c9591 /scripts | |
| parent | 617171e930cc282ceaa71fd6a6cd18615ad1bf59 (diff) | |
| download | rust-2e65a8f2ca9e2d7ffd42ef8b2c21436d4997c35d.tar.gz rust-2e65a8f2ca9e2d7ffd42ef8b2c21436d4997c35d.zip | |
Use -Zcodegen-backend instead of a rustc replacement in cargo-clif
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/cargo-clif.rs | 22 | ||||
| -rw-r--r-- | scripts/config.sh | 6 | ||||
| -rwxr-xr-x | scripts/filter_profile.rs | 3 | ||||
| -rw-r--r-- | scripts/rustc-clif.rs | 36 | ||||
| -rw-r--r-- | scripts/setup_rust_fork.sh | 3 | ||||
| -rwxr-xr-x | scripts/tests.sh | 7 |
6 files changed, 47 insertions, 30 deletions
diff --git a/scripts/cargo-clif.rs b/scripts/cargo-clif.rs index 41d82b581cd..20aee5ff81b 100644 --- a/scripts/cargo-clif.rs +++ b/scripts/cargo-clif.rs @@ -5,20 +5,11 @@ use std::path::PathBuf; use std::process::Command; fn main() { - if env::var("RUSTC_WRAPPER").map_or(false, |wrapper| wrapper.contains("sccache")) { - eprintln!( - "\x1b[1;93m=== Warning: Unsetting RUSTC_WRAPPER to prevent interference with sccache ===\x1b[0m" - ); - env::remove_var("RUSTC_WRAPPER"); - } - let sysroot = PathBuf::from(env::current_exe().unwrap().parent().unwrap()); - env::set_var("RUSTC", sysroot.join("bin/cg_clif".to_string() + env::consts::EXE_SUFFIX)); - - let mut rustdoc_flags = env::var("RUSTDOCFLAGS").unwrap_or(String::new()); - rustdoc_flags.push_str(" -Cpanic=abort -Zpanic-abort-tests -Zcodegen-backend="); - rustdoc_flags.push_str( + let mut rustflags = String::new(); + rustflags.push_str(" -Cpanic=abort -Zpanic-abort-tests -Zcodegen-backend="); + rustflags.push_str( sysroot .join(if cfg!(windows) { "bin" } else { "lib" }) .join( @@ -29,9 +20,10 @@ fn main() { .to_str() .unwrap(), ); - rustdoc_flags.push_str(" --sysroot "); - rustdoc_flags.push_str(sysroot.to_str().unwrap()); - env::set_var("RUSTDOCFLAGS", rustdoc_flags); + rustflags.push_str(" --sysroot "); + rustflags.push_str(sysroot.to_str().unwrap()); + env::set_var("RUSTFLAGS", env::var("RUSTFLAGS").unwrap_or(String::new()) + &rustflags); + env::set_var("RUSTDOCFLAGS", env::var("RUSTDOCFLAGS").unwrap_or(String::new()) + &rustflags); // Ensure that the right toolchain is used env::set_var("RUSTUP_TOOLCHAIN", env!("RUSTUP_TOOLCHAIN")); diff --git a/scripts/config.sh b/scripts/config.sh deleted file mode 100644 index 53ada369b08..00000000000 --- a/scripts/config.sh +++ /dev/null @@ -1,6 +0,0 @@ -# Note to people running shellcheck: this file should only be sourced, not executed directly. - -set -e - -export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib:$LD_LIBRARY_PATH" -export DYLD_LIBRARY_PATH="$(rustc --print sysroot)/lib:$DYLD_LIBRARY_PATH" diff --git a/scripts/filter_profile.rs b/scripts/filter_profile.rs index f4e863e5494..e6f60d1c0cb 100755 --- a/scripts/filter_profile.rs +++ b/scripts/filter_profile.rs @@ -2,8 +2,7 @@ #![forbid(unsafe_code)]/* This line is ignored by bash # This block is ignored by rustc pushd $(dirname "$0")/../ -source scripts/config.sh -RUSTC="$(pwd)/build/bin/cg_clif" +RUSTC="$(pwd)/build/rustc-clif" popd PROFILE=$1 OUTPUT=$2 exec $RUSTC -Zunstable-options -Cllvm-args=mode=jit -Cprefer-dynamic $0 #*/ diff --git a/scripts/rustc-clif.rs b/scripts/rustc-clif.rs new file mode 100644 index 00000000000..3abfcd8ddc8 --- /dev/null +++ b/scripts/rustc-clif.rs @@ -0,0 +1,36 @@ +use std::env; +use std::ffi::OsString; +#[cfg(unix)] +use std::os::unix::process::CommandExt; +use std::path::PathBuf; +use std::process::Command; + +fn main() { + let sysroot = PathBuf::from(env::current_exe().unwrap().parent().unwrap()); + + let cg_clif_dylib_path = sysroot.join(if cfg!(windows) { "bin" } else { "lib" }).join( + env::consts::DLL_PREFIX.to_string() + "rustc_codegen_cranelift" + env::consts::DLL_SUFFIX, + ); + + let mut args = std::env::args_os().skip(1).collect::<Vec<_>>(); + args.push(OsString::from("-Cpanic=abort")); + args.push(OsString::from("-Zpanic-abort-tests")); + let mut codegen_backend_arg = OsString::from("-Zcodegen-backend="); + codegen_backend_arg.push(cg_clif_dylib_path); + args.push(codegen_backend_arg); + if !args.contains(&OsString::from("--sysroot")) { + args.push(OsString::from("--sysroot")); + args.push(OsString::from(sysroot.to_str().unwrap())); + } + + // Ensure that the right toolchain is used + env::set_var("RUSTUP_TOOLCHAIN", env!("RUSTUP_TOOLCHAIN")); + + #[cfg(unix)] + Command::new("rustc").args(args).exec(); + + #[cfg(not(unix))] + std::process::exit( + Command::new("rustc").args(args).spawn().unwrap().wait().unwrap().code().unwrap_or(1), + ); +} diff --git a/scripts/setup_rust_fork.sh b/scripts/setup_rust_fork.sh index fa71dfeac07..4d0dfa16c5e 100644 --- a/scripts/setup_rust_fork.sh +++ b/scripts/setup_rust_fork.sh @@ -2,7 +2,6 @@ set -e ./y.rs build --no-unstable-features -source scripts/config.sh echo "[SETUP] Rust fork" git clone https://github.com/rust-lang/rust.git || true @@ -52,7 +51,7 @@ changelog-seen = 2 ninja = false [build] -rustc = "$(pwd)/../build/bin/cg_clif" +rustc = "$(pwd)/../build/rustc-clif" cargo = "$(rustup which cargo)" full-bootstrap = true local-rebuild = true diff --git a/scripts/tests.sh b/scripts/tests.sh index cdde44ac67c..cd6b2181ace 100755 --- a/scripts/tests.sh +++ b/scripts/tests.sh @@ -2,8 +2,6 @@ set -e -source scripts/config.sh - export CG_CLIF_DISPLAY_CG_TIME=1 export CG_CLIF_DISABLE_INCR_CACHE=1 @@ -31,8 +29,7 @@ if [[ "$(uname)" == 'Darwin' ]]; then export RUSTFLAGS="$RUSTFLAGS -Clink-arg=-undefined -Clink-arg=dynamic_lookup" fi -export RUSTC=false # ensure that cg_llvm isn't accidentally used -MY_RUSTC="$(pwd)/build/bin/cg_clif $RUSTFLAGS -L crate=target/out --out-dir target/out -Cdebuginfo=2" +MY_RUSTC="$(pwd)/build/rustc-clif $RUSTFLAGS -L crate=target/out --out-dir target/out -Cdebuginfo=2" function no_sysroot_tests() { echo "[BUILD] mini_core" @@ -124,7 +121,7 @@ function extended_sysroot_tests() { if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then echo "[BENCH COMPILE] ebobby/simple-raytracer" hyperfine --runs "${RUN_RUNS:-10}" --warmup 1 --prepare "../build/cargo-clif clean" \ - "RUSTC=rustc RUSTFLAGS='' cargo build" \ + "RUSTFLAGS='' cargo build" \ "../build/cargo-clif build" echo "[BENCH RUN] ebobby/simple-raytracer" |
