TWO questions about cargo:rustc-link-arg

N1.

why does it limit targets?

As I understood from this text`

The rustc-link-arg instruction tells Cargo to pass 
the -C link-arg=FLAG option to the compiler,
but only when building supported targets (benchmarks, binaries,
cdylib crates, examples, and tests). Its usage is highly platform specific. 
It is useful to set the shared library version or linker script.

cargo:rustc-link-arg deliberately limits the list of targets to which flags are applied, and flags will not be applied to targets such as dylib or rlib, why does it limit targets?

N2.

Where can I find documentation on all the flags of cargo:rustc-link-arg?

Where can I find documentation on all the flags of cargo:rustc-link-arg?. which I believe are transmitted to linker.exe, I searched on the Internet, but according to the search engine results, I did not find any complete list

N2: As the docs say: "usage is highly platform specific". So it depends on the platform (some combination of OS, ABI, hardware and maybe other things).

If you're asking specifically about windows-msvc targets then it'll use link.exe. You can find documentation here: MSVC Linker options | Microsoft Learn

2 Likes

Thank you!!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.