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

cargo fmt and other tools don't work for a linked toolchain. #81431

Closed
vext01 opened this issue Jan 27, 2021 · 9 comments · Fixed by #110365
Closed

cargo fmt and other tools don't work for a linked toolchain. #81431

vext01 opened this issue Jan 27, 2021 · 9 comments · Fixed by #110365
Assignees
Labels
C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@vext01
Copy link
Contributor

vext01 commented Jan 27, 2021

This is derived from this issue, in which we concluded that the bug should be filed against rustc, as it's an x.py problem.

In rustc:

$ ./x.py build --stage 1 src/tools/rustfmt/
...
$ find 'build' -name rustfmt
build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/rustfmt
build/x86_64-unknown-linux-gnu/stage1-tools-bin/rustfmt
build/x86_64-unknown-linux-gnu/stage0/share/doc/rustfmt
build/x86_64-unknown-linux-gnu/stage0/bin/rustfmt
build/tmp-rustbuild-tests/main/tmp/tarball/rustfmt
build/tmp-rustbuild-tests/main/tmp/tarball/rustfmt/B/image/share/doc/rustfmt

Then in a project using this toolchain via a rustup link:

$ cargo fmt
error: 'cargo-fmt' is not installed for the toolchain 'yk-stage1'
note: this is a custom toolchain, which cannot use `rustup component add`
help: if you built this toolchain from source, and used `rustup toolchain link`, then you may be able to build the component with `x.py`                                                                           

But note that cp build/x86_64-unknown-linux-gnu/stage1-tools-bin/rustfmt build/x86_64-unknown-linux-gnu/stage1/bin/rustfmt does not make this work either, so there is probably more to it?

Thanks

@vext01
Copy link
Contributor Author

vext01 commented Jan 28, 2021

[removed comment, wrong issue, sorry]

@camelid
Copy link
Member

camelid commented Feb 1, 2021

(I think you posted that comment in the wrong place.)

@camelid camelid 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 Feb 1, 2021
@vext01
Copy link
Contributor Author

vext01 commented Feb 22, 2021

Oops, yes.

@vext01
Copy link
Contributor Author

vext01 commented Mar 30, 2021

Can anyone comment on what the correct fix for this might be?

I notice that if I copy cargo-clippy and clippy-driver from stage1-tools-bin/ into stage1/bin then I'm able to run cargo clippy via the linked toolchain.

I initially considered changing rustup to add stage1-tools-bin to the PATH, but that seems incorrect as we would be adding something outside of the toolchain root to PATH.

So should x.py copy or move the binaries from stage1-tools-bin into stage1/bin?

I'm willing to (attempt to) do the work if we can agree on what the correct fix is.

@camelid
Copy link
Member

camelid commented Mar 30, 2021

Can anyone comment on what the correct fix for this might be?

I'm not really knowledgeable about x.py. You might want to ask in #t-compiler on Zulip.

@jyn514
Copy link
Member

jyn514 commented Sep 19, 2022

So should x.py copy or move the binaries from stage1-tools-bin into stage1/bin?

Yes, it should copy the binaries from stage1-tools-bin to stage1/bin.

@jyn514 jyn514 added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Sep 19, 2022
@jyn514
Copy link
Member

jyn514 commented Sep 19, 2022

Mentoring instructions: Add a new argument to the bootstrap_tool macro that says whether the tool should be added to the sysroot, then copy it into the sysroot just after

rust/src/bootstrap/tool.rs

Lines 223 to 224 in 4a7e2fb

let bin = builder.tools_dir(compiler).join(exe(tool, target));
builder.copy(&cargo_out, &bin);

@jyn514 jyn514 added the E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. label Sep 19, 2022
@WaffleLapkin
Copy link
Member

I believe this will be fixed by #102010, once we figure out some problems with clippy/fmt builds.

@onur-ozkan
Copy link
Member

@rustbot claim

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. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
5 participants