tawasuyu

sergio/takana

> Una distribución Linux construida con un laboratorio funcional y hermético en el > sótano, y una terminal mutable, clásica y anárquica en el piso de arriba — diseñada > desde el suelo para que una IA programadora entienda, modifique y co…

TOML 1173Shell 64Rust 62Markdown 441482 Definiciones

⎇ 4190c7b43e5bd323a9b166340cfa16cd324ca2e4 scripts/rust-frontier/build-stage0-musl.sh Shell · 69 líneas · 2.6 KB Historia crudo

takana: espejo de GitHub renombrado, y las dos colas que quedaban f9ed89cd1 · Sergio ·

1#!/bin/sh
2# Path A: rebuild the mrustc stage0 rustc+cargo with a MUSL host triple, so
3# CFG_COMPILER_HOST_TRIPLE=x86_64-unknown-linux-musl is baked in. This lets
4# run_rustc's cargo build proc-macros/build-scripts natively (host==target==musl)
5# without the proxy --target hack. LLVM + mrustc are reused (already built).
6# Output lands in output-1.90.0-x86_64-unknown-linux-musl/.
7set -eu
8ROOT=/mnt/vvv/takana
9DEVFS=$ROOT/.dev-fs/alpine
10MRUSTC=$ROOT/.scratch/mrustc
11T=x86_64-unknown-linux-musl
12
13run() {
14  bwrap \
15    --bind "$DEVFS" / \
16    --bind "$MRUSTC" /mrustc \
17    --dev /dev --proc /proc \
18    --tmpfs /tmp --tmpfs /run \
19    --setenv PATH /usr/bin:/bin:/usr/sbin:/sbin \
20    --setenv HOME /root --setenv TMPDIR /tmp \
21    --setenv MRUSTC_TARGET_VER 1.90 \
22    --setenv CC gcc --setenv CXX g++ \
23    --chdir /mrustc \
24    make -f minicargo.mk \
25      RUSTC_VERSION=1.90.0 \
26      MRUSTC_TARGET=$T RUSTC_TARGET=$T \
27      RUSTC_INSTALL_BINDIR=bin PARLEVEL=8 \
28      "$@"
29}
30
31# minicargo OUT_DIR host/target split fix.
32# With RUSTC_TARGET set (even when host==target==musl) minicargo runs each cargo
33# build-script under cargo-build/host/build_X/, but the *target* crate's
34# include!/include_bytes!(concat!(env!("OUT_DIR"),"/..")) resolves OUT_DIR to
35# cargo-build/build_X/ (no host/, empty) -> mrustc aborts with signal 6. Bit us on
36# libsqlite3-sys (bindgen.rs) and the cargo binary (man.tgz). host==target so the
37# script outputs are bit-identical; symlink target dir -> host dir. Late sys-crates
38# (cargo, curl, openssl, libgit2-sys, libssh2-sys) only run their scripts near the
39# end, so this is (re)applied between incremental cargo-build retries below.
40symlink_outdirs() {
41  cb="$MRUSTC/output-1.90.0-$T/cargo-build"
42  [ -d "$cb/host" ] || return 0
43  for d in "$cb"/host/build_*/; do
44    [ -d "$d" ] || continue
45    b=$(basename "$d")
46    [ -e "$cb/$b" ] && continue           # symlink or real dir already present
47    ln -s "host/$b" "$cb/$b"
48  done
49}
50
51echo "=== [1/3] LIBS (musl bootstrap std) ==="
52run LIBS
53echo "=== [2/3] rustc (musl host) ==="
54run output-1.90.0-$T/rustc
55echo "=== [3/3] cargo (musl host) ==="
56# Retry loop: minicargo is incremental, so each retry only redoes the crate that
57# failed onward. `until` keeps the failing build out of `set -e`'s reach.
58attempt=0
59until LIBGIT2_SYS_USE_PKG_CONFIG=1 run output-1.90.0-$T/cargo; do
60  attempt=$((attempt + 1))
61  if [ "$attempt" -gt 4 ]; then
62    echo "!!! cargo build still failing after $attempt attempts" >&2
63    exit 1
64  fi
65  echo "--- cargo build failed; mirroring host OUT_DIRs (attempt $attempt) and retrying ---"
66  symlink_outdirs
67done
68echo "=== DONE ==="
69ls -la output-1.90.0-$T/rustc output-1.90.0-$T/cargo