Skip to content

Build stage0/lib/libstd.so using the stage0 compiler. #720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ config.mk: $(S)configure $(S)Makefile.in $(S)src/snapshots.txt
######################################################################

include $(CFG_SRC_DIR)/mk/intrinsics.mk
include $(CFG_SRC_DIR)/mk/stage0.mk
include $(CFG_SRC_DIR)/mk/stageN.mk
include $(CFG_SRC_DIR)/mk/stage0.mk
include $(CFG_SRC_DIR)/mk/rt.mk
include $(CFG_SRC_DIR)/mk/rustllvm.mk
include $(CFG_SRC_DIR)/mk/autodep.mk
Expand Down Expand Up @@ -269,4 +269,4 @@ endif
ifneq ($(findstring clean,$(MAKECMDGOALS)),)
CFG_INFO := $(info cfg: including clean rules)
include $(CFG_SRC_DIR)/mk/clean.mk
endif
endif
20 changes: 12 additions & 8 deletions mk/stage0.mk
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# FIXME: temporary hack: stdlib comes in the lib/ directory, but we want it in
# the base directory, so we move it out.
stage0/rustc$(X): $(S)src/snapshots.txt $(S)src/etc/get-snapshot.py $(MKFILES)
@$(call E, fetch: $@)
$(Q)$(S)src/etc/get-snapshot.py
$(Q)mv stage0/lib/$(CFG_STDLIB) stage0/$(CFG_STDLIB)
$(Q)touch $@

# Host libs will be made in the process of making rustc above.

# FIXME: temporary hack: the first two are currently carried in
# lib/ directory only, so we copy them out.
# FIXME: temporary hack: the runtime is currently carried in
# lib/ directory only, so we copy it out.

stage0/$(CFG_RUNTIME): stage0/lib/$(CFG_RUNTIME)
$(Q)cp $< $@

stage0/$(CFG_STDLIB): stage0/lib/$(CFG_STDLIB)
$(Q)cp $< $@
stage0/$(CFG_STDLIB): stage0/rustc$(X)
$(Q)touch $@

stage0/$(CFG_RUSTLLVM): stage0/rustc$(X)
$(Q)touch $@
Expand All @@ -28,11 +31,12 @@ stage0/lib/glue.o: stage0/rustc$(X)
stage0/lib/main.o: rt/main.o
$(Q)cp $< $@


stage0/lib/$(CFG_RUNTIME): stage0/rustc$(X)
$(Q)touch $@

stage0/lib/$(CFG_STDLIB): stage0/rustc$(X)
$(Q)touch $@
# Instantiate template (in stageN.mk) for building
# stage0/lib/$(CFG_STDLIB) and stage0/lib/libstd.rlib.
SREQpre = stage0/lib/main.o $(MKFILES)
$(eval $(call STDLIBGEN,pre,0))

stage0/lib/libstd.rlib: stage0/rustc$(X)
$(Q)touch $@
42 changes: 24 additions & 18 deletions mk/stageN.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@
#
# The easiest way to read this template is to assume we're building stage2
# using stage1, and mentally gloss $(1) as 1, $(2) as 2.
#
# STDLIBGEN is pulled out seperately because we need to specially invoke
# it to build stage0/lib/libstd using stage0/rustc.

define STDLIBGEN
stage$(2)/lib/$$(CFG_STDLIB): $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
stage$(2)/rustc$$(X) \
stage$(2)/$$(CFG_RUNTIME) \
stage$(2)/$$(CFG_RUSTLLVM) \
stage$(2)/lib/glue.o \
$$(SREQ$(1))
@$$(call E, compile_and_link: $$@)
$$(STAGE$(2)) --lib -o $$@ $$<

stage$(2)/lib/libstd.rlib: $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
stage$(2)/rustc$$(X) \
stage$(2)/$$(CFG_RUNTIME) \
stage$(2)/$$(CFG_RUSTLLVM) \
stage$(2)/lib/glue.o \
$$(SREQ$(1))
@$$(call E, compile_and_link: $$@)
$$(STAGE$(2)) --lib --static -o $$@ $$<
endef

define STAGEN

Expand Down Expand Up @@ -56,24 +79,7 @@ stage$(2)/lib/glue.o: stage$(2)/rustc$$(X) \
@$$(call E, generate: $$@)
$$(STAGE$(2)) -c -o $$@ --glue

stage$(2)/lib/$$(CFG_STDLIB): $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
stage$(2)/rustc$$(X) \
stage$(2)/$$(CFG_RUNTIME) \
stage$(2)/$$(CFG_RUSTLLVM) \
stage$(2)/lib/glue.o \
$$(SREQ$(1))
@$$(call E, compile_and_link: $$@)
$$(STAGE$(2)) --lib -o $$@ $$<

stage$(2)/lib/libstd.rlib: $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
stage$(2)/rustc$$(X) \
stage$(2)/$$(CFG_RUNTIME) \
stage$(2)/$$(CFG_RUSTLLVM) \
stage$(2)/lib/glue.o \
$$(SREQ$(1))
@$$(call E, compile_and_link: $$@)
$$(STAGE$(2)) --lib --static -o $$@ $$<

$(eval $(call STDLIBGEN,$(1),$(2)))

stage$(2)/lib/main.o: rt/main.o
@$$(call E, cp: $$@)
Expand Down
6 changes: 3 additions & 3 deletions src/etc/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ def scrub(b):
download_unpack_base = os.path.join(download_dir_base, "unpack")

snapshot_files = {
"linux": ["rustc", "lib/glue.o", "lib/libstd.so", "lib/libstd.rlib",
"linux": ["rustc", "lib/glue.o", "lib/libstd.so",
"lib/librustrt.so", "librustllvm.so", "lib/intrinsics.bc"],
"macos": ["rustc", "lib/glue.o", "lib/libstd.dylib", "lib/libstd.rlib",
"macos": ["rustc", "lib/glue.o", "lib/libstd.dylib",
"lib/librustrt.dylib", "librustllvm.dylib", "lib/intrinsics.bc"],
"winnt": ["rustc.exe", "lib/glue.o", "lib/std.dll", "lib/libstd.rlib",
"winnt": ["rustc.exe", "lib/glue.o", "lib/std.dll",
"lib/rustrt.dll", "rustllvm.dll", "lib/intrinsics.bc"]
}

Expand Down