Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linker Problem following the example #12

Closed
mwbryant opened this issue Jul 19, 2020 · 5 comments · Fixed by rust-lang/rust#74631
Closed

Linker Problem following the example #12

mwbryant opened this issue Jul 19, 2020 · 5 comments · Fixed by rust-lang/rust#74631

Comments

@mwbryant
Copy link

I'm new to the rust embedded world and I am trying to get the example provided in the docs working. After running xargo rustc --target msp430-none-elf -- -C link-arg=-nostartfiles -C link-arg=-Tlink.x I get the error:

Compiling mymsp v0.1.0 (/home/matthew/personalProjects/rust/msp/mymsp)
error: linking with `msp430-elf-gcc` failed: exit code: 1
  |
  = note: "msp430-elf-gcc" "-Wl,--eh-frame-hdr" "-L" "/home/matthew/.xargo/lib/rustlib/msp430-none-elf/lib" "/home/matthew/personalProjects/rust/msp/mymsp/target/msp430-none-elf/debug/deps/mymsp-5e8f1dc7e4a97be6.17zmi0j3rsei05y0.rcgu.o" "-o" "/home/matthew/personalProjects/rust/msp/mymsp/target/msp430-none-elf/debug/deps/mymsp-5e8f1dc7e4a97be6" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "/home/matthew/personalProjects/rust/msp/mymsp/target/msp430-none-elf/debug/deps" "-L" "/home/matthew/personalProjects/rust/msp/mymsp/target/debug/deps" "-L" "/home/matthew/personalProjects/rust/msp/mymsp/target/msp430-none-elf/debug/build/msp430-rt-1543454d2d69ddf3/out" "-L" "/home/matthew/.xargo/lib/rustlib/msp430-none-elf/lib" "-Wl,--start-group" "-Wl,-Bstatic" "/home/matthew/personalProjects/rust/msp/mymsp/target/msp430-none-elf/debug/deps/libpanic_msp430-009ff554b3c69afe.rlib" "/home/matthew/personalProjects/rust/msp/mymsp/target/msp430-none-elf/debug/deps/libmsp430_rt-b547c370e166624e.rlib" "/home/matthew/personalProjects/rust/msp/mymsp/target/msp430-none-elf/debug/deps/libr0-077d58e20f73b032.rlib" "/home/matthew/personalProjects/rust/msp/mymsp/target/msp430-none-elf/debug/deps/libmsp430-c6aa6fbcc43ff67f.rlib" "/home/matthew/personalProjects/rust/msp/mymsp/target/msp430-none-elf/debug/deps/libbare_metal-5d885d7e97dad07e.rlib" "/home/matthew/.xargo/lib/rustlib/msp430-none-elf/lib/libcore-f34c7f19eb54f014.rlib" "-Wl,--end-group" "/home/matthew/.xargo/lib/rustlib/msp430-none-elf/lib/libcompiler_builtins-735d55bb87ed4287.rlib" "-nostartfiles" "-Tlink.x" "-Wl,-Bdynamic"
  = note: /opt/msp430-gcc/bin/../lib/gcc/msp430-elf/9.2.0/../../../../msp430-elf/bin/ld: unrecognized option '--eh-frame-hdr'
          /opt/msp430-gcc/bin/../lib/gcc/msp430-elf/9.2.0/../../../../msp430-elf/bin/ld: use the --help option for usage information
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error

error: could not compile `mymsp`.

To learn more, run the command again with --verbose.

As far as I can tell this flag is not supported by msp430-elf-gcc but I also cannot find what code is adding this flag so I could attempt to remove it.

My msp430-elf-gcc --version is:

msp430-elf-gcc (Mitto Systems Limited - msp430-gcc 9.2.0.50) 9.2.0

My active toolchain is:

nightly-x86_64-unknown-linux-gnu (default)
rustc 1.46.0-nightly (346aec9b0 2020-07-11)
@cr1901
Copy link
Contributor

cr1901 commented Jul 19, 2020

This is due to PR #73564 in Rust upstream. A potential fix would look something like this PR. It's a non-invasive fix, but I still will need to check locally, and I won't be able to do this myself for at least a few days.

I recommend as a stopgap to install a recent nightly, but from about, say, a month ago:

rustup install nightly-YYYY-MM-DD
rustup override set nightly-YYYY-MM-DD /path/to/msp430/crates

@petrochenkov
Copy link

Fixed in rust-lang/rust#74631.

@cr1901
Copy link
Contributor

cr1901 commented Jul 22, 2020

@petrochenkov Awesome! Thank you for saving me the trouble :D!

Manishearth added a commit to Manishearth/rust that referenced this issue Jul 22, 2020
rustc_target: Add a target spec option for disabling `--eh-frame-hdr`

Disable `--eh-frame-hdr` for targets that use an `ld`-like linker, but don't support that option.
Do it through a target spec option rather than through hard-coding in `linker.rs`.
The option is still enabled by default though.

cc rust-lang#73564
Fixes rust-lang#73564 (comment)
Fixes rust-lang#74625
Fixes rust-embedded/msp430-rt#12
Manishearth added a commit to Manishearth/rust that referenced this issue Jul 22, 2020
rustc_target: Add a target spec option for disabling `--eh-frame-hdr`

Disable `--eh-frame-hdr` for targets that use an `ld`-like linker, but don't support that option.
Do it through a target spec option rather than through hard-coding in `linker.rs`.
The option is still enabled by default though.

cc rust-lang#73564
Fixes rust-lang#73564 (comment)
Fixes rust-lang#74625
Fixes rust-embedded/msp430-rt#12
Manishearth added a commit to Manishearth/rust that referenced this issue Jul 22, 2020
rustc_target: Add a target spec option for disabling `--eh-frame-hdr`

Disable `--eh-frame-hdr` for targets that use an `ld`-like linker, but don't support that option.
Do it through a target spec option rather than through hard-coding in `linker.rs`.
The option is still enabled by default though.

cc rust-lang#73564
Fixes rust-lang#73564 (comment)
Fixes rust-lang#74625
Fixes rust-embedded/msp430-rt#12
Manishearth added a commit to Manishearth/rust that referenced this issue Jul 22, 2020
rustc_target: Add a target spec option for disabling `--eh-frame-hdr`

Disable `--eh-frame-hdr` for targets that use an `ld`-like linker, but don't support that option.
Do it through a target spec option rather than through hard-coding in `linker.rs`.
The option is still enabled by default though.

cc rust-lang#73564
Fixes rust-lang#73564 (comment)
Fixes rust-lang#74625
Fixes rust-embedded/msp430-rt#12
Manishearth added a commit to Manishearth/rust that referenced this issue Jul 22, 2020
rustc_target: Add a target spec option for disabling `--eh-frame-hdr`

Disable `--eh-frame-hdr` for targets that use an `ld`-like linker, but don't support that option.
Do it through a target spec option rather than through hard-coding in `linker.rs`.
The option is still enabled by default though.

cc rust-lang#73564
Fixes rust-lang#73564 (comment)
Fixes rust-lang#74625
Fixes rust-embedded/msp430-rt#12
@cr1901
Copy link
Contributor

cr1901 commented Jul 25, 2020

@mwbryant This should be fixed now. Can you please confirm and close?

@stianeklund
Copy link

stianeklund commented Jul 26, 2020

Compiles just fine on nightly-2020-07-26.

Some notes from some problems I had while getting this & other projects for msp430 to compile:

  1. Make sure to install the latest nightly 2020-07-26. Can be installed with: rustup install nightly-2020-07-26 --profile=minimal
  2. Set new nightly to default: rustup default nightly-2020-07-26 verify with rustup show
  3. Might need to add rust-src, rustup component add rust-src
  4. Make sure to disable LTO (link time optimization) if set in Cargo.toml this caused issues for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants