Expand description
RUSTC_WRAPPER shim that recovers the dylib half of a -Zbuild-std
standard library.
Cargo deliberately strips the dylib crate type from std when the
standard library is built from source (-Zbuild-std), so the only shared
libstd a -Cprefer-dynamic link can pick is rustup’s prebuilt one — and
rustup ships the Android libstd with 4 KB-aligned LOAD segments, which
a device with 16 KB pages refuses to map.
This wrapper supplies the missing half at the exact point Cargo cannot
express it. For the std unit of the configured target it appends
--crate-type dylib to the same rustc invocation that emits the rlib, so
both artifacts carry one strict version hash and every dependent crate
accepts the dylib as the same std. And for every other unit that
receives the std rlib through --extern, it appends the produced .so
as a second std extern: a crate named on the command line is never
re-resolved against the library search path, so the sibling dylib has to
be passed explicitly for prefer-dynamic to find it.
The water binary itself is the wrapper (RUSTC_WRAPPER points at the
running executable) so the shim ships inside the same artifact a
cargo install produces. Cargo invokes the wrapper as
water <rustc> <args…>; the process enters here only when the cargo
invocation that spawned it also exported WRAPPER_MODE_ENV, so a normal
water run never wanders into this path.
Constants§
- BUILD_
STD_ DYLIB_ DIR_ ENV - Directory the produced
libstd-*.sois published into — the Cargo profiledeps/directory, where the packaging step stages it from. - BUILD_
STD_ TARGET_ ENV - The only
--targettriple this shim rewrites. - WRAPPER_
CHAIN_ ENV - Optional second wrapper (e.g.
sccache) invoked between this shim and rustc; unset means the rewritten arguments go to rustc directly. - WRAPPER_
MODE_ ENV - Marks the
waterprocess as a Cargo rustc wrapper rather than a CLI.
Functions§
- wrapper_
main - Run as a Cargo rustc wrapper when the invoking cargo configured us as one.