Skip to content

Commit 3406c55

Browse files
committed
mk: Add --enable-local-rebuild to bootstrap from the current release
In Linux distributions, it is often necessary to rebuild packages for cases like applying new patches or linking against new system libraries. In this scenario, the rustc in the distro build environment may already match the current release that we're trying to rebuild. Thus we don't want to use the prior release's bootstrap key, nor `--cfg stage0` for the prior unstable features. The new `configure --enable-local-rebuild` option specifies that we are rebuilding from the current release. The current bootstrap key is used for the local rustc, and current stage1 features are also assumed.
1 parent 14d6a10 commit 3406c55

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

configure

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ opt debug-assertions 0 "build with debugging assertions"
599599
opt fast-make 0 "use .gitmodules as timestamp for submodule deps"
600600
opt ccache 0 "invoke gcc/clang via ccache to reuse object files between builds"
601601
opt local-rust 0 "use an installed rustc rather than downloading a snapshot"
602+
opt local-rebuild 0 "use an installed rustc matching the current version, for rebuilds"
602603
opt llvm-static-stdcpp 0 "statically link to libstdc++ for LLVM"
603604
opt rpath 1 "build rpaths into rustc itself"
604605
opt stage0-landing-pads 1 "enable landing pads during bootstrap with stage0"
@@ -847,6 +848,16 @@ then
847848
BIN_SUF=.exe
848849
fi
849850

851+
# --enable-local-rebuild implies --enable-local-rust too
852+
if [ -n "$CFG_ENABLE_LOCAL_REBUILD" ]
853+
then
854+
if [ -z "$CFG_ENABLE_LOCAL_RUST" ]
855+
then
856+
CFG_ENABLE_LOCAL_RUST=1
857+
putvar CFG_ENABLE_LOCAL_RUST
858+
fi
859+
fi
860+
850861
if [ -n "$CFG_ENABLE_LOCAL_RUST" ]
851862
then
852863
system_rustc=$(which rustc)

mk/main.mk

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,14 @@ CFG_FILENAME_EXTRA=$(shell printf '%s' $(CFG_RELEASE)$(CFG_EXTRA_FILENAME) | $(C
3434
# intentionally not "secure" by any definition, this is largely just a deterrent
3535
# from users enabling unstable features on the stable compiler.
3636
CFG_BOOTSTRAP_KEY=$(CFG_FILENAME_EXTRA)
37+
38+
# The stage0 compiler needs to use the previous key recorded in src/stage0.txt,
39+
# except for local-rebuild when it just uses the same current key.
40+
ifdef CFG_ENABLE_LOCAL_REBUILD
41+
CFG_BOOTSTRAP_KEY_STAGE0=$(CFG_BOOTSTRAP_KEY)
42+
else
3743
CFG_BOOTSTRAP_KEY_STAGE0=$(shell grep 'rustc_key' $(S)src/stage0.txt | sed 's/rustc_key: '//)
44+
endif
3845

3946
ifeq ($(CFG_RELEASE_CHANNEL),stable)
4047
# This is the normal semver version string, e.g. "0.12.0", "0.12.0-nightly"
@@ -526,6 +533,11 @@ ifneq ($(strip $(CFG_BUILD)),$(strip $(3)))
526533
CFGFLAG$(1)_T_$(2)_H_$(3) = stage1
527534

528535
RPATH_VAR$(1)_T_$(2)_H_$(3) := $$(TARGET_RPATH_VAR1_T_$(2)_H_$$(CFG_BUILD))
536+
else
537+
ifdef CFG_ENABLE_LOCAL_REBUILD
538+
# Assume the local-rebuild rustc already has stage1 features too.
539+
CFGFLAG$(1)_T_$(2)_H_$(3) = stage1
540+
endif
529541
endif
530542
endif
531543

0 commit comments

Comments
 (0)