Skip to content

aarch64-linux-gnu + SSH config is selecting the wrong linker: x86_64-w64-mingw32-gcc instead of aarch64-linux-gnu-gcc #260

@DavidAntliff

Description

@DavidAntliff

I am trying to use dinghy (for the first time) with an aarch64 embedded Linux platform, via SSH.

I'm on Ubuntu 24.04 with the aarch64-linux-gnu-gcc toolchain installed:

$ which aarch64-linux-gnu-gcc
/usr/bin/aarch64-linux-gnu-gcc

$ dpkg -S /usr/bin/aarch64-linux-gnu-gcc
gcc-aarch64-linux-gnu: /usr/bin/aarch64-linux-gnu-gcc

The sysroot appears to be installed to /usr/aarch64-linux-gnu/ by libc6-dev-arm64-cross and friends:

$ dpkg -S /usr/aarch64-linux-gnu
binutils-aarch64-linux-gnu, libstdc++6-arm64-cross, libtsan2-arm64-cross, liblsan0-arm64-cross, libitm1-arm64-cross, libgomp1-arm64-cross, libgcc-s1-arm64-cross, libc6-arm64-cross, libhwasan0-arm64-cross, libubsan1-arm64-cross, libasan8-arm64-cross, libatomic1-arm64-cross, linux-libc-dev-arm64-cross, libc6-dev-arm64-cross: /usr/aarch64-linux-gnu

I think I have the right Rust target installed:

$ rustup target install aarch64-unknown-linux-gnu
info: component 'rust-std' for target 'aarch64-unknown-linux-gnu' is up to date

So for this I have set up my .dinghy.toml as per the instructions:

[platforms.aarch64-linux]
rustc_triple = "aarch64-unknown-linux-gnu"
toolchain = "/usr"

[ssh_devices]
emb = { hostname="192.168.0.2", username="root", platform="aarch64-linux" }

When I run cargo dinghy -d emb test, the process tries to link with the wrong linker (some paths redacted with ...):

$ cargo dinghy -d emb test -v
   Targeting platform aarch64-linux and device emb

...

error: linking with `/.../target/aarch64-unknown-linux-gnu/aarch64-linux/linker` failed: exit status: 1
  |
  = note:  "/.../target/aarch64-unknown-linux-gnu/aarch64-linux/linker" "/tmp/rustcqwGjnM/symbols.o" "<21 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "<sysroot>/lib/rustlib/aarch64-unknown-linux-gnu/lib/{libtest-*,libgetopts-*,libunicode_width-*,librustc_std_workspace_std-*,libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,libcfg_if-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/tmp/rustcqwGjnM/raw-dylibs" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "<sysroot>/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-o" "/.../target/aarch64-unknown-linux-gnu/debug/deps/test_dinghy-c9f0160be67509b8" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: /usr/bin/x86_64-w64-mingw32-ld: unrecognized option '--eh-frame-hdr'
          /usr/bin/x86_64-w64-mingw32-ld: use the --help option for usage information
          collect2: error: ld returned 1 exit status

This linker, /usr/bin/x86_64-w64-mingw32-ld, is obviously incorrect (it's a Windows cross-compiler!).

$ cat target/aarch64-unknown-linux-gnu/aarch64-linux/linker
#!/bin/sh
/usr/bin/x86_64-w64-mingw32-gcc  "$@"

Any idea what's going wrong here? Why is the wrong linker being picked up?


Note: I have a .cargo/config.toml set up with:

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"

Thus, the following cross-compilation works: cargo build --target aarch64-unknown-linux-gnu, but I don't seem to be able to pass --target to cargo dinghy in any meaningful way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions