selfhost-verify: arregla el split OUT_DIR host/target de minicargo en build-stage0-musl
Al construir el cargo del stage0 musl-host, minicargo (con RUSTC_TARGET seteado, aunque host==target==musl) corre los build-scripts bajo cargo-build/host/build_X/ pero el crate target hace include!/include_bytes!(OUT_DIR/..) apuntando a cargo-build/build_X/ (vacío) -> mrustc aborta con signal 6. Rompió en libsqlite3-sys (bindgen.rs) y en el binario cargo (man.tgz). Fix: symlink_outdirs() enlaza cada dir target -> host (salidas bit-idénticas porque host==target), aplicado en un bucle de reintento alrededor del build incremental de cargo (los sys-crates tardíos -cargo/curl/openssl/libgit2-sys/libssh2-sys- corren sus scripts al final, así que un solo pase no basta). Documentado como snag #4 en el README. Verificado: stage0 musl-host rustc 1.90.0 + cargo 1.90.0 construyen y corren con host=x86_64-unknown-linux-musl; desbloquea proc-macros nativos en run_rustc. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -62,6 +62,18 @@ to bootstrap a usable rust there:
|
||||
can't be reassigned by the makefile, so the `-musl` suffix append is skipped and
|
||||
the build contaminates the gnu output dir. Let it default.
|
||||
|
||||
4. **minicargo OUT_DIR host/target split** (only when building the musl stage0's
|
||||
cargo). With `RUSTC_TARGET` set, minicargo runs each cargo build-script under
|
||||
`cargo-build/host/build_X/`, but the *target* crate's `include!` /
|
||||
`include_bytes!(concat!(env!("OUT_DIR"), "/.."))` resolves `OUT_DIR` to
|
||||
`cargo-build/build_X/` (no `host/`, empty) → mrustc aborts with signal 6. Hit
|
||||
`libsqlite3-sys` (`bindgen.rs`) and the `cargo` binary (`man.tgz`). The gnu
|
||||
build never split (single triple → single dir). Since host==target the script
|
||||
outputs are bit-identical, so `build-stage0-musl.sh` symlinks the target dir to
|
||||
the host dir (`symlink_outdirs`). Late sys-crates (cargo, curl, openssl,
|
||||
libgit2-sys, libssh2-sys) run their scripts near the end, so it's applied in a
|
||||
retry loop around the incremental cargo build.
|
||||
|
||||
## Workflow
|
||||
|
||||
```sh
|
||||
|
||||
@@ -28,11 +28,42 @@ run() {
|
||||
"$@"
|
||||
}
|
||||
|
||||
# minicargo OUT_DIR host/target split fix.
|
||||
# With RUSTC_TARGET set (even when host==target==musl) minicargo runs each cargo
|
||||
# build-script under cargo-build/host/build_X/, but the *target* crate's
|
||||
# include!/include_bytes!(concat!(env!("OUT_DIR"),"/..")) resolves OUT_DIR to
|
||||
# cargo-build/build_X/ (no host/, empty) -> mrustc aborts with signal 6. Bit us on
|
||||
# libsqlite3-sys (bindgen.rs) and the cargo binary (man.tgz). host==target so the
|
||||
# script outputs are bit-identical; symlink target dir -> host dir. Late sys-crates
|
||||
# (cargo, curl, openssl, libgit2-sys, libssh2-sys) only run their scripts near the
|
||||
# end, so this is (re)applied between incremental cargo-build retries below.
|
||||
symlink_outdirs() {
|
||||
cb="$MRUSTC/output-1.90.0-$T/cargo-build"
|
||||
[ -d "$cb/host" ] || return 0
|
||||
for d in "$cb"/host/build_*/; do
|
||||
[ -d "$d" ] || continue
|
||||
b=$(basename "$d")
|
||||
[ -e "$cb/$b" ] && continue # symlink or real dir already present
|
||||
ln -s "host/$b" "$cb/$b"
|
||||
done
|
||||
}
|
||||
|
||||
echo "=== [1/3] LIBS (musl bootstrap std) ==="
|
||||
run LIBS
|
||||
echo "=== [2/3] rustc (musl host) ==="
|
||||
run output-1.90.0-$T/rustc
|
||||
echo "=== [3/3] cargo (musl host) ==="
|
||||
LIBGIT2_SYS_USE_PKG_CONFIG=1 run output-1.90.0-$T/cargo
|
||||
# Retry loop: minicargo is incremental, so each retry only redoes the crate that
|
||||
# failed onward. `until` keeps the failing build out of `set -e`'s reach.
|
||||
attempt=0
|
||||
until LIBGIT2_SYS_USE_PKG_CONFIG=1 run output-1.90.0-$T/cargo; do
|
||||
attempt=$((attempt + 1))
|
||||
if [ "$attempt" -gt 4 ]; then
|
||||
echo "!!! cargo build still failing after $attempt attempts" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "--- cargo build failed; mirroring host OUT_DIRs (attempt $attempt) and retrying ---"
|
||||
symlink_outdirs
|
||||
done
|
||||
echo "=== DONE ==="
|
||||
ls -la output-1.90.0-$T/rustc output-1.90.0-$T/cargo
|
||||
|
||||
Reference in New Issue
Block a user