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

RUSTC_WRAPPER is ignored #45

Closed
RalfJung opened this issue Mar 27, 2024 · 6 comments · Fixed by #46
Closed

RUSTC_WRAPPER is ignored #45

RalfJung opened this issue Mar 27, 2024 · 6 comments · Fixed by #46

Comments

@RalfJung
Copy link
Contributor

RalfJung commented Mar 27, 2024

rustc-version has the same issue as rust-lang/cargo#10885: it will by default ignore RUSTC_WRAPPER, so tools that expect to intercept all communication between a build and rustc by setting the wrapper will get entirely bypassed. If the wrapper ends up invoking an entirely different version of rustc than what is in the PATH, that can lead to incorrect results (e.g. when rustc-version is used from a build script).

@djc
Copy link
Owner

djc commented Mar 28, 2024

Happy to review a PR -- I'm doing passive maintenance only for this project.

@hkBst
Copy link
Contributor

hkBst commented Apr 18, 2024

I think the only thing needed for this is that:

pub fn version_meta() -> Result<VersionMeta> {
    let cmd = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc"));

    VersionMeta::for_command(Command::new(cmd))
}

first checks RUSTC_WRAPPER, maybe like so:

pub fn version_meta() -> Result<VersionMeta> {
    let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc"));
    let cmd = if let Some(wrapper) = env::var_os("RUSTC_WRAPPER") {
        Command::new(wrapper).arg(rustc)
    } else {
        Command::new(rustc)
    };

    VersionMeta::for_command(cmd)
}

@djc
Copy link
Owner

djc commented Apr 18, 2024

@hkBst great -- want to submit a PR for that?

@hkBst
Copy link
Contributor

hkBst commented Apr 18, 2024

done

@RalfJung
Copy link
Contributor Author

RalfJung commented Apr 18, 2024 via email

@hkBst
Copy link
Contributor

hkBst commented Apr 19, 2024

@RalfJung I've added flitering for empty strings, see #46.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants