Add custom driver
This commit is contained in:
parent
c046ad017f
commit
17a54ad62e
@ -32,15 +32,18 @@ if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
export RUSTFLAGS=$linker' -Ztrim-diagnostic-paths=no -Cpanic=abort -Cdebuginfo=2 -Zpanic-abort-tests -Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot'
|
||||
export RUSTDOCFLAGS=$RUSTFLAGS
|
||||
export RUSTC=$(pwd)/"target/"$CHANNEL"/cg_clif"
|
||||
export RUSTFLAGS=$linker
|
||||
export RUSTDOCFLAGS=$linker' -Ztrim-diagnostic-paths=no -Cpanic=abort -Zpanic-abort-tests '\
|
||||
'-Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot'
|
||||
|
||||
# FIXME remove once the atomic shim is gone
|
||||
if [[ `uname` == 'Darwin' ]]; then
|
||||
export RUSTFLAGS="$RUSTFLAGS -Clink-arg=-undefined -Clink-arg=dynamic_lookup"
|
||||
fi
|
||||
|
||||
export LD_LIBRARY_PATH="$(pwd)/target/out:$(pwd)/build_sysroot/sysroot/lib/rustlib/$TARGET_TRIPLE/lib"
|
||||
export LD_LIBRARY_PATH="$(pwd)/target/out:$(pwd)/build_sysroot/sysroot/lib/rustlib/"$TARGET_TRIPLE"/lib:\
|
||||
$(pwd)/target/"$CHANNEL":$(rustc --print sysroot)/lib"
|
||||
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
|
||||
|
||||
export CG_CLIF_DISPLAY_CG_TIME=1
|
||||
|
77
src/bin/cg_clif.rs
Normal file
77
src/bin/cg_clif.rs
Normal file
@ -0,0 +1,77 @@
|
||||
#![feature(rustc_private)]
|
||||
|
||||
extern crate rustc_data_structures;
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_interface;
|
||||
extern crate rustc_session;
|
||||
extern crate rustc_target;
|
||||
|
||||
use rustc_data_structures::profiling::print_time_passes_entry;
|
||||
use rustc_interface::interface;
|
||||
use rustc_session::config::ErrorOutputType;
|
||||
use rustc_session::early_error;
|
||||
use rustc_target::spec::PanicStrategy;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct TimePassesCallbacks {
|
||||
time_passes: bool,
|
||||
}
|
||||
|
||||
impl rustc_driver::Callbacks for TimePassesCallbacks {
|
||||
fn config(&mut self, config: &mut interface::Config) {
|
||||
// If a --prints=... option has been given, we don't print the "total"
|
||||
// time because it will mess up the --prints output. See #64339.
|
||||
self.time_passes = config.opts.prints.is_empty()
|
||||
&& (config.opts.debugging_opts.time_passes || config.opts.debugging_opts.time);
|
||||
|
||||
// FIXME workaround for an ICE
|
||||
config.opts.debugging_opts.trim_diagnostic_paths = false;
|
||||
|
||||
config.opts.cg.panic = Some(PanicStrategy::Abort);
|
||||
config.opts.debugging_opts.panic_abort_tests = true;
|
||||
config.opts.maybe_sysroot = Some(
|
||||
std::env::current_exe()
|
||||
.unwrap()
|
||||
.parent()
|
||||
.unwrap()
|
||||
.parent()
|
||||
.unwrap()
|
||||
.parent()
|
||||
.unwrap()
|
||||
.join("build_sysroot")
|
||||
.join("sysroot"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let start = std::time::Instant::now();
|
||||
rustc_driver::init_rustc_env_logger();
|
||||
let mut callbacks = TimePassesCallbacks::default();
|
||||
rustc_driver::install_ice_hook();
|
||||
let exit_code = rustc_driver::catch_with_exit_code(|| {
|
||||
let args = std::env::args_os()
|
||||
.enumerate()
|
||||
.map(|(i, arg)| {
|
||||
arg.into_string().unwrap_or_else(|arg| {
|
||||
early_error(
|
||||
ErrorOutputType::default(),
|
||||
&format!("Argument {} is not valid Unicode: {:?}", i, arg),
|
||||
)
|
||||
})
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
rustc_driver::run_compiler(
|
||||
&args,
|
||||
&mut callbacks,
|
||||
None,
|
||||
None,
|
||||
Some(Box::new(|_| {
|
||||
rustc_codegen_cranelift::__rustc_codegen_backend()
|
||||
})),
|
||||
)
|
||||
});
|
||||
// The extra `\t` is necessary to align this label with the others.
|
||||
print_time_passes_entry(callbacks.time_passes, "\ttotal", start.elapsed());
|
||||
std::process::exit(exit_code)
|
||||
}
|
9
test.sh
9
test.sh
@ -2,18 +2,19 @@
|
||||
set -e
|
||||
|
||||
# Build cg_clif
|
||||
export RUSTFLAGS="-Zrun_dsymutil=no"
|
||||
if [[ "$1" == "--release" ]]; then
|
||||
export CHANNEL='release'
|
||||
cargo rustc --release -- -Zrun_dsymutil=no
|
||||
cargo build --release
|
||||
else
|
||||
export CHANNEL='debug'
|
||||
cargo rustc -- -Zrun_dsymutil=no
|
||||
cargo build --bin cg_clif
|
||||
fi
|
||||
|
||||
# Config
|
||||
source scripts/config.sh
|
||||
export CG_CLIF_INCR_CACHE_DISABLED=1
|
||||
RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out"
|
||||
RUSTC=$RUSTC" "$RUSTFLAGS" -L crate=target/out --out-dir target/out -Cdebuginfo=2"
|
||||
|
||||
# Cleanup
|
||||
rm -r target/out || true
|
||||
@ -86,7 +87,7 @@ pushd simple-raytracer
|
||||
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then
|
||||
echo "[BENCH COMPILE] ebobby/simple-raytracer"
|
||||
hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "cargo clean" \
|
||||
"RUSTFLAGS='' cargo build" \
|
||||
"RUSTC=rustc RUSTFLAGS='' cargo build" \
|
||||
"../cargo.sh build"
|
||||
|
||||
echo "[BENCH RUN] ebobby/simple-raytracer"
|
||||
|
Loading…
Reference in New Issue
Block a user