toolchain: add a version that can be bumped to force toolchain/target rebuild

This can be used to ensure that the compiled code is up to date, when
something important changes in the toolchain.
A recent example of this is the gcc 11 fix for a code miscompilation issue

Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
Felix Fietkau 2021-11-16 12:46:21 -08:00
parent 0c249ab076
commit db34b93331
4 changed files with 24 additions and 4 deletions

1
.gitignore vendored
View File

@ -5,6 +5,7 @@
/dl /dl
/.config /.config
/.config.old /.config.old
/.toolchain_build_ver
/bin /bin
/build_dir /build_dir
/staging_dir /staging_dir

View File

@ -38,7 +38,7 @@ else
include tools/Makefile include tools/Makefile
include toolchain/Makefile include toolchain/Makefile
$(toolchain/stamp-compile): $(tools/stamp-compile) $(toolchain/stamp-compile): $(tools/stamp-compile) $(if $(CONFIG_BUILDBOT),toolchain_rebuild_check)
$(target/stamp-compile): $(toolchain/stamp-compile) $(tools/stamp-compile) $(BUILD_DIR)/.prepared $(target/stamp-compile): $(toolchain/stamp-compile) $(tools/stamp-compile) $(BUILD_DIR)/.prepared
$(package/stamp-compile): $(target/stamp-compile) $(package/stamp-cleanup) $(package/stamp-compile): $(target/stamp-compile) $(package/stamp-cleanup)
$(package/stamp-install): $(package/stamp-compile) $(package/stamp-install): $(package/stamp-compile)
@ -50,14 +50,23 @@ printdb:
prepare: $(target/stamp-compile) prepare: $(target/stamp-compile)
clean: FORCE _clean: FORCE
rm -rf $(BUILD_DIR) $(STAGING_DIR) $(BIN_DIR) $(OUTPUT_DIR)/packages/$(ARCH_PACKAGES) $(BUILD_LOG_DIR) $(TOPDIR)/staging_dir/packages rm -rf $(BUILD_DIR) $(STAGING_DIR) $(BIN_DIR) $(OUTPUT_DIR)/packages/$(ARCH_PACKAGES) $(BUILD_LOG_DIR) $(TOPDIR)/staging_dir/packages
dirclean: clean clean: _clean
rm -rf $(STAGING_DIR_HOST) $(STAGING_DIR_HOSTPKG) $(TOOLCHAIN_DIR) $(BUILD_DIR_BASE)/host $(BUILD_DIR_BASE)/hostpkg $(BUILD_DIR_TOOLCHAIN) rm -rf $(BUILD_LOG_DIR)
targetclean: _clean
rm -rf $(TOOLCHAIN_DIR) $(BUILD_DIR_BASE)/hostpkg $(BUILD_DIR_TOOLCHAIN)
dirclean: targetclean clean
rm -rf $(STAGING_DIR_HOST) $(STAGING_DIR_HOSTPKG) $(BUILD_DIR_BASE)/host
rm -rf $(TMP_DIR) rm -rf $(TMP_DIR)
$(MAKE) -C $(TOPDIR)/scripts/config clean $(MAKE) -C $(TOPDIR)/scripts/config clean
toolchain_rebuild_check:
$(SCRIPT_DIR)/check-toolchain-clean.sh
cacheclean: cacheclean:
ifneq ($(CONFIG_CCACHE),) ifneq ($(CONFIG_CCACHE),)
$(STAGING_DIR_HOST)/bin/ccache -C $(STAGING_DIR_HOST)/bin/ccache -C

View File

@ -0,0 +1,9 @@
#!/bin/sh
eval `grep CONFIG_GCC_VERSION .config`
CONFIG_TOOLCHAIN_BUILD_VER="$CONFIG_GCC_VERSION-$(cat toolchain/build_version)"
touch .toolchain_build_ver
[ "$CONFIG_TOOLCHAIN_BUILD_VER" = "$(cat .toolchain_build_ver)" ] && exit 0
echo "Toolchain build version changed, running make targetclean"
make targetclean
echo "$CONFIG_TOOLCHAIN_BUILD_VER" > .toolchain_build_ver
exit 0

1
toolchain/build_version Normal file
View File

@ -0,0 +1 @@
1