summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xTestRustcBootstrap.sh33
-rw-r--r--run_rustc/Makefile79
2 files changed, 74 insertions, 38 deletions
diff --git a/TestRustcBootstrap.sh b/TestRustcBootstrap.sh
index db195038..05897c59 100755
--- a/TestRustcBootstrap.sh
+++ b/TestRustcBootstrap.sh
@@ -1,18 +1,27 @@
-#!/bin/sh
+#!/bin/bash
# Builds rustc with the mrustc stage0 and downloaded stage0
set -e
PREFIX=${PWD}/run_rustc/prefix/
WORKDIR=${WORKDIR:-rustc_bootstrap}/
+RUSTC_VERSION=${*-1.29.0}
+if [[ "$RUSTC_VERSION" == "1.29.0" ]]; then
+ RUSTC_VERSION_NEXT=1.30.0
+elif [[ "$RUSTC_VERSION" == "1.19.0" ]]; then
+ RUSTC_VERSION_NEXT=1.20.0
+else
+ echo "Unknown rustc version"
+fi
+
MAKEFLAGS=-j8
export MAKEFLAGS
echo "=== Building stage0 rustc (with libstd)"
-make -C run_rustc
+make -C run_rustc RUSTC_VERSION=${RUSTC_VERSION}
-if [ ! -e rustc-1.20.0-src.tar.gz ]; then
- wget https://static.rust-lang.org/dist/rustc-1.20.0-src.tar.gz
+if [ ! -e rustc-${RUSTC_VERSION_NEXT}-src.tar.gz ]; then
+ wget https://static.rust-lang.org/dist/rustc-${RUSTC_VERSION_NEXT}-src.tar.gz
fi
#
@@ -21,8 +30,8 @@ fi
echo "--- Working in directory ${WORKDIR}"
echo "=== Building rustc bootstrap mrustc stage0"
mkdir -p ${WORKDIR}mrustc/
-tar -xf rustc-1.20.0-src.tar.gz -C ${WORKDIR}mrustc/
-cat - > ${WORKDIR}mrustc/rustc-1.20.0-src/config.toml <<EOF
+tar -xf rustc-${RUSTC_VERSION_NEXT}-src.tar.gz -C ${WORKDIR}mrustc/
+cat - > ${WORKDIR}mrustc/rustc-${RUSTC_VERSION_NEXT}-src/config.toml <<EOF
[build]
cargo = "${PREFIX}bin/cargo"
rustc = "${PREFIX}bin/rustc"
@@ -31,10 +40,10 @@ vendor = true
EOF
echo "--- Running x.py, see ${WORKDIR}mrustc.log for progress"
(cd ${WORKDIR} && mv mrustc build)
-(cd ${WORKDIR}build/rustc-1.20.0-src/ && ./x.py build --stage 3) > ${WORKDIR}mrustc.log 2>&1
+(cd ${WORKDIR}build/rustc-${RUSTC_VERSION_NEXT}-src/ && ./x.py build --stage 3) > ${WORKDIR}mrustc.log 2>&1
(cd ${WORKDIR} && mv build mrustc)
rm -rf ${WORKDIR}mrustc-output
-cp -r ${WORKDIR}mrustc/rustc-1.20.0-src/build/x86_64-unknown-linux-gnu/stage2 ${WORKDIR}mrustc-output
+cp -r ${WORKDIR}mrustc/rustc-${RUSTC_VERSION_NEXT}-src/build/x86_64-unknown-linux-gnu/stage2 ${WORKDIR}mrustc-output
tar -czf ${WORKDIR}mrustc.tar.gz -C ${WORKDIR} mrustc-output
#
@@ -42,16 +51,16 @@ tar -czf ${WORKDIR}mrustc.tar.gz -C ${WORKDIR} mrustc-output
#
echo "=== Building rustc bootstrap downloaded stage0"
mkdir -p ${WORKDIR}official/
-tar -xf rustc-1.20.0-src.tar.gz -C ${WORKDIR}official/
-cat - > ${WORKDIR}official/rustc-1.20.0-src/config.toml <<EOF
+tar -xf rustc-${RUSTC_VERSION_NEXT}-src.tar.gz -C ${WORKDIR}official/
+cat - > ${WORKDIR}official/rustc-${RUSTC_VERSION_NEXT}-src/config.toml <<EOF
[build]
full-bootstrap = true
vendor = true
EOF
echo "--- Running x.py, see ${WORKDIR}official.log for progress"
(cd ${WORKDIR} && mv official build)
-(cd ${WORKDIR}build/rustc-1.20.0-src/ && ./x.py build --stage 3) > ${WORKDIR}official.log 2>&1
+(cd ${WORKDIR}build/rustc-${RUSTC_VERSION_NEXT}-src/ && ./x.py build --stage 3) > ${WORKDIR}official.log 2>&1
(cd ${WORKDIR} && mv build official)
rm -rf ${WORKDIR}official-output
-cp -r ${WORKDIR}official/rustc-1.20.0-src/build/x86_64-unknown-linux-gnu/stage2 ${WORKDIR}official-output
+cp -r ${WORKDIR}official/rustc-${RUSTC_VERSION_NEXT}-src/build/x86_64-unknown-linux-gnu/stage2 ${WORKDIR}official-output
tar -czf ${WORKDIR}official.tar.gz -C ${WORKDIR} official-output
diff --git a/run_rustc/Makefile b/run_rustc/Makefile
index f57054e4..fb2447f4 100644
--- a/run_rustc/Makefile
+++ b/run_rustc/Makefile
@@ -3,21 +3,26 @@
RUSTC_VERSION_DEF = $(shell cat ../rust-version)
RUSTC_VERSION ?= $(RUSTC_VERSION_DEF)
RUST_SRC ?= ../rustc-$(RUSTC_VERSION)-src/src/
-$(warning ($(RUSTC_VERSION),$(RUST_VERSION_DEF)))
ifeq ($(RUSTC_VERSION),$(RUSTC_VERSION_DEF))
OUTDIR_SUF ?=
else
OUTDIR_SUF ?= -$(RUSTC_VERSION)
endif
+RUSTC_TARGET := x86_64-unknown-linux-gnu
+
PREFIX := prefix$(OUTDIR_SUF)/
BINDIR := $(PREFIX)bin/
-LIBDIR := $(PREFIX)lib/rustlib/x86_64-unknown-linux-gnu/lib/
+LIBDIR := $(PREFIX)lib/rustlib/$(RUSTC_TARGET)/lib/
+CARGO_HOME := $(PREFIX)cargo_home/
+PREFIX_S := prefix-s$(OUTDIR_SUF)/
+LIBDIR_S := $(PREFIX_S)lib/rustlib/$(RUSTC_TARGET)/lib/
+BINDIR_S := $(PREFIX_S)bin/
V ?= @
-all: $(BINDIR)rustc $(LIBDIR)libstd.rlib $(BINDIR)hello_world
+all: $(BINDIR)rustc $(LIBDIR)libstd.rlib $(LIBDIR)libproc_macro.rlib $(BINDIR)hello_world
all: $(BINDIR)cargo
RUSTFLAGS_core :=
@@ -36,40 +41,62 @@ RUSTFLAGS_compiler_builtins := --cfg feature=\"compiler-builtins\"
$(BINDIR)rustc: ../output$(OUTDIR_SUF)/rustc
@mkdir -p $(dir $@)
$Vcp $< $@
+$(BINDIR_S)rustc: ../output$(OUTDIR_SUF)/rustc
+ @mkdir -p $(dir $@)
+ $Vcp $< $@
$(BINDIR)cargo: ../output$(OUTDIR_SUF)/cargo
@mkdir -p $(dir $@)
$Vcp $< $@
-#$(LIBDIR)libstd.rlib: $(RUSTC) $(BINDIR)cargo $(BINDIR)rustc
-# @mkdir -p ./build/libstd
-# $(BINDIR)cargo build -Z unstable-options --vendor $(RUST_SRC)vendor --manifest-path $(RUST_SRC)libstd/Cargo.toml --out-dir $(LIBDIR) --target-dir build/libstd
+$(CARGO_HOME)config: Makefile
+ mkdir -p $(dir $@)
+ echo "[source.crates-io]" > $@
+ echo "replace-with = \"vendored-sources\"" >> $@
+ echo "[source.vendored-sources]" >> $@
+ echo "directory = \"$(abspath $(RUST_SRC)vendor)\"" >> $@
-$(LIBDIR)lib%.rlib: $(RUST_SRC)lib%/lib.rs $(BINDIR)rustc
+# Actual libstd build (using cargo)
+$(LIBDIR)libstd.rlib: $(BINDIR_S)rustc $(BINDIR)cargo $(LIBDIR_S)libstd.rlib $(CARGO_HOME)config
+ @mkdir -p ./build/libstd
+ RUSTC=$(BINDIR_S)rustc CFG_COMPILER_HOST_TRIPLE=$(RUSTC_TARGET) RUSTC_BOOTSTRAP=1 CARGO_HOME=$(CARGO_HOME) $(BINDIR)cargo build -Z unstable-options --manifest-path $(RUST_SRC)libstd/Cargo.toml --out-dir $(LIBDIR) --target-dir build$(OUTDIR_SUF) -j 1 --release --verbose
+$(LIBDIR)libproc_macro.rlib: $(LIBDIR)libstd.rlib $(CARGO_HOME)config
+ @mkdir -p ./build$(OUTDIR_SUF)
+ RUSTC=$(BINDIR)rustc CFG_COMPILER_HOST_TRIPLE=$(RUSTC_TARGET) RUSTC_BOOTSTRAP=1 CARGO_HOME=$(CARGO_HOME) $(BINDIR)cargo build -Z unstable-options --manifest-path $(RUST_SRC)libproc_macro/Cargo.toml --out-dir $(LIBDIR) --target-dir build$(OUTDIR_SUF) -j 1 --verbose
+# MINICARGO_COMPILER=$(BINDIR)rustc ../tools/bin/minicargo --vendor-dir $(RUST_SRC)vendor --output-dir build$(OUTDIR_SUF) $(RUST_SRC)libproc_macro
+
+$(BINDIR)hello_world: $(RUST_SRC)test/run-pass/hello.rs $(LIBDIR)libstd.rlib $(BINDIR)rustc
@mkdir -p $(dir $@)
@echo "[RUSTC] -o $@"
- $Vtime $(DBG) $(BINDIR)rustc --crate-type rlib --crate-name $* -L $(LIBDIR) -L ../output/libs $< -o $@ $(RUSTFLAGS_$*)
-$(LIBDIR)lib%.rlib: $(RUST_SRC)lib%/src/lib.rs $(BINDIR)rustc
+ $Vtime $(DBG) $(BINDIR)rustc $(RUSTFLAGS_$@) -L $(LIBDIR) -L ../output/libs $< -o $@
+
+#
+# - Build libstd in a hacky hard-coded way first, to allow build scripts to work
+#
+$(LIBDIR_S)lib%.rlib: $(RUST_SRC)lib%/lib.rs $(BINDIR)rustc
@mkdir -p $(dir $@)
@echo "[RUSTC] -o $@"
- $Vtime $(DBG) $(BINDIR)rustc --crate-type rlib --crate-name $* -L $(LIBDIR) -L ../output/libs $< -o $@ $(RUSTFLAGS_$*)
-
-$(BINDIR)hello_world: $(RUST_SRC)test/run-pass/hello.rs $(LIBDIR)libstd.rlib $(RUSTC)
- $Vmkdir -p $(dir $@)
+ $Vtime $(DBG) $(BINDIR)rustc --crate-type rlib --crate-name $* -L $(LIBDIR_S) $< -o $@ $(RUSTFLAGS_$*)
+$(LIBDIR_S)lib%.rlib: $(RUST_SRC)lib%/src/lib.rs $(BINDIR)rustc
+ @mkdir -p $(dir $@)
@echo "[RUSTC] -o $@"
- $Vtime $(DBG) $(BINDIR)rustc $(RUSTFLAGS_$@) -L $(LIBDIR) -L ../output/libs $< -o $@
+ $Vtime $(DBG) $(BINDIR)rustc --crate-type rlib --crate-name $* -L $(LIBDIR_S) $< -o $@ $(RUSTFLAGS_$*)
-fcn_extcrate = $(patsubst %,$(LIBDIR)lib%.rlib,$(1))
+fcn_extcrate = $(patsubst %,$(LIBDIR_S)lib%.rlib,$(1))
-$(LIBDIR)libarena.rlib: $(call fcn_extcrate, std)
-$(LIBDIR)liballoc.rlib: $(call fcn_extcrate, core compiler_builtins)
+$(LIBDIR_S)libarena.rlib: $(call fcn_extcrate, std)
+$(LIBDIR_S)liballoc.rlib: $(call fcn_extcrate, core compiler_builtins)
ifeq ($(RUSTC_VERSION),1.29.0)
-$(LIBDIR)liballoc.rlib: $(call fcn_extcrate, alloc_system)
-$(LIBDIR)liballoc_system.rlib: $(call fcn_extcrate, core libc)
+$(LIBDIR_S)liballoc.rlib: $(call fcn_extcrate, alloc_system)
+$(LIBDIR_S)liballoc_system.rlib: $(call fcn_extcrate, core libc)
+$(LIBDIR_S)libpanic_unwind.rlib: $(call fcn_extcrate, alloc)
+endif
+$(LIBDIR_S)libstd_unicode.rlib: $(call fcn_extcrate, core compiler_builtins)
+$(LIBDIR_S)libcollections.rlib: $(call fcn_extcrate, core alloc std_unicode compiler_builtins)
+$(LIBDIR_S)librand.rlib: $(call fcn_extcrate, core compiler_builtins)
+$(LIBDIR_S)liblibc.rlib: $(call fcn_extcrate, core compiler_builtins)
+$(LIBDIR_S)libcompiler_builtins.rlib: $(call fcn_extcrate, core)
+$(LIBDIR_S)libstd.rlib: $(call fcn_extcrate, core libc unwind compiler_builtins alloc_system panic_unwind)
+ifeq ($(RUSTC_VERSION),1.19.0)
+$(LIBDIR_S)libstd.rlib: $(call fcn_extcrate, collections rand)
endif
-$(LIBDIR)libstd_unicode.rlib: $(call fcn_extcrate, core compiler_builtins)
-$(LIBDIR)libcollections.rlib: $(call fcn_extcrate, core alloc std_unicode compiler_builtins)
-$(LIBDIR)librand.rlib: $(call fcn_extcrate, core compiler_builtins)
-$(LIBDIR)liblibc.rlib: $(call fcn_extcrate, core compiler_builtins)
-$(LIBDIR)libcompiler_builtins.rlib: $(call fcn_extcrate, core)
-$(LIBDIR)libstd.rlib: $(call fcn_extcrate, core collections rand libc unwind compiler_builtins alloc_system panic_unwind)
-$(LIBDIR)libunwind.rlib: $(call fcn_extcrate, core libc)
+$(LIBDIR_S)libunwind.rlib: $(call fcn_extcrate, core libc)