diff options
-rw-r--r-- | run_rustc/Makefile | 64 |
1 files changed, 39 insertions, 25 deletions
diff --git a/run_rustc/Makefile b/run_rustc/Makefile index cb9a7a81..f57054e4 100644 --- a/run_rustc/Makefile +++ b/run_rustc/Makefile @@ -1,9 +1,16 @@ # Makefile that builds libstd using the mrustc-built rustc -RUSTC := ../output/rustc -RUST_SRC ?= ../rustc-1.29.0-src/src/ +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 -PREFIX := prefix/ +PREFIX := prefix$(OUTDIR_SUF)/ BINDIR := $(PREFIX)bin/ LIBDIR := $(PREFIX)lib/rustlib/x86_64-unknown-linux-gnu/lib/ @@ -13,49 +20,56 @@ V ?= @ all: $(BINDIR)rustc $(LIBDIR)libstd.rlib $(BINDIR)hello_world all: $(BINDIR)cargo -RUSTFLAGS_liblibc := --cfg stdbuild -RUSTFLAGS_libstd := -l dl -l rt -l pthread -RUSTFLAGS_libunwind := -l gcc_s +RUSTFLAGS_core := +RUSTFLAGS_libc := --cfg stdbuild +RUSTFLAGS_std := -l dl -l rt -l pthread +RUSTFLAGS_unwind := -l gcc_s +RUSTFLAGS_alloc := +RUSTFLAGS_alloc_system := +RUSTFLAGS_compiler_builtins := --cfg feature=\"compiler-builtins\" -$(RUSTC): - make -C ../ output/rustc -j 3 -../output/cargo: - make -C ../ output/cargo -j 3 +../output$(OUTDIR_SUF)/rustc: + make -C ../ output$(OUTDIR_SUF)/rustc -j 3 +../output$(OUTDIR_SUF)/cargo: + make -C ../ output$(OUTDIR_SUF)/cargo -j 3 -$(BINDIR)rustc: $(RUSTC) +$(BINDIR)rustc: ../output$(OUTDIR_SUF)/rustc @mkdir -p $(dir $@) $Vcp $< $@ -$(BINDIR)cargo: ../output/cargo +$(BINDIR)cargo: ../output$(OUTDIR_SUF)/cargo @mkdir -p $(dir $@) $Vcp $< $@ -#$(LIBDIR)libstd.rlib-: $(RUSTC) $(BINDIR)cargo $(BINDIR)rustc +#$(LIBDIR)libstd.rlib: $(RUSTC) $(BINDIR)cargo $(BINDIR)rustc # @mkdir -p ./build/libstd -# cd $(RUST_SRC)libstd && CARGO_TARGET_DIR=$(abspath ./build/libstd) PATH="$(abspath $(BINDIR)):$$PATH" cargo build -# cp ./build/libstd/target/libstd.rlib $@ +# $(BINDIR)cargo build -Z unstable-options --vendor $(RUST_SRC)vendor --manifest-path $(RUST_SRC)libstd/Cargo.toml --out-dir $(LIBDIR) --target-dir build/libstd -$(LIBDIR)%.rlib: $(RUST_SRC)%/lib.rs $(BINDIR)rustc +$(LIBDIR)lib%.rlib: $(RUST_SRC)lib%/lib.rs $(BINDIR)rustc @mkdir -p $(dir $@) @echo "[RUSTC] -o $@" - $Vtime $(DBG) $(RUSTC) $(RUSTFLAGS_$@) -L $(LIBDIR) -L ../output/libs $< -o $@ $(RUSTFLAGS_$*) -$(LIBDIR)%.rlib: $(RUST_SRC)%/src/lib.rs $(BINDIR)rustc + $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 @mkdir -p $(dir $@) @echo "[RUSTC] -o $@" - $Vtime $(DBG) $(RUSTC) $(RUSTFLAGS_$@) -L $(LIBDIR) -L ../output/libs $< -o $@ $(RUSTFLAGS_$*) + $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 $@) @echo "[RUSTC] -o $@" - $Vtime $(DBG) $(RUSTC) $(RUSTFLAGS_$@) -L $(LIBDIR) -L ../output/libs $< -o $@ + $Vtime $(DBG) $(BINDIR)rustc $(RUSTFLAGS_$@) -L $(LIBDIR) -L ../output/libs $< -o $@ fcn_extcrate = $(patsubst %,$(LIBDIR)lib%.rlib,$(1)) $(LIBDIR)libarena.rlib: $(call fcn_extcrate, std) -$(LIBDIR)liballoc.rlib: $(call fcn_extcrate, core) -$(LIBDIR)libstd_unicode.rlib: $(call fcn_extcrate, core) -$(LIBDIR)libcollections.rlib: $(call fcn_extcrate, core alloc std_unicode) -$(LIBDIR)librand.rlib: $(call fcn_extcrate, core) -$(LIBDIR)liblibc.rlib: $(call fcn_extcrate, core) +$(LIBDIR)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) +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) |