You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cargo_build_script: propagate cdylib and binary link args
A build script's cargo::rustc-cdylib-link-arg and cargo::rustc-link-arg-bins
directives were dropped with a warning, so flags like napi-rs's
`-undefined dynamic_lookup` never reached the linker.
Route them through BuildInfo to the targets cargo applies them to:
* rustc-cdylib-link-arg is collected into BuildInfo.cdylib_link_flags and applied
to cdylib crates. Matching cargo, it propagates transitively: a cdylib picks up
the cdylib link args of every build script in its transitive dependencies
(rust-lang/cargo#9562).
* rustc-link-arg-bins is collected into BuildInfo.bin_link_flags and applied to
binary crates.
Each set is written to its own flag file, added to the relevant rustc action as
an --arg-file, so a non-matching crate type never reads it.
The per-binary cargo::rustc-link-arg-bin=BIN=FLAG stays unsupported: a build
script's outputs are shared by every target that depends on it, so a flag cannot
be scoped to one named binary.
Fixes#1062.
Copy file name to clipboardExpand all lines: rust/private/providers.bzl
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -79,6 +79,8 @@ CrateGroupInfo = provider(
79
79
BuildInfo=provider(
80
80
doc="A provider containing `rustc` build settings for a given Crate.",
81
81
fields= {
82
+
"bin_link_flags": "Optional[File]: file of `-Clink-arg`s to pass to rustc only when the crate is built as a binary (`cargo::rustc-link-arg-bins`).",
83
+
"cdylib_link_flags": "Optional[File]: file of `-Clink-arg`s to pass to rustc only when the crate is built as a cdylib (`cargo::rustc-cdylib-link-arg`); propagated transitively to cdylibs.",
82
84
"compile_data": "Depset[File]: Compile data provided by the build script that was not copied into `out_dir`.",
83
85
"dep_env": "Optional[File]: extra build script environment variables to be set to direct dependencies.",
84
86
"flags": "Optional[File]: file containing additional flags to pass to rustc",
0 commit comments