Skip to content

The LLVM we ship in rust-dev doesn't match the LLVM we ship in the rustc component #110474

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
jyn514 opened this issue Apr 18, 2023 · 10 comments · Fixed by #110490
Closed

The LLVM we ship in rust-dev doesn't match the LLVM we ship in the rustc component #110474

jyn514 opened this issue Apr 18, 2023 · 10 comments · Fixed by #110490
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@jyn514
Copy link
Member

jyn514 commented Apr 18, 2023

I tried this code:

; rustc +stage2 --print=target-spec-json --target loongarch64-unknown-linux-gnu -Zunstable-options

I expected to see this happen: rustc prints the target spec successfully, because it knows it exists:

; rustc +stage2 --print=target-list | grep loong
loongarch64-unknown-linux-gnu

Instead, this happened: rustc fails to load the LLVM specification:

; rustc +stage2 --print=target-spec-json --target loongarch64-unknown-linux-gnu -Zunstable-options
error: could not create LLVM TargetMachine for triple: loongarch64-unknown-linux-gnu: No available targets are compatible with triple "loongarch64-unknown-linux-gnu"

Note that this is different from the error we emit for an unrecognized target:

; rustc +stage2 --print=target-spec-json --target unknown -Zunstable-options
error: Error loading target specification: Could not find specification for target "unknown". Run `rustc --print target-list` for a list of built-in targets

Also, this only happens for local builds, because we don't use the LLVM in the rust-dev component in rustup, only when building rustc from source.

... wtf ???

Meta

HEAD is branched from ce1073b

@jyn514 jyn514 added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) C-bug Category: This is a bug. labels Apr 18, 2023
@jyn514
Copy link
Member Author

jyn514 commented Apr 18, 2023

cc @zhaixiaojuan @heiher, do you know what could be going wrong here?

@heiher
Copy link
Contributor

heiher commented Apr 18, 2023

@jyn514 Thank you for bringing this to my attention. It is possible that the locally builds has enabled llvm.download-ci-llvm, and that prebuilt LLVM does not support LoongArch architecture. It would be great if you could provide specific steps to reproduce. Thank you.

@jyn514
Copy link
Member Author

jyn514 commented Apr 18, 2023

Yes, that's exactly what's happened, I have download-ci-llvm enabled and the prebuilt LLVM differs.

Here's steps to reproduce:

rm config.toml  # download-ci-llvm is on by default
x build --stage 0 rustc
build/host/stage1/bin/rustc --print=target-spec-json --target loongarch64-unknown-linux-gnu -Zunstable-options

@jyn514
Copy link
Member Author

jyn514 commented Apr 18, 2023

The RustDev component builds LLVM here:

builder.ensure(crate::llvm::Llvm { target });

but I'm not sure how that differs from the Rustc component?

rust/src/bootstrap/dist.rs

Lines 456 to 461 in 276fa29

// Copy libLLVM.so to the lib dir as well, if needed. While not
// technically needed by rustc itself it's needed by lots of other
// components like the llvm tools and LLD. LLD is included below and
// tools/LLDB come later, so let's just throw it in the rustc
// component for now.
maybe_install_llvm_runtime(builder, host, image);

@heiher
Copy link
Contributor

heiher commented Apr 18, 2023

I think the difference is that the llvm.targets of ci-llvm does not contain LoongArch, but locally it does. Is it time to update ci-llvm?

@nikic
Copy link
Contributor

nikic commented Apr 18, 2023

Maybe need to bump download-ci-llvm-stamp to pick up the LoongArch enablement?

@heiher
Copy link
Contributor

heiher commented Apr 18, 2023

@jyn514 @nikic Thank you for catching that. I was mistaken to think that the cached prebuilt ci-llvm would automatically update over time.

@jyn514
Copy link
Member Author

jyn514 commented Apr 18, 2023

@heiher no worries :) it updates every six weeks when we make a new release, or if the submodule is updated, but it's cached until then so it's not constantly re-uploaded on every change to bootstrap.

@RalfJung
Copy link
Member

Is there any way CI could help prevent such problems? Like, complain if compiler/rustc_llvm gets changed but the stamp file does not, or something like that?

@jyn514
Copy link
Member Author

jyn514 commented Apr 20, 2023

@RalfJung we can use heuristics, but they're only heuristics and I wouldn't want to fail CI on them. That said, having rustbot leave a comment if you touch rustc_llvm or src/bootstrap/llvm.rs seems reasonable, so the PR author can make a judgement call but also doesn't forget about the stamp.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 17, 2023
…acrum

Suggest bumping download-ci-llvm-stamp if the build config for llvm changes

This will hopefully avoid issues like rust-lang#110474 where the uploaded `rust-dev` component doesn't match the one you'd get if you built LLVM from source.

cc rust-lang#110474 (comment)
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 17, 2023
…acrum

Suggest bumping download-ci-llvm-stamp if the build config for llvm changes

This will hopefully avoid issues like rust-lang#110474 where the uploaded `rust-dev` component doesn't match the one you'd get if you built LLVM from source.

cc rust-lang#110474 (comment)
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 17, 2023
…acrum

Suggest bumping download-ci-llvm-stamp if the build config for llvm changes

This will hopefully avoid issues like rust-lang#110474 where the uploaded `rust-dev` component doesn't match the one you'd get if you built LLVM from source.

cc rust-lang#110474 (comment)
RalfJung pushed a commit to RalfJung/miri that referenced this issue Jun 18, 2023
Suggest bumping download-ci-llvm-stamp if the build config for llvm changes

This will hopefully avoid issues like rust-lang/rust#110474 where the uploaded `rust-dev` component doesn't match the one you'd get if you built LLVM from source.

cc rust-lang/rust#110474 (comment)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants