Skip to content

Commit c850470

Browse files
committed
mk: If local-rust is the same as the current version, then force a local-rebuild
1 parent 65fb7be commit c850470

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

configure

+1-1
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ opt debug-assertions 0 "build with debugging assertions"
600600
opt fast-make 0 "use .gitmodules as timestamp for submodule deps"
601601
opt ccache 0 "invoke gcc/clang via ccache to reuse object files between builds"
602602
opt local-rust 0 "use an installed rustc rather than downloading a snapshot"
603-
opt local-rebuild 0 "use an installed rustc matching the current version, for rebuilds"
603+
opt local-rebuild 0 "assume local-rust matches the current version, for rebuilds; implies local-rust, and is implied if local-rust already matches the current version"
604604
opt llvm-static-stdcpp 0 "statically link to libstdc++ for LLVM"
605605
opt rpath 1 "build rpaths into rustc itself"
606606
opt stage0-landing-pads 1 "enable landing pads during bootstrap with stage0"

mk/main.mk

+10-1
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,21 @@ CFG_FILENAME_EXTRA=$(shell printf '%s' $(CFG_RELEASE)$(CFG_EXTRA_FILENAME) | $(C
6464
# from users enabling unstable features on the stable compiler.
6565
CFG_BOOTSTRAP_KEY=$(CFG_FILENAME_EXTRA)
6666

67+
# If local-rust is the same as the current version, then force a local-rebuild
68+
ifdef CFG_ENABLE_LOCAL_RUST
69+
ifeq ($(CFG_RELEASE),\
70+
$(shell $(S)src/etc/local_stage0.sh --print-rustc-release $(CFG_LOCAL_RUST_ROOT)))
71+
CFG_INFO := $(info cfg: auto-detected local-rebuild $(CFG_RELEASE))
72+
CFG_ENABLE_LOCAL_REBUILD = 1
73+
endif
74+
endif
75+
6776
# The stage0 compiler needs to use the previous key recorded in src/stage0.txt,
6877
# except for local-rebuild when it just uses the same current key.
6978
ifdef CFG_ENABLE_LOCAL_REBUILD
7079
CFG_BOOTSTRAP_KEY_STAGE0=$(CFG_BOOTSTRAP_KEY)
7180
else
72-
CFG_BOOTSTRAP_KEY_STAGE0=$(shell grep 'rustc_key' $(S)src/stage0.txt | sed 's/rustc_key: '//)
81+
CFG_BOOTSTRAP_KEY_STAGE0=$(shell sed -ne 's/^rustc_key: //p' $(S)src/stage0.txt)
7382
endif
7483

7584
# The name of the package to use for creating tarballs, installers etc.

mk/stage0.mk

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ endif
1111

1212
$(SNAPSHOT_RUSTC_POST_CLEANUP): \
1313
$(S)src/stage0.txt \
14+
$(S)src/etc/local_stage0.sh \
1415
$(S)src/etc/get-stage0.py $(MKFILE_DEPS) \
1516
| $(HBIN0_H_$(CFG_BUILD))/
1617
@$(call E, fetch: $@)

src/etc/local_stage0.sh

+9
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ if [ -z $TARG_DIR ]; then
4949
exit 1
5050
fi
5151

52+
case "$TARG_DIR" in
53+
--print-rustc-release)
54+
# not actually copying to TARG_DIR, just print the local rustc version and exit
55+
${PREFIX}/bin/rustc${BIN_SUF} --version --verbose | sed -ne 's/^release: //p'
56+
;;
57+
*)
58+
5259
cp ${PREFIX}/bin/rustc${BIN_SUF} ${TARG_DIR}/stage0/bin/
5360
cp ${PREFIX}/${LIB_DIR}/${RUSTLIBDIR}/${TARG_DIR}/${LIB_DIR}/* ${TARG_DIR}/stage0/${LIB_DIR}/
5461
cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}extra*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR}/
@@ -66,3 +73,5 @@ cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}term*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DI
6673

6774
# do not fail if one of the above fails, as all we need is a working rustc!
6875
exit 0
76+
77+
esac

0 commit comments

Comments
 (0)