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

Vendoring broken with stable rustc #112391

Closed
bjorn3 opened this issue Jun 7, 2023 · 11 comments · Fixed by #120001 or #123942
Closed

Vendoring broken with stable rustc #112391

bjorn3 opened this issue Jun 7, 2023 · 11 comments · Fixed by #120001 or #123942
Assignees
Labels
C-bug Category: This is a bug. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@bjorn3
Copy link
Member

bjorn3 commented Jun 7, 2023

I tried to enable vendoring in config.toml and then following the instructions given by ./x.py.

I expected to see this happen: All dependencies are vendored.

Instead, this happened:

$ ./x.py build
error: vendoring required, but vendor directory does not exist.
       Run `cargo vendor --sync ./src/tools/cargo/Cargo.toml --sync ./src/tools/rust-analyzer/Cargo.toml --sync ./compiler/rustc_codegen_cranelift/Cargo.toml --sync ./src/bootstrap/Cargo.toml ` to initialize the vendor directory.
Alternatively, use the pre-vendored `rustc-src` dist component.
[...]
$ cargo vendor --sync ./src/tools/cargo/Cargo.toml --sync ./src/tools/rust-analyzer/Cargo.toml --sync ./compiler/rustc_codegen_cranelift/Cargo.toml --sync ./src/bootstrap/Cargo.toml
error: failed to load manifest for workspace member `/home/gh-bjorn3/rust/library/std`

Caused by:
  failed to parse manifest at `/home/gh-bjorn3/rust/library/std/Cargo.toml`

Caused by:
  the cargo feature `public-dependency` requires a nightly version of Cargo, but this is the `stable` channel
  See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels.
  See https://doc.rust-lang.org/cargo/reference/unstable.html#public-dependency for more information about using this feature.

To work around this, I need to explicitly use a nightly cargo.

Meta

Caused by #111076 enabling the public-dependency unstable cargo feature.

@bjorn3 bjorn3 added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) C-bug Category: This is a bug. labels Jun 7, 2023
@bjorn3
Copy link
Member Author

bjorn3 commented Jun 19, 2023

This also broke the rust-analyzer config as rust-analyzer fetches the workspace layout using the default toolchain which for most users is stable.

@jyn514
Copy link
Member

jyn514 commented Jun 19, 2023

can we override the cargo that rust-analyzer uses? we should use the beta toolchain for consistency.

@bjorn3
Copy link
Member Author

bjorn3 commented Jun 19, 2023

I can't find any configuration for that.

@jyn514
Copy link
Member

jyn514 commented Jun 19, 2023

ok. i think we should consider reverting #111076. @notriddle why did you need a new cargo feature to make that PR work?

@jyn514 jyn514 added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Jun 19, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jun 19, 2023
@notriddle
Copy link
Contributor

notriddle commented Jun 19, 2023

So, how are people going to dogfood unstable Cargo features before they get stabilized if rust-analyzer breaks on it?

In any case, I used an unstable Cargo feature because I wanted to use the private dependency metadata in the rlib, and that means Cargo needs to actually mark the dependency as private, and that means Cargo.toml needs to communicate this information to Cargo.

@bjorn3
Copy link
Member Author

bjorn3 commented Jun 19, 2023

In any case, I used an unstable Cargo feature because I wanted to use the private dependency metadata in the rlib, and that means Cargo needs to actually mark the dependency as private, and that means Cargo.toml needs to communicate this information to Cargo.

As a hack you could handle marking deps as private and public in src/bootstrap/bin/rustc.rs.

@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jun 21, 2023
@Be-ing
Copy link
Contributor

Be-ing commented Jun 30, 2023

I am stumbling over this too.

I can't find any configuration for that.

So is the only workaround rustup default nightly?

@bjorn3
Copy link
Member Author

bjorn3 commented Jun 30, 2023

You can also put +nightly between cargo and vendor to override the toolchain to use for just a single call. I'm not aware of any other workaround than using nightly or using the unstable RUSTC_BOOTSTRAP with a recent enough stable/beta cargo.

notriddle added a commit to notriddle/rust that referenced this issue Jul 20, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 31, 2023
…v, r=Mark-Simulacrum

etc: add `RUSTC_BOOTSTRAP` to rust-analyzer config

Fixes the problem reported in rust-lang#112391 (comment)
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 31, 2023
…v, r=Mark-Simulacrum

etc: add `RUSTC_BOOTSTRAP` to rust-analyzer config

Fixes the problem reported in rust-lang#112391 (comment)
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 31, 2023
…v, r=Mark-Simulacrum

etc: add `RUSTC_BOOTSTRAP` to rust-analyzer config

Fixes the problem reported in rust-lang#112391 (comment)
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Aug 2, 2023
…-Simulacrum

etc: add `RUSTC_BOOTSTRAP` to rust-analyzer config

Fixes the problem reported in rust-lang/rust#112391 (comment)
@onur-ozkan onur-ozkan self-assigned this Nov 8, 2023
compiler-errors added a commit to compiler-errors/rust that referenced this issue Jan 17, 2024
…-ozkan

Consistently unset RUSTC_BOOTSTRAP when compiling bootstrap

Since rust-lang#113906, all x.py invocations performed by rust-analyzer have RUSTC_BOOTSTRAP=1 set. This was to fix rust-lang#112391 (comment) — rust-analyzer uses some default cargo from the system when fetching workspace layout, and the standard library uses some unstable cargo feature, so x.py would previously fail if the system toolchain wasn't nightly.

https://github.com/rust-lang/rust/blob/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/Cargo.toml#L1

This PR changes x.py to cancel out this RUSTC_BOOTSTRAP=1 when compiling bootstrap. It will only remain set when running the compiled bootstrap executable. This fixes spurious bootstrap rebuilds in the event that a rust-analyzer x.py invocation is alternated with someone running x.py themself on the command line, if any dependency of bootstrap looks at `option_env!("RUSTC_BOOTSTRAP")`, which is the case since rust-lang#119654.

**Before:**

```console
$ RUSTC_BOOTSTRAP=1 ./x.py check library/core
Building bootstrap
   Compiling proc-macro2 v1.0.76
   Compiling quote v1.0.35
   Compiling syn v2.0.48
   Compiling clap_derive v4.4.7
   Compiling serde_derive v1.0.195
   Compiling clap v4.4.13
   Compiling clap_complete v4.4.6
   Compiling build_helper v0.1.0
   Compiling bootstrap v0.0.0
    Finished dev [unoptimized] target(s) in 6.31s
Checking stage0 library artifacts {core} (x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.23s
Build completed successfully in 0:00:07

$ ./x.py check library/core
Building bootstrap
   Compiling proc-macro2 v1.0.76
   Compiling quote v1.0.35
   Compiling syn v2.0.48
   Compiling clap_derive v4.4.7
   Compiling serde_derive v1.0.195
   Compiling clap v4.4.13
   Compiling clap_complete v4.4.6
   Compiling build_helper v0.1.0
   Compiling bootstrap v0.0.0
    Finished dev [unoptimized] target(s) in 5.30s
Checking stage0 library artifacts {core} (x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.25s
Build completed successfully in 0:00:06
```

**After:**

```console
$ RUSTC_BOOTSTRAP=1 ./x.py check library/core
Building bootstrap
    Finished dev [unoptimized] target(s) in 0.06s
Checking stage0 library artifacts {core} (x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.14s
Build completed successfully in 0:00:01

$ ./x.py check library/core
Building bootstrap
    Finished dev [unoptimized] target(s) in 0.04s
Checking stage0 library artifacts {core} (x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.13s
Build completed successfully in 0:00:01
```
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 17, 2024
…-ozkan

Consistently unset RUSTC_BOOTSTRAP when compiling bootstrap

Since rust-lang#113906, all x.py invocations performed by rust-analyzer have RUSTC_BOOTSTRAP=1 set. This was to fix rust-lang#112391 (comment) — rust-analyzer uses some default cargo from the system when fetching workspace layout, and the standard library uses some unstable cargo feature, so x.py would previously fail if the system toolchain wasn't nightly.

https://github.com/rust-lang/rust/blob/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/Cargo.toml#L1

This PR changes x.py to cancel out this RUSTC_BOOTSTRAP=1 when compiling bootstrap. It will only remain set when running the compiled bootstrap executable. This fixes spurious bootstrap rebuilds in the event that a rust-analyzer x.py invocation is alternated with someone running x.py themself on the command line, if any dependency of bootstrap looks at `option_env!("RUSTC_BOOTSTRAP")`, which is the case since rust-lang#119654.

**Before:**

```console
$ RUSTC_BOOTSTRAP=1 ./x.py check library/core
Building bootstrap
   Compiling proc-macro2 v1.0.76
   Compiling quote v1.0.35
   Compiling syn v2.0.48
   Compiling clap_derive v4.4.7
   Compiling serde_derive v1.0.195
   Compiling clap v4.4.13
   Compiling clap_complete v4.4.6
   Compiling build_helper v0.1.0
   Compiling bootstrap v0.0.0
    Finished dev [unoptimized] target(s) in 6.31s
Checking stage0 library artifacts {core} (x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.23s
Build completed successfully in 0:00:07

$ ./x.py check library/core
Building bootstrap
   Compiling proc-macro2 v1.0.76
   Compiling quote v1.0.35
   Compiling syn v2.0.48
   Compiling clap_derive v4.4.7
   Compiling serde_derive v1.0.195
   Compiling clap v4.4.13
   Compiling clap_complete v4.4.6
   Compiling build_helper v0.1.0
   Compiling bootstrap v0.0.0
    Finished dev [unoptimized] target(s) in 5.30s
Checking stage0 library artifacts {core} (x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.25s
Build completed successfully in 0:00:06
```

**After:**

```console
$ RUSTC_BOOTSTRAP=1 ./x.py check library/core
Building bootstrap
    Finished dev [unoptimized] target(s) in 0.06s
Checking stage0 library artifacts {core} (x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.14s
Build completed successfully in 0:00:01

$ ./x.py check library/core
Building bootstrap
    Finished dev [unoptimized] target(s) in 0.04s
Checking stage0 library artifacts {core} (x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.13s
Build completed successfully in 0:00:01
```
compiler-errors added a commit to compiler-errors/rust that referenced this issue Jan 17, 2024
…-ozkan

Consistently unset RUSTC_BOOTSTRAP when compiling bootstrap

Since rust-lang#113906, all x.py invocations performed by rust-analyzer have RUSTC_BOOTSTRAP=1 set. This was to fix rust-lang#112391 (comment) — rust-analyzer uses some default cargo from the system when fetching workspace layout, and the standard library uses some unstable cargo feature, so x.py would previously fail if the system toolchain wasn't nightly.

https://github.com/rust-lang/rust/blob/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/Cargo.toml#L1

This PR changes x.py to cancel out this RUSTC_BOOTSTRAP=1 when compiling bootstrap. It will only remain set when running the compiled bootstrap executable. This fixes spurious bootstrap rebuilds in the event that a rust-analyzer x.py invocation is alternated with someone running x.py themself on the command line, if any dependency of bootstrap looks at `option_env!("RUSTC_BOOTSTRAP")`, which is the case since rust-lang#119654.

**Before:**

```console
$ RUSTC_BOOTSTRAP=1 ./x.py check library/core
Building bootstrap
   Compiling proc-macro2 v1.0.76
   Compiling quote v1.0.35
   Compiling syn v2.0.48
   Compiling clap_derive v4.4.7
   Compiling serde_derive v1.0.195
   Compiling clap v4.4.13
   Compiling clap_complete v4.4.6
   Compiling build_helper v0.1.0
   Compiling bootstrap v0.0.0
    Finished dev [unoptimized] target(s) in 6.31s
Checking stage0 library artifacts {core} (x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.23s
Build completed successfully in 0:00:07

$ ./x.py check library/core
Building bootstrap
   Compiling proc-macro2 v1.0.76
   Compiling quote v1.0.35
   Compiling syn v2.0.48
   Compiling clap_derive v4.4.7
   Compiling serde_derive v1.0.195
   Compiling clap v4.4.13
   Compiling clap_complete v4.4.6
   Compiling build_helper v0.1.0
   Compiling bootstrap v0.0.0
    Finished dev [unoptimized] target(s) in 5.30s
Checking stage0 library artifacts {core} (x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.25s
Build completed successfully in 0:00:06
```

**After:**

```console
$ RUSTC_BOOTSTRAP=1 ./x.py check library/core
Building bootstrap
    Finished dev [unoptimized] target(s) in 0.06s
Checking stage0 library artifacts {core} (x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.14s
Build completed successfully in 0:00:01

$ ./x.py check library/core
Building bootstrap
    Finished dev [unoptimized] target(s) in 0.04s
Checking stage0 library artifacts {core} (x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.13s
Build completed successfully in 0:00:01
```
@bors bors closed this as completed in cc9a4a2 Jan 18, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 18, 2024
Rollup merge of rust-lang#120001 - dtolnay:bootstrapbootstrap, r=onur-ozkan

Consistently unset RUSTC_BOOTSTRAP when compiling bootstrap

Since rust-lang#113906, all x.py invocations performed by rust-analyzer have RUSTC_BOOTSTRAP=1 set. This was to fix rust-lang#112391 (comment) — rust-analyzer uses some default cargo from the system when fetching workspace layout, and the standard library uses some unstable cargo feature, so x.py would previously fail if the system toolchain wasn't nightly.

https://github.com/rust-lang/rust/blob/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/Cargo.toml#L1

This PR changes x.py to cancel out this RUSTC_BOOTSTRAP=1 when compiling bootstrap. It will only remain set when running the compiled bootstrap executable. This fixes spurious bootstrap rebuilds in the event that a rust-analyzer x.py invocation is alternated with someone running x.py themself on the command line, if any dependency of bootstrap looks at `option_env!("RUSTC_BOOTSTRAP")`, which is the case since rust-lang#119654.

**Before:**

```console
$ RUSTC_BOOTSTRAP=1 ./x.py check library/core
Building bootstrap
   Compiling proc-macro2 v1.0.76
   Compiling quote v1.0.35
   Compiling syn v2.0.48
   Compiling clap_derive v4.4.7
   Compiling serde_derive v1.0.195
   Compiling clap v4.4.13
   Compiling clap_complete v4.4.6
   Compiling build_helper v0.1.0
   Compiling bootstrap v0.0.0
    Finished dev [unoptimized] target(s) in 6.31s
Checking stage0 library artifacts {core} (x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.23s
Build completed successfully in 0:00:07

$ ./x.py check library/core
Building bootstrap
   Compiling proc-macro2 v1.0.76
   Compiling quote v1.0.35
   Compiling syn v2.0.48
   Compiling clap_derive v4.4.7
   Compiling serde_derive v1.0.195
   Compiling clap v4.4.13
   Compiling clap_complete v4.4.6
   Compiling build_helper v0.1.0
   Compiling bootstrap v0.0.0
    Finished dev [unoptimized] target(s) in 5.30s
Checking stage0 library artifacts {core} (x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.25s
Build completed successfully in 0:00:06
```

**After:**

```console
$ RUSTC_BOOTSTRAP=1 ./x.py check library/core
Building bootstrap
    Finished dev [unoptimized] target(s) in 0.06s
Checking stage0 library artifacts {core} (x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.14s
Build completed successfully in 0:00:01

$ ./x.py check library/core
Building bootstrap
    Finished dev [unoptimized] target(s) in 0.04s
Checking stage0 library artifacts {core} (x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.13s
Build completed successfully in 0:00:01
```
@dtolnay dtolnay reopened this Jan 18, 2024
@onur-ozkan
Copy link
Member

This is no longer a problem since #120096 I think?

@bjorn3
Copy link
Member Author

bjorn3 commented Apr 13, 2024

Does that also add RUSTC_BOOTSTRAP=1 to the vendor command shown by x.py?

@onur-ozkan
Copy link
Member

$ ./x.py build
error: vendoring required, but vendor directory does not exist.
       Run `cargo vendor --sync ./src/tools/cargo/Cargo.toml --sync ./src/tools/rust-analyzer/Cargo.toml --sync ./compiler/rustc_codegen_cranelift/Cargo.toml --sync ./src/bootstrap/Cargo.toml ` to initialize the vendor directory.
Alternatively, use the pre-vendored `rustc-src` dist component.
[...]
$ cargo vendor --sync ./src/tools/cargo/Cargo.toml --sync ./src/tools/rust-analyzer/Cargo.toml --sync ./compiler/rustc_codegen_cranelift/Cargo.toml --sync ./src/bootstrap/Cargo.toml

Oh wait, I didn't see the manually invoked cargo part.

@onur-ozkan onur-ozkan mentioned this issue Apr 14, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 27, 2024
…crum

`x vendor`

This PR implements `x vendor` on bootstrap; enabling dependency vendoring without the need for developers to have `cargo` installed on their system (previously, we suggested running `cargo vendor ...` but now we can accomplish the same task with `x vendor`).

In addition, fixes rust-lang#112391 problem.
@bors bors closed this as completed in 8ef4a8d Apr 28, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 28, 2024
Rollup merge of rust-lang#123942 - onur-ozkan:x-vendor, r=Mark-Simulacrum

`x vendor`

This PR implements `x vendor` on bootstrap; enabling dependency vendoring without the need for developers to have `cargo` installed on their system (previously, we suggested running `cargo vendor ...` but now we can accomplish the same task with `x vendor`).

In addition, fixes rust-lang#112391 problem.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
8 participants