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

Respect CARGOFLAGS in bootstrap.py #111979

Merged
merged 1 commit into from
May 31, 2023
Merged

Respect CARGOFLAGS in bootstrap.py #111979

merged 1 commit into from
May 31, 2023

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented May 26, 2023

This makes it possible to pass flags to bootstrap itself, for consistency with std/rustc:

rust/src/bootstrap/builder.rs

Lines 1446 to 1447 in 0426562

if let Ok(s) = env::var("CARGOFLAGS") {
cargo.args(s.split_whitespace());

Like RUSTFLAGS, this doesn't support CARGOFLAGS_BOOTSTRAP:
# preserve existing RUSTFLAGS
env.setdefault("RUSTFLAGS", "")

I found this useful recently when I wanted to pass -Zsparse-registry to an old checkout of the compiler from before it was stabilized in cargo.

@rustbot
Copy link
Collaborator

rustbot commented May 26, 2023

r? @albertlarsan68

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels May 26, 2023
@albertlarsan68
Copy link
Member

Thanks for the PR!
@bors r+

Would be great to have a test at some point

@bors
Copy link
Contributor

bors commented May 30, 2023

📌 Commit 6674dcd has been approved by albertlarsan68

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 30, 2023
@jyn514
Copy link
Member Author

jyn514 commented May 30, 2023

do you have ideas for how to test this? maybe bootstrap_test.py can inspect the command that bootstrap.py generates somehow?

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request May 31, 2023
Respect CARGOFLAGS in bootstrap.py

This makes it possible to pass flags to bootstrap itself, for consistency with std/rustc: https://github.com/rust-lang/rust/blob/04265621f9a82cfc2fc2278b935dcc5d4a1c39b7/src/bootstrap/builder.rs#L1446-L1447
Like RUSTFLAGS, this doesn't support CARGOFLAGS_BOOTSTRAP: https://github.com/rust-lang/rust/blob/6674dcda7a1da4c66e0aa0cfc67b27e42f4ebb34/src/bootstrap/bootstrap.py#L883-L884

I found this useful recently when I wanted to pass `-Zsparse-registry` to an old checkout of the compiler from before it was stabilized in cargo.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request May 31, 2023
Respect CARGOFLAGS in bootstrap.py

This makes it possible to pass flags to bootstrap itself, for consistency with std/rustc: https://github.com/rust-lang/rust/blob/04265621f9a82cfc2fc2278b935dcc5d4a1c39b7/src/bootstrap/builder.rs#L1446-L1447
Like RUSTFLAGS, this doesn't support CARGOFLAGS_BOOTSTRAP: https://github.com/rust-lang/rust/blob/6674dcda7a1da4c66e0aa0cfc67b27e42f4ebb34/src/bootstrap/bootstrap.py#L883-L884

I found this useful recently when I wanted to pass `-Zsparse-registry` to an old checkout of the compiler from before it was stabilized in cargo.
bors added a commit to rust-lang-ci/rust that referenced this pull request May 31, 2023
…iaskrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#111772 (Fix linkage for large binaries on mips64 platforms)
 - rust-lang#111975 (Stop normalizing so many different prefixes)
 - rust-lang#111979 (Respect CARGOFLAGS in bootstrap.py)
 - rust-lang#112089 (Add `--warnings warn` flag to `x.py`)
 - rust-lang#112103 (Bootstrap update to 1.71 beta)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit aee05c7 into rust-lang:master May 31, 2023
@rustbot rustbot added this to the 1.72.0 milestone May 31, 2023
@jyn514 jyn514 deleted the cargoflags branch June 4, 2023 16:39
TaKO8Ki added a commit to TaKO8Ki/rust that referenced this pull request Jun 25, 2023
…larsan68

Test the cargo args generated by bootstrap.py

I recommend reviewing this commit-by-commit using the instructions in https://rustc-dev-guide.rust-lang.org/git.html#moving-large-sections-of-code.

- Test cargo arguments passed by bootstrap.py

  This moves a lot of code around, but the logic itself is not too terribly complicated.

    - Move almost all logic in `def bootstrap` to the `RustBuild` class, to avoid mixing setting configuration with running commands
    - Update various doctests to the new (more complete) RustBuild config. In particular, don't pretend that `bin_root` supports `build` being unset.
    - Change `parse_args` not to use a global, to allow testing it
    - Set BUILD_DIR appropriately so bootstrap.py doesn't panic because cargo isn't found

- Allow passing arguments to `bootstrap_test.py`

    Previous, it used the built-in test runner, which doesn't support options unless they're manually passed in the script.

- Fix progress messages for configure in bootstrap_test.py

    Before it would unconditionally print `configure-args = []`.

r? `@albertlarsan68` cc rust-lang#112089 rust-lang#111979 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants