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

feat: Expost host and target sysroot to build scripts. #13443

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

c272
Copy link

@c272 c272 commented Feb 15, 2024

What does this PR try to resolve?

Currently, when using -Zbuild-std, Cargo passes a --sysroot argument down to the relevant rustc invocations. However, the value of this argument is not exposed to build scripts, so if a build script wishes to mirror the rustc configuration of the host, they must somehow discover the sysroot themselves.

This patch exposes the host (RUSTC_HOST_SYSROOT) and target (RUSTC_TARGET_SYSROOT) sysroots to build scripts through additional environment variables.

Fixes #7501
Related to rust-lang/wg-cargo-std-aware#50

How should we test and review this PR?

An example build script displaying these environment variables is as follows:

use std::env;

fn main() {
    println!("host: {}", env::var("RUSTC_HOST_SYSROOT").unwrap());
    println!("target: {}", env::var("RUSTC_TARGET_SYSROOT").unwrap());
}

Additional information

N/A

@rustbot
Copy link
Collaborator

rustbot commented Feb 15, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @weihanglo (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added A-build-scripts Area: build.rs scripts A-documenting-cargo-itself Area: Cargo's documentation S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 15, 2024
@weihanglo
Copy link
Member

Sorry I don't quite follow. I read through the relevant issues but haven't found any design decision made. Do we have discussions in other places like Zulip I missed?

@weihanglo
Copy link
Member

Asking because we would like to have design discussions in issue threads, and PRs is for discussing each implementation separately. That would make things a bit easier to follow :)

@ehuss ehuss added S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 19, 2024
@adamgemmell
Copy link

adamgemmell commented Feb 20, 2024

Hi, sorry about that! I advised c272 to share the implementation first as the best way to move the discussion forwards. We should have followed the contributor's guide a bit more closely - hope it didn't seem too pushy.

Writing the patch fleshed this idea out a bit more in the process, so one of us will share that in a separate feature request issue.

@bors
Copy link
Contributor

bors commented Feb 20, 2024

☔ The latest upstream changes (presumably #13409) made this pull request unmergeable. Please resolve the merge conflicts.

@bors
Copy link
Contributor

bors commented May 7, 2024

☔ The latest upstream changes (presumably #13872) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot
Copy link
Collaborator

rustbot commented Dec 20, 2024

☔ The latest upstream changes (possibly 081d7ba) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build-scripts Area: build.rs scripts A-documenting-cargo-itself Area: Cargo's documentation S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rust sysroot is not exposed to build scripts
6 participants