Skip to content

Missing rust_begin_unwind symbol for msp430 (debug-only?) builds #102290

Description

@cr1901

Code

Instructions

  1. Make sure the msp430-elf-gcc toolchain is installed. Optionally install just for convenience.
  2. git clone https://github.com/cr1901/msp430-size. Use commit 036da7a specifically.
  3. Install any rust nightly after 2022-09-08 (I am using 2022-09-21/9062b780b32d2eab060b4432863e085d9504ca5c for the error below).
  4. Run the following command:
    cargo +override-name rustc --manifest-path=./test-cases/Cargo.toml --target=msp430-none-elf -Zbuild-std=core --features=unsafe -- --emit=obj=target/msp430-none-elf/debug/test-cases.o,llvm-ir=target/msp430-none-elf/debug/test-cases.ll,asm=target/msp430-none-elf/debug/test-cases.s

With a working compiler (I used 2022-08-10/34a6cae28e7013ff0e640026a8e46f315426829d for this example), I expect compilation to succeed:

   Compiling test-cases v0.1.0 (/home/william/Projects/embedded/msp430/msp430-size/test-cases)
warning: unused import: `interrupt as mspint`
  --> test-cases/src/main.rs:10:15
   |
10 | use msp430::{{interrupt as mspint}, interrupt::CriticalSection};
   |               ^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: `test-cases` (bin "test-cases") generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 0.20s

Instead, I get a link error about a missing rust_begin_unwind symbol, and cannot link any code that doesn't optimize it out (so everything with opt-level=0 and sometimes higher opt-levels?):

Compiling test-cases v0.1.0 (/home/william/Projects/embedded/msp430/msp430-size/test-cases)
warning: unused import: `interrupt as mspint`
  --> test-cases/src/main.rs:10:15
   |
10 | use msp430::{{interrupt as mspint}, interrupt::CriticalSection};
   |               ^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

error: linking with `msp430-elf-gcc` failed: exit status: 1
  |
  = note: "msp430-elf-gcc" "/home/william/Projects/embedded/msp430/msp430-size/target/msp430-none-elf/debug/deps/test_cases-77e7fc9bffc4f0a7.s693teeolgqnrfj.rcgu.o" "-L" "/home/william/Projects/embedded/msp430/msp430-size/target/msp430-none-elf/debug/deps" "-L" "/home/william/Projects/embedded/msp430/msp430-size/target/debug/deps" "-L" "/home/william/Projects/embedded/msp430/msp430-size/target/msp430-none-elf/debug/build/test-cases-3f682f73842f7eb2/out" "-L" "/home/william/Projects/embedded/msp430/msp430-size/target/msp430-none-elf/debug/build/msp430-rt-b95e8a1acafa0902/out" "-L" "/home/william/Projects/embedded/msp430/msp430-size/target/msp430-none-elf/debug/build/msp430g2553-3b2ab7604a829bcc/out" "-L" "/home/william/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/msp430-none-elf/lib" "-Wl,-Bstatic" "/home/william/Projects/embedded/msp430/msp430-size/target/msp430-none-elf/debug/deps/libmsp430g2553-ffaf04726949f42c.rlib" "/home/william/Projects/embedded/msp430/msp430-size/target/msp430-none-elf/debug/deps/libvcell-d1c6da43e237512b.rlib" "/home/william/Projects/embedded/msp430/msp430-size/target/msp430-none-elf/debug/deps/libmsp430_rt-10b834e6ef56ed17.rlib" "/home/william/Projects/embedded/msp430/msp430-size/target/msp430-none-elf/debug/deps/libcfg_if-092783056b17116d.rlib" "/home/william/Projects/embedded/msp430/msp430-size/target/msp430-none-elf/debug/deps/libpanic_msp430-f198507bed824f51.rlib" "/home/william/Projects/embedded/msp430/msp430-size/target/msp430-none-elf/debug/deps/libmsp430-e970b409efe93be8.rlib" "/home/william/Projects/embedded/msp430/msp430-size/target/msp430-none-elf/debug/deps/libcritical_section-7116d7524c9bc4b8.rlib" "/home/william/Projects/embedded/msp430/msp430-size/target/msp430-none-elf/debug/deps/librustc_std_workspace_core-a9d0ab60345003e9.rlib" "/home/william/Projects/embedded/msp430/msp430-size/target/msp430-none-elf/debug/deps/libcore-7b26ee1f55864a47.rlib" "/home/william/Projects/embedded/msp430/msp430-size/target/msp430-none-elf/debug/deps/libcompiler_builtins-3594f08dc3904fc7.rlib" "-Wl,-Bdynamic" "-L" "/home/william/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/msp430-none-elf/lib" "-o" "/home/william/Projects/embedded/msp430/msp430-size/target/msp430-none-elf/debug/deps/test_cases-77e7fc9bffc4f0a7" "-nodefaultlibs" "-Tlink.x" "-nostartfiles" "-mcpu=msp430" "-lmul_none" "-lgcc"
  = note: /home/william/.local/bin/../lib/gcc/msp430-elf/9.2.0/../../../../msp430-elf/bin/ld: /home/william/Projects/embedded/msp430/msp430-size/target/msp430-none-elf/debug/deps/libcore-7b26ee1f55864a47.rlib(core-7b26ee1f55864a47.core.a947c771-cgu.0.rcgu.o): in function `core::panicking::panic_fmt':
          /home/william/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panicking.rs:142: undefined reference to `rust_begin_unwind'
          collect2: error: ld returned 1 exit status
          
  = help: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

warning: `test-cases` (bin "test-cases") generated 1 warning
error: could not compile `test-cases` due to previous error; 1 warning emitted
error: Recipe `build-example` failed with exit code 101

The msp430-none-elf target doesn't support unwinding (and I don't imagine it ever will), only aborting panics. So I'm not sure why rust_begin_unwind is being linked in in the first place (or how compilation should be fixed).

cargo-bisect-rustc output (Version it worked on/Version with regression)

searched nightlies: from nightly-2022-08-07 to nightly-2022-09-21
regressed nightly: nightly-2022-09-08
searched commits: from 78a891d to c2804e6
regressed commit: 699bfa8

bisected with cargo-bisect-rustc v0.6.0

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --preserve-target --preserve --start=2022-08-07 --end=2022-09-21 --with-src -- build -Zbuild-std=core --target=msp430-none-elf --features=unsafe 

No activity

Activity on this issue will appear here.

Activity

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

    C-bugCategory: This is a bug.O-msp430P-mediumMedium priorityregression-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