Skip to content

Undefined reference in unchecked_shl function when compiling in release mode for thumbv4t-none-eabi #108893

Closed
@gwilymk

Description

@gwilymk

Since the nightly version released on the 28th February, we've been getting a build failure for agb (https://github.com/agbrs/agb) relating to undefined reference to <T as core::convert::TryInto<U>>::try_into in core::num::<impl u32>::unchecked_shl

Code

If you build the text_render example in the agb directory as follows:

$ cargo build --example=text_render

it works correctly, but if you do so in release mode, you get

$ cargo build --example=text_render --release
<lots of output>
  = note: arm-none-eabi-ld: /home/gwilym/Projects/agb/agb/target/thumbv4t-none-eabi/release/deps/libcompiler_builtins-59056e9a57a3f920.rlib(compiler_builtins-59056e9a57a3f920.compiler_builtins.12b6ae5a-cgu.3.rcgu.o): in function `core::num::<impl u32>::unchecked_shl':
          /home/gwilym/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/uint_macros.rs:942: undefined reference to `<T as core::convert::TryInto<U>>::try_into'

Note that you'll need arm-none-eabi-binutils installed since we use the arm-none-eabi-ld linker and the assembler.

I tried some smaller examples, but couldn't work out how to trigger this smaller since it seems to be optimisation related? Let me know if I can do further research for this.

Version it worked on

The nightly version before the 28th February (we know this is the exact build it failed on because we run the build daily (https://github.com/agbrs/agb/actions/workflows/build-and-test.yml)

Installing an older nightly version fixes the issue:

rustc --version --verbose
rustc 1.69.0-nightly (d962ea578 2023-02-26)
binary: rustc
commit-hash: d962ea57899d64dc8a57040142c6b498a57c8064
commit-date: 2023-02-26
host: x86_64-unknown-linux-gnu
release: 1.69.0-nightly
LLVM version: 15.0.7

Version with regression

It fails on the most recent nightly, but the first version it doesn't work on is provided below:

rustc --version --verbose:

rustc 1.69.0-nightly (7281249a1 2023-02-27)
binary: rustc
commit-hash: 7281249a19a9755e9d889ee251ec323629caadab
commit-date: 2023-02-27
host: x86_64-unknown-linux-gnu
release: 1.69.0-nightly
LLVM version: 15.0.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    -Zbuild-stdUnstable Cargo option: Compile the standard library yourself.C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-untriagedUntriaged performance or correctness regression.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions