Is there a way to set/override the linker binary from within a build.rs file?
I would like to set it to the binary name I retrieve from a PKG_CONFIG information for cross-compilation.
Setting the environment variable CARGO_TARGET_<triple>_LINKER
before calling cargo build
or setting it in config.toml
works.
So far I found/tried the following without success:
- I found some (old) references to
println!("cargo:rustc-linker=<linker>");
but that doesn't seem to do anything. - The
"cargo:rustc-link-arg"
only adds options to the linker, but can't select it. - The
"cargo:rustc-env"
seems to set environment variables visible to the compiled source code - Using std::env::set::var("CARGO_TARGET_<triple>_LINKER", "linker"); also doesn't work
cargo::rustc-flags=FLAGS
only allows for-l
or-L
flags, but not-C linker=