Description
Summary
Implementation: #7811 #8441
Documentation: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#extra-link-arg
The -Z extra-link-arg
flag allows build scripts to issue additional cargo commands to pass custom flags to the linker:
*cargo:rustc-link-arg-bins=FLAG
– Passes custom flags to a linker for binaries.
*cargo:rustc-link-arg=FLAG
– Passes custom flags to a linker for benchmarks, binaries, cdylib
crates, examples, and tests.
Unresolved issues
None at this time.
Future extensions
- Additional options could be added in the future to pass flags for other targets. These flags should probably mirror cargo's CLI flags, though some cases are a little unclear. For example:
cargo:rustc-link-arg-bin-NAME=… # equivalent to --bin=NAME cargo:rustc-link-arg-example-NAME=… # equivalent to --example=NAME cargo:rustc-link-arg-bins=… # equivalent to --bins (NOW IMPLEMENTED) cargo:rustc-link-arg-examples=… # equivalent to --examples cargo:rustc-link-arg-test-NAME=… # equivalent to --test=NAME cargo:rustc-link-arg-tests=… # equivalent to --tests (including unittests) cargo:rustc-link-arg-unittests=… # ??? (not sure what this means) cargo:rustc-link-arg-test-LIBNAME=… # for unittest of lib only? cargo:rustc-link-arg-cdylib=… # for cdylib (ON STABLE AS rustc-cdylib-link-arg) cargo:rustc-link-arg-bench-NAME=… # equivalent to --bench=NAME cargo:rustc-link-arg-benches=… # equivalent to --benches cargo:rustc-link-arg=… # anything linkable? bins,examples,tests,benches,cdylib? (NOW IMPLEMENTED)
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.