Skip to content

non-pub function no longer compiled in debug profile, causing link errors on thumbv7em-none-eabihf with defmt #131164

Closed

Description

@jonathanpallant

Code

I tried this code:

$ git clone https://github.com/ferrous-systems/rust-exercises.git
$ cd rust-exercises
$ git checkout v1.17.0
$ cd nrf52_code/radio_app
$ rustup target add thumbv7em-none-eabihf --toolchain=nightly
$ cargo install flip-link (or change `.cargo/config.toml` to not use flip-link - either is fine)
$ cargo +nightly build

I expected to see this happen:

The binaries build like, they do on stable.

Instead, this happened:

  = note: rust-lld: error: /Users/jonathan/Documents/clients/training/open-rust-embedded-2024-10-02/rust-exercises-v1.17.0/nrf52-code/radio-app/target/thumbv7em-none-eabihf/debug/build/defmt-36a2ab5d209daca3/out/defmt.x:7: symbol not found: __defmt_default_panic
          rust-lld: error: /Users/jonathan/Documents/clients/training/open-rust-embedded-2024-10-02/rust-exercises-v1.17.0/nrf52-code/radio-app/target/thumbv7em-none-eabihf/debug/build/defmt-36a2ab5d209daca3/out/defmt.x:7: symbol not found: __defmt_default_panic
          rust-lld: error: /Users/jonathan/Documents/clients/training/open-rust-embedded-2024-10-02/rust-exercises-v1.17.0/nrf52-code/radio-app/target/thumbv7em-none-eabihf/debug/build/defmt-36a2ab5d209daca3/out/defmt.x:7: symbol not found: __defmt_default_panic
          rust-lld: error: /Users/jonathan/Documents/clients/training/open-rust-embedded-2024-10-02/rust-exercises-v1.17.0/nrf52-code/radio-app/target/thumbv7em-none-eabihf/debug/build/defmt-36a2ab5d209daca3/out/defmt.x:7: symbol not found: __defmt_default_panic

That symbol is defined here: https://github.com/knurling-rs/defmt/blob/b7a89f56059fc66ac3c7cc3445d092829599e699/defmt/src/lib.rs#L365

Bisect

@Dirbaio said:

searched nightlies: from nightly-2024-07-30 to nightly-2024-10-02
regressed nightly: nightly-2024-08-01
searched commit range: f8060d2...28a58f2
regressed commit: 0b5eb7b

That's the LLVM 19 upgrade.

Activity

  1. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Oct 2, 2024
  2. Dirbaio commented on Oct 2, 2024

    @Dirbaio
    Contributor

    it regressed both with and without --release.

  3. jonathanpallant commented on Oct 2, 2024

    @jonathanpallant
    ContributorAuthor

    I also ran a bisect:

    searched nightlies: from nightly-2024-07-01 to nightly-2024-10-02
    regressed nightly: nightly-2024-08-01
    searched commit range: f8060d2...28a58f2
    regressed commit: 0b5eb7b

  4. added
    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Oct 2, 2024
  5. apiraino commented on Oct 2, 2024

    @apiraino
    Contributor

    WG-prioritization assigning priority (Zulip discussion).

    I can also reproduce on current beta so tagging accordingly

    @rustbot label -I-prioritize +P-medium +regression-from-stable-to-beta

  6. added and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Oct 2, 2024
  7. added
    E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
    on Oct 2, 2024
  8. Dirbaio commented on Oct 2, 2024

    @Dirbaio
    Contributor

    minimized, zero deps -> https://github.com/Dirbaio/defmt-repro

    [dirbaio@mars defmt-repro]$ rustc --version
    rustc 1.83.0-nightly (06bb8364a 2024-10-01)
    [dirbaio@mars defmt-repro]$ cargo build
       Compiling radio_app v0.0.0 (/home/dirbaio/defmt-repro)
    error: linking with `rust-lld` failed: exit status: 1
      |
      = note: LC_ALL="C" PATH="/home/dirb(snip)47a" "--gc-sections" "-Tlol.x"
      = note: rust-lld: error: lol.x:1: symbol not found: __defmt_default_panic
              rust-lld: error: lol.x:1: symbol not found: __defmt_default_panic
              rust-lld: error: lol.x:1: symbol not found: __defmt_default_panic
    
    error: could not compile `radio_app` (bin "radio_app") due to 1 previous error
    [dirbaio@mars defmt-repro]$ rustc +stable --version
    rustc 1.81.0 (eeb90cda1 2024-09-04)
    [dirbaio@mars defmt-repro]$ cargo +stable build
        Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.06s
    
  9. Dirbaio commented on Oct 2, 2024

    @Dirbaio
    Contributor
  10. 32 remaining items

  11. Urhengulas commented on Oct 16, 2024

    @Urhengulas
    Contributor

    Upstream LLVM will not backport the relevant fixes, so I will add a test case.

    Do you think there is a chance that this "bug" will come back to us? We are currently evaluating if we should apply a fix/safeguard in defmt.

  12. dianqk commented on Oct 16, 2024

    @dianqk
    Member

    Upstream LLVM will not backport the relevant fixes, so I will add a test case.

    Do you think there is a chance that this "bug" will come back to us? We are currently evaluating if we should apply a fix/safeguard in defmt.

    No. The main branch of LLVM has fixed. The next major update will include it.

  13. Urhengulas commented on Oct 16, 2024

    @Urhengulas
    Contributor

    Upstream LLVM will not backport the relevant fixes, so I will add a test case.

    Do you think there is a chance that this "bug" will come back to us? We are currently evaluating if we should apply a fix/safeguard in defmt.

    No. The main branch of LLVM has fixed. The next major update will include it.

    Perfect!

  14. thejpster commented on Oct 16, 2024

    @thejpster
    Contributor

    Lgtm

  15. jannic commented on Oct 16, 2024

    @jannic
    Contributor

    Also tried with the stable prerelease from https://internals.rust-lang.org/t/rust-1-82-0-pre-release-testing/21705. Problem is solved.

  16. added a commit that references this issue on Oct 22, 2024
  17. added 2 commits that reference this issue on Oct 22, 2024
  18. added 2 commits that reference this issue on Oct 23, 2024
  19. added a commit that references this issue on Oct 23, 2024
  20. added a commit that references this issue on Oct 24, 2024
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.A-linkageArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.P-highHigh priorityS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions