Closed
Description
openedon Jan 7, 2023
(Downstream issue: Rahix/avr-hal#388)
A bug was introduced in #103240 (5642a75) when compiling for AVR targets, causing errors in linking which look like:
error: linking with `avr-gcc` failed: exit status: 1
|
= note: "avr-gcc" "-mmcu=attiny404" "/tmp/rustcmivxhx/symbols.o" "/home/goose/dev/hwlife/life-cell/firmware/target/avr-attiny404/debug/deps/life_cell-6668cd99ba2eaeff.avrxmega_hal-cc404b4688795bef.avrxmega_hal.d6125529-cgu.0.rcgu.o.rcgu.o" "-Wl,--as-needed" "-L" "/home/goose/dev/hwlife/life-cell/firmware/target/avr-attiny404/debug/deps" "-L" "/home/goose/dev/hwlife/life-cell/firmware/target/debug/deps" "-L" "/home/goose/build/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/avr-attiny404/lib" "-Wl,-Bstatic" "/home/goose/dev/hwlife/life-cell/firmware/target/avr-attiny404/debug/deps/libcompiler_builtins-dfbc3c77452aecc4.rlib" "-Wl,-Bdynamic" "-lgcc" "-Wl,-znoexecstack" "-L" "/home/goose/build/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/avr-attiny404/lib" "-o" "/home/goose/dev/hwlife/life-cell/firmware/target/avr-attiny404/debug/deps/life_cell-6668cd99ba2eaeff.elf" "-Wl,--gc-sections" "-no-pie"
= note: /usr/lib/arduino/hardware/tools/avr/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld: avr architecture of input file `/tmp/rustcmivxhx/symbols.o' is incompatible with avr:103 output
collect2: error: ld returned 1 exit status
The PR in question added support for AVR architecture in create_object_file
, but it doesn't actually make the necessary changes to set the e_flags
field, which is used to specify the AVR ISA revision. As a knock-on-effect, this causes add_linked_symbol_object
to avoid an early return and succeed in creating a symbols.o
file, but this object file doesn't have e_flags
set correctly.
I believe that is the cause of this error; the AVR linker checks the e_flags
field to make sure the ISA revision matches what is expected, and rustc is not setting that field correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment