Skip to content

Commit

Permalink
Use RUSTC instead of RUSTC_WRAPPER
Browse files Browse the repository at this point in the history
  • Loading branch information
nilehmann committed Oct 11, 2023
1 parent 521260d commit 64612d7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions crates/flux-bin/src/bin/cargo-flux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn main() {
}

fn run() -> Result<i32> {
let flux_path = get_flux_driver_path()?;
let flux_driver_path = get_flux_driver_path()?;
let rust_toolchain = get_rust_toolchain()?;
let ld_library_path = get_ld_library_path(&rust_toolchain)?;
let extended_lib_path = extend_env_var_with_path(LIB_PATH, ld_library_path)?;
Expand All @@ -39,7 +39,7 @@ fn run() -> Result<i32> {
.env(LIB_PATH, extended_lib_path)
.env("RUST_TOOLCHAIN", rust_toolchain.clone())
.env("RUSTUP_TOOLCHAIN", rust_toolchain)
.env("RUSTC_WRAPPER", flux_path)
.env("RUSTC", flux_driver_path)
.env("CARGO_TARGET_DIR", cargo_target)
.status()?
.code();
Expand Down
18 changes: 6 additions & 12 deletions crates/flux-driver/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@ use std::{env, io, process::exit};
use flux_driver::callbacks::FluxCallbacks;
use rustc_driver::{catch_with_exit_code, RunCompiler};

const CMD_RUSTC: &str = "rustc";

mod logger;

fn main() -> io::Result<()> {
let resolve_logs = logger::install()?;

// Check if we are being called from cargo.
let in_cargo = env::var("CARGO").is_ok();

// HACK(nilehmann)
// * Setting RUSTC_WRAPPER causes Cargo to pass 'rustc' as the first argument. We igore the
// argument and use it to determine if the binary is being called from cargo.
// * Disable incremental compilation because that makes the borrow checker to not run
// and we fail to retrieve the mir.
// Disable incremental compilation because that makes the borrow checker to not run
// and we fail to retrieve the mir.
let mut args = vec![];
let mut in_cargo = false;
let mut is_codegen = false;
for arg in env::args() {
if arg.starts_with("-C") || arg.starts_with("--codegen") {
Expand All @@ -32,11 +30,7 @@ fn main() -> io::Result<()> {
args.push("-C".to_string());
is_codegen = false;
}
if arg.ends_with(CMD_RUSTC) {
in_cargo = true;
} else {
args.push(arg);
}
args.push(arg);
}
}
// Add the sysroot path to the arguments.
Expand Down

0 comments on commit 64612d7

Please sign in to comment.