How to pass cargo linker args?


#1

I need pass to linker args,
i put in my ~/.cargo/config:

[target.arm-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc -Xlinker -rpath=/usr/lib/arm-linux-gnueabihf"

```

i get error:
```
error: could not exec the linker `/home/chessnokov/arm-linux-gnueabihf-gcc -Xlinker -rpath=/usr/lib/arm-linux-gnueabihf`: No such file or directory
```

then try:

[target.arm-unknown-linux-gnueabihf]
linker = “arm-linux-gnueabihf-gcc “-Xlinker” “-rpath=/usr/lib/arm-linux-gnueabihf””

same error

#2

Sorry for bringing this to the top but, since it shows up on Google, I think it merits at least one answer:

Cargo and the TOML language aren’t as loose about the difference between a string and a list as shell scripting is. If you actually used the ["array", "syntax"], you’d have gotten an error from Cargo about how it expected a string.

I’ve checked the docs and can’t find any evidence that adding custom arguments is supported directly, so you’ll have to write a simple wrapper script like this and then point ~/.cargo/config at that instead.

#!/bin/sh
exec arm-linux-gnueabihf-gcc -Xlinker -rpath=/usr/lib/arm-linux-gnueabihf "$@"

#3

~/.cargo/config:
[target.armv7-unknown-linux-gnueabihf]
linker = “arm-linux-gnueabihf-gcc"
rustflags = [”-Clink-args=-Xlinker -rpath=/usr/lib/arm-linux-gnueabihf"]


#4

Another example can be seen here: