rust-lang / rust-lang/rust

`rustc-LLVM ERROR: Cannot select` with `-C code-model=large`

Open
#138,899 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-LLVM C-bug E-needs-mcve I-ICE O-x86_32 T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Unfortunately this is far from an MRE, but I wanted to report it anyway in case anyone else has the same problem.

Code

uv in https://github.com/astral-sh/uv at ae880c6d48671fbe84d304d3f86b9666ee89ad54

When compiling in CI in a 32-bit docker container, we were experiencing out-of-memory errors ("rustc-LLVM ERROR: out of memory" - the build was using more than 4GB of RAM), so we tried adding -C code-model=large to reduce the memory usage. Doing so, we instead got an error with llvm internals when compiling the final binary (https://github.com/astral-sh/uv/actions/runs/14040533118/job/39309313189):

# Start a 32-bit docker container
$ docker run -it --rm -v $(pwd):/io quay.io/pypa/manylinux2014_i686:latest
# Install Rust
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Compie the program
$ cargo rustc --release --features self-update --bin uv -p uv -- -Ccode-model=large
[...]
rustc-LLVM ERROR: Cannot select: 0x876befa0: i32,ch = load<(load (s64) from jump-table, align 4), sext from i64> 0x99d77300, 0x876bef50, undef:i32
  0x876bef50: i32 = add 0x876be690, 0x876bed70
    0x876be690: i32 = shl 0x876e0910, Constant:i8<3>
      0x876e0910: i32,ch = CopyFromReg 0x99d77300, Register:i32 %27
        0x876beb90: i32 = Register %27
      0x876e01e0: i8 = Constant<3>
    0x876bed70: i32 = add X86ISD::GlobalBaseReg:i32, 0x876be230
      0x876bee10: i32 = X86ISD::GlobalBaseReg
      0x876be230: i32 = X86ISD::Wrapper TargetJumpTable:i32<0> [TF=4]
        0x876e0dc0: i32 = TargetJumpTable<0> [TF=4]
  0x876bea00: i32 = undef
In function: _ZN10axoupdater7release16get_release_list28_$u7b$$u7b$closure$u7d$$u7d$17hf4e3434edf50ffdeE
Meta

rustc --version --verbose:

rustc 1.85.1 (4eb161250 2025-03-15)
binary: rustc
commit-hash: 4eb161250e340c8f48f66e2b929ef4a5bed7c181
commit-date: 2025-03-15
host: i686-unknown-linux-gnu
release: 1.85.1
LLVM version: 19.1.7
Error output
rustc-LLVM ERROR: Cannot select: 0x876befa0: i32,ch = load<(load (s64) from jump-table, align 4), sext from i64> 0x99d77300, 0x876bef50, undef:i32
  0x876bef50: i32 = add 0x876be690, 0x876bed70
    0x876be690: i32 = shl 0x876e0910, Constant:i8<3>
      0x876e0910: i32,ch = CopyFromReg 0x99d77300, Register:i32 %27
        0x876beb90: i32 = Register %27
      0x876e01e0: i8 = Constant<3>
    0x876bed70: i32 = add X86ISD::GlobalBaseReg:i32, 0x876be230
      0x876bee10: i32 = X86ISD::GlobalBaseReg
      0x876be230: i32 = X86ISD::Wrapper TargetJumpTable:i32<0> [TF=4]
        0x876e0dc0: i32 = TargetJumpTable<0> [TF=4]
  0x876bea00: i32 = undef
In function: _ZN10axoupdater7release16get_release_list28_$u7b$$u7b$closure$u7d$$u7d$17hf4e3434edf50ffdeE

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported cargo rustc --release --features self-update --bin uv -p uv -- -Ccode-model=large build in the i686-unknown-linux-gnu Docker environment with Rust 1.85.1. Investigate the X86 jump-table code-generation failure shown in the LLVM error and work toward a smaller reproducer; done means the compiler no longer aborts with Cannot select for the case.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.