Skip to content

cortex-m-rt Documentation: -nostartfiles linker option does not exist in rust-lld #610

@mfil

Description

@mfil

The doc comments in cortex-m-rt/src/lib.rs say that you should use the following command to compile: cargo rustc --target thumbv7m-none-eabi -- -C link-arg=-nostartfiles -C link-arg=-Tlink.x. For me, this produces the following error:

$ cargo rustc --target thumbv7em-none-eabi -- -C link-arg=-nostartfiles -C link-arg=-Tlink.x 
   Compiling cortex-m-rt v0.7.5
   Compiling cortex_m_rt_test v0.1.0 (/home/max/test/cortex_m_rt_test)
error: linking with `rust-lld` failed: exit status: 1
  |
  = note:  "rust-lld" "-flavor" "gnu" "/tmp/rustcrMK7jK/symbols.o" "<3 object files omitted>" "--as-needed" "-Bstatic" "/home/max/test/cortex_m_rt_test/target/thumbv7em-none-eabi/debug/deps/libcortex_m_rt-eeb9b267930985b2.rlib" "<sysroot>/lib/rustlib/thumbv7em-none-eabi/lib/{libcore-*,libcompiler_builtins-*}.rlib" "-L" "/tmp/rustcrMK7jK/raw-dylibs" "-Bdynamic" "--eh-frame-hdr" "-z" "noexecstack" "-L" "/home/max/test/cortex_m_rt_test/target/thumbv7em-none-eabi/debug/build/cortex-m-rt-22da783ef07445d2/out" "-o" "/home/max/test/cortex_m_rt_test/target/thumbv7em-none-eabi/debug/deps/cortex_m_rt_test-39c54d44dafd8fd1" "--gc-sections" "-nostartfiles" "-Tlink.x"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: rust-lld: error: unknown argument '-nostartfiles'
          

error: could not compile `cortex_m_rt_test` (bin "cortex_m_rt_test") due to 1 previous error

It looks to me like -nostartfiles is a GCC-specific option. I can get it to work by adding -C linker=/usr/bin/arm-none-eabi-gcc to the command. But I'm wondering if that's necessary. When I leave out the -nostartfiles and use the default rust-lld linker, my simple test program still works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions