Skip to main content

Module rustc_wrapper

Module rustc_wrapper 

Source
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-*.so is published into — the Cargo profile deps/ directory, where the packaging step stages it from.
BUILD_STD_TARGET_ENV
The only --target triple 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 water process 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.