Skip to content

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

Closed

Description

@jyn514

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

Activity

  1. added
    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
    T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
    C-bugCategory: This is a bug.
    on Apr 18, 2023
  2. jyn514 commented on Apr 18, 2023

    @jyn514
    MemberAuthor

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

  3. heiher commented on Apr 18, 2023

    @heiher
    Contributor

    @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.

  4. jyn514 commented on Apr 18, 2023

    @jyn514
    MemberAuthor

    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
    
  5. jyn514 commented on Apr 18, 2023

    @jyn514
    MemberAuthor

    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);

  6. heiher commented on Apr 18, 2023

    @heiher
    Contributor

    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?

  7. nikic commented on Apr 18, 2023

    @nikic
    Contributor

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

  8. added a commit that references this issue on Apr 18, 2023
  9. heiher commented on Apr 18, 2023

    @heiher
    Contributor

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

  10. jyn514 commented on Apr 18, 2023

    @jyn514
    MemberAuthor

    @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.

  11. RalfJung commented on Apr 20, 2023

    @RalfJung
    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?

  12. jyn514 commented on Apr 20, 2023

    @jyn514
    MemberAuthor

    @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.

  13. added 3 commits that reference this issue on Jun 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions