Curiously Chase

Rust Error for mach-o section specifier requires a segment and section separated by comma

How to fix a Rust embed error "LLVM ERROR: Global variable '__INTERRUPTS' has an invalid section specifier '.vector_table.interrupts': mach-o section specifier requires a segment and section separated by a comma.error: could not compile `rp2040-pac` (lib)

Lately I've been learning Rust and Embedded Programming at the same time.

When attempting to build a binary for my Adafruit Macropad I kept getting this error:

LLVM ERROR: Global variable '__INTERRUPTS' has an invalid section specifier '.vector_table.interrupts': mach-o section specifier requires a segment and section separated by a comma.
error: could not compile `rp2040-pac` (lib)

The solution is a real face palm...

My .cargo/config was in my src directory and not my project root.

That meant that anytime I ran cargo run --release it didn't find a config to target my device, so it was building the binary for MacOS.

Solution

Make sure that you have your Rust .cargo/config for any of the embedded projects you're doing at your project root and not somewhere else in the tree.

I hope this saves you ton of head scratching. 🤦‍♂️

Share on Twitter