-
Notifications
You must be signed in to change notification settings - Fork 85
empty thumb binary on macOS with 1.31.0 to 1.41.1 #251
Comments
Update: I had a stale environment variable in my shell. Specifically,
Woo-hoo! Thanks to @jonas-schievink for the hint! Now, to prevent future foot guns, could I get a "WARN: $RUSTFLAGS overrides .cargo/config" ? |
I tried to make cortex-m-rt detect this, by having The best way to fix this would be via proper |
Well, imho, this needs to happen in the toolchain: if RUSTFLAGS is set and .cargo/config exists, throw an error. There's no valid use case for both, right? |
That seems to be tracked in rust-lang/cargo#5376, but that looks stalled. |
I tried doing some linker trickery to detect this mistake, but couldn't find any way to do it so far. One remaining idea: Put a function that refers to an undefined symbol into a section used only by the default linker script. When linking with the correct linker script, the function will be disposed and the program doesn't fail to link. (This is basically the opposite of what I tried and failed to do earlier). |
Ah, I don't think there is a default linker script since Rust links with LLD directly instead of calling a driver like GCC. Oh well. |
Closing as wontfix/upstream issue, as per the discussion above. |
All,
I'm walking through the Rust Embedded Discovery book to familiarize myself with how Rust on microcontrollers works. I'm on a MacBook Pro with macOS 10.15.3 (Catalina) and up-to-date MacPorts for
arm-none-eabi-{gcc,gdb,binutils}
. Both OpenOCD and arm-none-eabi-gdb run fine and communicate. I first detected the error in Chapter 05, when I attempted toload
the first binary built. I got the following result:Diagnosis in #rust-embedded on Matrix revealed the following:
So, I repeated the book in my Gentoo Linux VM, and received sane results. IOW, it looks like a bug in Rust on macOS.
I'm using
rustup
to install Rust, on vanilla macOS, latest MacPorts, and I'm using the source repository for the Discovery book: https://github.com/rust-embedded/discoveryI've tried every major version of Rust from 1.31.0 through 1.41.1 with similar results. Copying the binary to my Linux system yield the same output
You can see above that I get a sane build product on Linux, but the binary from macOS (in my home directory) is obviously not right.
I've no idea how to further debug this as I'm relatively new to Rust. I'm hoping that someone on macOS can reproduce this (you don't need the board, openocd, or gdb to test). and dig in a little further.
STR:
If you use
cargo readobj ...
, here's the difference between a good binary (built on Linux) and a bad binary (built on macOS)The text was updated successfully, but these errors were encountered: