Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove RUSTC_WRAPPER hack #12998

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions crates/project-model/src/build_scripts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,16 @@ impl WorkspaceBuildScripts {
) -> io::Result<WorkspaceBuildScripts> {
const RUST_1_62: Version = Version::new(1, 62, 0);

match Self::run_(Self::build_command(config), config, workspace, progress) {
match Self::run_(Self::build_command(config), workspace, progress) {
Ok(WorkspaceBuildScripts { error: Some(error), .. })
if toolchain.as_ref().map_or(false, |it| *it >= RUST_1_62) =>
{
tracing::info!("running build scripts failed, retrying with --keep-going flag");
// building build scripts failed, attempt to build with --keep-going so
// that we potentially get more build data
let mut cmd = Self::build_command(config);
cmd.args(&["-Z", "unstable-options", "--keep-going"]).env("RUSTC_BOOTSTRAP", "1");
let mut res = Self::run_(cmd, config, workspace, progress)?;
let mut res = Self::run_(cmd, workspace, progress)?;
res.error = Some(error);
Ok(res)
}
Expand All @@ -100,19 +101,9 @@ impl WorkspaceBuildScripts {

fn run_(
mut cmd: Command,
config: &CargoConfig,
workspace: &CargoWorkspace,
progress: &dyn Fn(String),
) -> io::Result<WorkspaceBuildScripts> {
if config.wrap_rustc_in_build_scripts {
// Setup RUSTC_WRAPPER to point to `rust-analyzer` binary itself. We use
// that to compile only proc macros and build scripts during the initial
// `cargo check`.
let myself = std::env::current_exe()?;
cmd.env("RUSTC_WRAPPER", myself);
cmd.env("RA_RUSTC_WRAPPER", "1");
}

cmd.current_dir(workspace.workspace_root());

let mut res = WorkspaceBuildScripts::default();
Expand Down
2 changes: 0 additions & 2 deletions crates/project-model/src/cargo_workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ pub struct CargoConfig {
/// crates to disable `#[cfg(test)]` on
pub unset_test_crates: UnsetTestCrates,

pub wrap_rustc_in_build_scripts: bool,

pub run_build_script_command: Option<Vec<String>>,
}

Expand Down
15 changes: 0 additions & 15 deletions crates/rust-analyzer/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]

mod logger;
mod rustc_wrapper;

use std::{env, fs, path::Path, process};

Expand All @@ -23,20 +22,6 @@ static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

fn main() {
if std::env::var("RA_RUSTC_WRAPPER").is_ok() {
let mut args = std::env::args_os();
let _me = args.next().unwrap();
let rustc = args.next().unwrap();
let code = match rustc_wrapper::run_rustc_skipping_cargo_checking(rustc, args.collect()) {
Ok(rustc_wrapper::ExitCode(code)) => code.unwrap_or(102),
Err(err) => {
eprintln!("{}", err);
101
}
};
process::exit(code);
}

if let Err(err) = try_main() {
tracing::error!("Unexpected error: {}", err);
eprintln!("{}", err);
Expand Down
46 changes: 0 additions & 46 deletions crates/rust-analyzer/src/bin/rustc_wrapper.rs

This file was deleted.

4 changes: 0 additions & 4 deletions crates/rust-analyzer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ config_data! {
/// ```
/// .
cargo_buildScripts_overrideCommand: Option<Vec<String>> = "null",
/// Use `RUSTC_WRAPPER=rust-analyzer` when running build scripts to
/// avoid checking unnecessary things.
cargo_buildScripts_useRustcWrapper: bool = "true",
/// List of features to activate.
///
/// Set this to `"all"` to pass `--all-features` to cargo.
Expand Down Expand Up @@ -960,7 +957,6 @@ impl Config {
no_sysroot: self.data.cargo_noSysroot,
rustc_source,
unset_test_crates: UnsetTestCrates::Only(self.data.cargo_unsetTest.clone()),
wrap_rustc_in_build_scripts: self.data.cargo_buildScripts_useRustcWrapper,
run_build_script_command: self.data.cargo_buildScripts_overrideCommand.clone(),
}
}
Expand Down
6 changes: 0 additions & 6 deletions docs/user/generated_config.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ cargo check --quiet --workspace --message-format=json --all-targets
```
.
--
[[rust-analyzer.cargo.buildScripts.useRustcWrapper]]rust-analyzer.cargo.buildScripts.useRustcWrapper (default: `true`)::
+
--
Use `RUSTC_WRAPPER=rust-analyzer` when running build scripts to
avoid checking unnecessary things.
--
[[rust-analyzer.cargo.features]]rust-analyzer.cargo.features (default: `[]`)::
+
--
Expand Down
5 changes: 0 additions & 5 deletions editors/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,11 +432,6 @@
"type": "string"
}
},
"rust-analyzer.cargo.buildScripts.useRustcWrapper": {
"markdownDescription": "Use `RUSTC_WRAPPER=rust-analyzer` when running build scripts to\navoid checking unnecessary things.",
"default": true,
"type": "boolean"
},
"rust-analyzer.cargo.features": {
"markdownDescription": "List of features to activate.\n\nSet this to `\"all\"` to pass `--all-features` to cargo.",
"default": [],
Expand Down