Skip to content

Commit 9db4d9c

Browse files
committed
Add CFG_USE_SNAP_LIBS_FOR_STAGE1 hack to makefiles
1 parent 4eb86d4 commit 9db4d9c

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

Makefile.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ else
5757
CFG_STDLIB_DEFAULT = $(2)/$(CFG_STDLIB)
5858
endif
5959

60+
# Uncomment this to temporarily use the snapshot's runtime for stage1.
61+
# This is useful when making incompatible changes to the parts of the
62+
# runtime used directly by the compiler -- the binaries built by the
63+
# snapshot won't know about the changes yet. Don't leave this on. Turn
64+
# it on, shapshot, and turn it off again.
65+
# CFG_USE_SNAP_LIBS_FOR_STAGE1 = 1
66+
6067
# version-string calculation
6168
CFG_GIT_DIR := $(CFG_SRC_DIR).git
6269
CFG_VERSION = prerelease

mk/stageN.mk

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
# new rustrt in stage0/lib/.
99

1010
define LIBGEN
11+
12+
ifdef CFG_USE_SNAP_LIBS_FOR_STAGE1
13+
ifeq ($(2), 0)
14+
RUNTIME_SOURCE = stage0/$(CFG_RUNTIME)
15+
stage$(2)/lib/$$(CFG_STDLIB): stage0/$$(CFG_STDLIB)
16+
@$$(call E, cp: $$@)
17+
$$(Q)cp $$< $$@
18+
else
19+
RUNTIME_SOURCE = rt/$(CFG_RUNTIME)
1120
stage$(2)/lib/$$(CFG_STDLIB): $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
1221
stage$(2)/rustc$$(X) \
1322
stage$(2)/$$(CFG_RUNTIME) \
@@ -16,6 +25,8 @@ stage$(2)/lib/$$(CFG_STDLIB): $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
1625
$$(SREQ$(1))
1726
@$$(call E, compile_and_link: $$@)
1827
$$(STAGE$(2)) --lib -o $$@ $$<
28+
endif
29+
endif
1930

2031
stage$(2)/lib/libstd.rlib: $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
2132
stage$(2)/rustc$$(X) \
@@ -26,7 +37,7 @@ stage$(2)/lib/libstd.rlib: $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
2637
@$$(call E, compile_and_link: $$@)
2738
$$(STAGE$(2)) --lib --static -o $$@ $$<
2839

29-
stage$(2)/lib/$$(CFG_RUNTIME): rt/$$(CFG_RUNTIME)
40+
stage$(2)/lib/$$(CFG_RUNTIME): $$(RUNTIME_SOURCE)
3041
@$$(call E, cp: $$@)
3142
$$(Q)cp $$< $$@
3243

@@ -58,11 +69,20 @@ stage$(2)/rustc$$(X): $$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
5869
@$$(call E, compile_and_link: $$@)
5970
$$(STAGE$(1)) -L stage$(2) -o $$@ $$<
6071

61-
stage$(2)/$$(CFG_RUNTIME): rt/$$(CFG_RUNTIME)
72+
RUNTIME_SOURCE = rt/$(CFG_RUNTIME)
73+
STDLIB_SOURCE = stage$(1)/lib/$$(CFG_STDLIB)
74+
ifdef CFG_USE_SNAP_LIBS_FOR_STAGE1
75+
ifeq ($(2), 1)
76+
RUNTIME_SOURCE = stage0/$(CFG_RUNTIME)
77+
STDLIB_SOURCE = stage0/$(CFG_STDLIB)
78+
endif
79+
endif
80+
81+
stage$(2)/$$(CFG_RUNTIME): $$(RUNTIME_SOURCE)
6282
@$$(call E, cp: $$@)
6383
$$(Q)cp $$< $$@
6484

65-
stage$(2)/$$(CFG_STDLIB): stage$(1)/lib/$$(CFG_STDLIB)
85+
stage$(2)/$$(CFG_STDLIB): $$(STDLIB_SOURCE)
6686
@$$(call E, cp: $$@)
6787
$$(Q)cp $$< $$@
6888

0 commit comments

Comments
 (0)