pub fn build_obj_plan(
captured: &CapturedRustcInvocation,
output_dir: &Path,
) -> ObjBuildPlanExpand description
Edit a captured rustc invocation so that running it produces an
object file containing every pub fn’s mangled symbol — the
input to the linker step in [build_link_plan].
Three changes only:
--crate-typeis forced torlib. Object files emitted for anrlibcrate-type retain mangledpub fnsymbols (cdylib’s symbol-visibility filter wouldn’t have run yet, because we stop before linking).libwould also work butrlibis what cargo itself uses for normal dependency compilation, so we stay closer to the rustc call shape that gets the most testing.--emitis forced to a singleobj=<output_dir>/<crate>.odirective. This skips the link step (nolib<crate>.rlibmetadata bundle, no.rmeta, no codegen-units fan-out into deps) and writes one consolidated object file we can hand directly to the linker.--out-diris redirected so the host’starget/isn’t touched (it’s still the rustc-default location for any auxiliary file rustc decides to emit).
Everything else is preserved verbatim — same target triple,
sysroot, sysroot suffix, -C flags, -L/-l directives, cfg
gates. This is the same “minimal edit, verbatim everything else”
principle as the captured-args replay does for the linker side
in super::link_plan::build_link_plan; the only difference is
where we stop in rustc’s pipeline (obj vs link).