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

Do not unconditionally succeed RUSTC_WRAPPER when run by build scripts #9235

Conversation

vlad20012
Copy link
Member

@vlad20012 vlad20012 commented Aug 24, 2022

Fixes #9198, fixes #9227.

Based on rust-lang/rust-analyzer#13010 and discussion in rust-lang/rust-analyzer#12973.

intellij-rust-native-helper in RUSTC_WRAPPER role unconditionally succeeds cargo check invocations tripping up build scripts using cargo check to probe for successful compilations. To prevent this from happening the RUSTC_WRAPPER now checks if it's run from a build script by looking for the CARGO_CFG_TARGET_ARCH env var that cargo sets only when running build scripts.

changelog: Fix broken anyhow compilation when org.rust.cargo.evaluate.build.scripts experimental feature is enabled

@vlad20012 vlad20012 added the fix Pull requests that fix some bug(s) label Aug 24, 2022
@Undin
Copy link
Member

Undin commented Aug 26, 2022

I think it should fix #9227 as well

Copy link
Member

@Undin Undin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, looks ok for me
Maybe add some tests to emulate a situation happened with anyhow crate?

@vlad20012 vlad20012 force-pushed the Do_not_unconditionally_succeed_RUSTC_WRAPPER_when_run_by_build_scripts branch from cbe129a to 41c28dc Compare August 29, 2022 15:57
intellij-rust-native-helper in `RUSTC_WRAPPER` role unconditionally succeeds
 `cargo check` invocations tripping up build scripts using `cargo check` to
 probe for successful compilations. To prevent this from happening the
 `RUSTC_WRAPPER` now checks if it's run from a build script by looking for
 the `CARGO_CFG_TARGET_ARCH` env var that cargo sets only when running
 build scripts.
@vlad20012 vlad20012 force-pushed the Do_not_unconditionally_succeed_RUSTC_WRAPPER_when_run_by_build_scripts branch from 41c28dc to f540fe2 Compare August 30, 2022 08:27
Copy link
Member

@Undin Undin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors r+

@bors
Copy link
Contributor

bors bot commented Aug 30, 2022

Build succeeded:

@bors bors bot merged commit bc9f993 into master Aug 30, 2022
@bors bors bot deleted the Do_not_unconditionally_succeed_RUSTC_WRAPPER_when_run_by_build_scripts branch August 30, 2022 11:34
@github-actions github-actions bot added this to the v178 milestone Aug 30, 2022
@Undin
Copy link
Member

Undin commented Aug 30, 2022

For QA: I failed to reproduce mentioned issues when Sync tool window shows error. I tested the following scenario:

  • project has anyhow = "=1.0.60" dependency
  • build script evaluation is enabled
  • the plugin performs project model loading
  • cargo build

Before these changes, cargo build failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Pull requests that fix some bug(s)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

auto jump to context.rs which in anyhow crate Failure to evaluate build script for anyhow
3 participants