Files
takana/scripts/rust-frontier/run_rustc.patch
T
sergioandClaude Opus 4.8 bf3f1166ec selfhost-verify: artefactos del frente rust (parche run_rustc + runners stage0-musl)
Rastrea las correcciones del frente rust que vivían en .scratch/ (gitignored):

- run_rustc.patch (vs mrustc be69c74): minicargo/hello con --target musl;
  RUSTFLAGS + sitios de link con link-self-contained=no (CRT vía gcc Alpine,
  link dinámico contra musl); proxy host-units con crt-static off (sin inject
  de --target, host==target==musl con el stage0 musl-host).
- build-stage0-musl.sh: rebuild del stage0 rustc+cargo con host triple musl
  (CFG_COMPILER_HOST_TRIPLE vía RUSTC_TARGET, --target vía MRUSTC_TARGET),
  reusa LLVM + bin/mrustc. Gotcha OUTDIR_SUF documentado.
- run-runrustc.sh: corre targets de run_rustc en el sandbox devfs apuntando
  al stage0 musl-host.
- README: diagnóstico de los 3 snags acoplados (std-gnu mmap64/open64,
  CRT self-contained ausente, host-triple gnu + proc-macros) y el workflow.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 21:48:37 -04:00

50 lines
3.1 KiB
Diff

diff --git a/run_rustc/Makefile b/run_rustc/Makefile
index e78d8c5..4d6ef5d 100644
--- a/run_rustc/Makefile
+++ b/run_rustc/Makefile
@@ -108,7 +108,7 @@ CARGO_FLAGS := --target $(RUSTC_TARGET) -j $(PARLEVEL) --release --verbose
CARGO_ENV := CFG_COMPILER_HOST_TRIPLE=$(RUSTC_TARGET)
CARGO_ENV += RUSTC_BOOTSTRAP=1
CARGO_ENV += CARGO_HOME=$(CARGO_HOME)
-CARGO_ENV += RUSTFLAGS="-Z force-unstable-if-unmarked -C link_args=-Wl,-rpath,\$$ORIGIN/../lib -C target-feature=-crt-static"
+CARGO_ENV += RUSTFLAGS="-Z force-unstable-if-unmarked -C link_args=-Wl,-rpath,\$$ORIGIN/../lib -C target-feature=-crt-static -C link-self-contained=no"
fn_opt_copy = (test -e "$2" && test ! "$1" -nt "$2") || cp "$1" "$2"
@@ -159,7 +159,7 @@ $(LIBDIR_S)libstd.rlib: $(BINDIR_S)rustc $(MINICARGO) Makefile
@echo "[MINICARGO] $(RUST_SRC_LIBS)std > $(LIBDIR_S)"
mkdir -p $(LIBDIR_S)
ifneq ($(TARGETVER_LEAST_1_74),)
- $V+STD_ENV_ARCH=$(RUSTC_ARCH) MRUSTC_PATH=$(abspath $(BINDIR_S)rustc) $(MINICARGO) --vendor-dir $(VENDOR_DIR) --script-overrides ../script-overrides/stable-$(RUSTC_VERSION)-$(PLATFORM)/ --output-dir $(LIBDIR_S) $(RUST_SRC_LIBS)sysroot
+ $V+STD_ENV_ARCH=$(RUSTC_ARCH) MRUSTC_PATH=$(abspath $(BINDIR_S)rustc) $(MINICARGO) --vendor-dir $(VENDOR_DIR) --script-overrides ../script-overrides/stable-$(RUSTC_VERSION)-$(PLATFORM)/ --output-dir $(LIBDIR_S) --target $(RUSTC_TARGET) $(RUST_SRC_LIBS)sysroot
else
$V+MRUSTC_PATH=$(abspath $(BINDIR_S)rustc) $(MINICARGO) --vendor-dir $(VENDOR_DIR) --script-overrides ../script-overrides/stable-$(RUSTC_VERSION)-$(PLATFORM)/ --output-dir $(LIBDIR_S) $(RUST_SRC_LIBS)std
$V+MRUSTC_PATH=$(abspath $(BINDIR_S)rustc) $(MINICARGO) --vendor-dir $(VENDOR_DIR) --script-overrides ../script-overrides/stable-$(RUSTC_VERSION)-$(PLATFORM)/ --output-dir $(LIBDIR_S) $(RUST_SRC_LIBS)panic_unwind
@@ -169,7 +169,7 @@ endif
# Build hello_world using the bootstrapping compiler (mrustc-built rustc)
$(BINDIR_S)hello_world: $(RUST_SRC_HELLO) $(LIBDIR_S)libstd.rlib $(BINDIR_S)rustc
@mkdir -p $(dir $@)
- $V$(BINDIR_S)rustc $(RUSTFLAGS_$@) -L $(LIBDIR_S) $< -o $@
+ $V$(BINDIR_S)rustc $(RUSTFLAGS_$@) --target $(RUSTC_TARGET) -C target-feature=-crt-static -C link-self-contained=no -L $(LIBDIR_S) $< -o $@
# ---
# Stage 2: Build a proper libstd (which includes dynamc libraries too)
diff --git a/run_rustc/rustc_proxy.sh b/run_rustc/rustc_proxy.sh
index 3f4f2b9..78f6f1d 100755
--- a/run_rustc/rustc_proxy.sh
+++ b/run_rustc/rustc_proxy.sh
@@ -17,7 +17,12 @@ if is_target "$@"; then
#echo " [REAL]" "$@" >&2
${PROXY_RUSTC} "$@"
else
+ # Host (build-script / proc-macro) build. With the musl-host stage0 rustc its
+ # default target IS x86_64-unknown-linux-musl, so no --target inject is needed
+ # (host==target==musl, proc-macros load natively). Just force dynamic +
+ # non-self-contained so the Alpine gcc supplies the CRT (the mrustc sysroot has
+ # no self-contained CRT dir, and musl's default is static-pie).
#echo " [BOOTSTRAP]" "$@" >&2
- ${PROXY_MRUSTC} "$@"
+ ${PROXY_MRUSTC} -C target-feature=-crt-static -C link-self-contained=no "$@"
fi