avr-rust / book.avr-rust.com

The AVR-Rust guidebook
https://book.avr-rust.com/
Other
73 stars 19 forks source link

Installing required third party tools from source #17

Closed jonahbron closed 3 years ago

jonahbron commented 3 years ago

This section in the book works great in most cases, but I'm on Clear Linux and have neither of those package managers available.

https://book.avr-rust.com/002.1-installing-required-third-party-tools.html#21-installing-required-third-party-tools

Instructions on how to install manually would be nice. I downloaded the official AVR toolchain from Microchip:

https://www.microchip.com/mplab/avr-support/avr-and-arm-toolchains-c-compilers

But when I run cargo build, it seems that it's trying to use a flag not supported by the version of ld provided in the official AVR toolchain.

error: linking with `avr-gcc` failed: exit code: 1
  |
  = note: "avr-gcc" "-Os" "-mmcu=atmega328p" "-Wl,--eh-frame-hdr" "-L" "/home/jonah/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/avr-atmega328p/lib" "/run/media/jonah/data/Projects/smart-plug/target/avr-atmega328p/release/deps/smart_plug-12f5bd55c8f99728.smart_plug.davrc7f1-cgu.0.rcgu.o" "-o" "/run/media/jonah/data/Projects/smart-plug/target/avr-atmega328p/release/deps/smart_plug-12f5bd55c8f99728.elf" "-Wl,--gc-sections" "-L" "/run/media/jonah/data/Projects/smart-plug/target/avr-atmega328p/release/deps" "-L" "/run/media/jonah/data/Projects/smart-plug/target/release/deps" "-L" "/home/jonah/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/avr-atmega328p/lib" "-Wl,--start-group" "-Wl,--end-group" "-Wl,-Bstatic" "/run/media/jonah/data/Projects/smart-plug/target/avr-atmega328p/release/deps/libcompiler_builtins-3056cbb15200d16d.rlib" "-Wl,-Bdynamic" "-Wl,--gc-sections"
  = note: /home/jonah/Downloads/avr8-gnu-toolchain-3.6.2.1759-linux.any.x86_64/avr8-gnu-toolchain-linux_x86_64/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld: unrecognized option '--eh-frame-hdr'
          /home/jonah/Downloads/avr8-gnu-toolchain-3.6.2.1759-linux.any.x86_64/avr8-gnu-toolchain-linux_x86_64/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld: use the --help option for usage information
          collect2: error: ld returned 1 exit status

Are there some additional instructions we could add, like how to remove that flag?

dylanmckay commented 3 years ago

In https://github.com/rust-lang/rust/pull/74631/files Rust got support for disabling --eh-frame-hdr flag via the "eh-frame-header": false target specification JSON option.

The blink example has this so that --eh-frame-hdr is not passed to the linker. My avr-gcc linker (Arch Linux) doesn't support the --eh-frame-hdr flag either (even though it is a very recent version of binutils). Here is the example in blink.

Good suggestion on adding distro-independent avr-gcc installation instructions. Raised #18.

This should be fixed by #10 when instructions for getting/creating a target specification JSON file are written.

jonahbron commented 3 years ago

Thanks @dylanmckay . Yeah updating yesterday evening fixed it, and it turned out my json file was also setting that flag. Fixing that fixed the problem. I'll open a PR for manual installation instructions.

jonahbron commented 3 years ago

Closing since you opened another ticket for the task.