Skip to content

Commit 3075a77

Browse files
committed
Clean rlib target when rustc bumped up
1 parent eca5e5c commit 3075a77

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

defs/rustc.mk

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ifndef rustc-version-check
2+
rustc-version-check := target/.rustc-version
3+
target/.rustc-version:
4+
$(eval prev_version := $(if $(wildcard $@),$(shell cat $@)))
5+
$(eval curr_version := $(shell $(RUSTC) -V | cut -d' ' -f2))
6+
$(if $(filter-out $(prev_version),$(curr_version)), \
7+
rm -fr $(@D) && mkdir $(@D) && echo $(curr_version) > $@)
8+
endif

yjit/yjit.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- mode: makefile-gmake; indent-tabs-mode: t -*-
2+
include $(top_srcdir)/defs/rustc.mk
23

34
YJIT_SRC_FILES = $(wildcard \
45
$(top_srcdir)/yjit/Cargo.* \
@@ -16,14 +17,14 @@ BUILD_YJIT_LIBS = $(TOP_BUILD_DIR)/$(YJIT_LIBS)
1617
# In a YJIT-only build (no ZJIT)
1718
ifneq ($(strip $(YJIT_LIBS)),)
1819
yjit-libs: $(BUILD_YJIT_LIBS)
19-
$(BUILD_YJIT_LIBS): $(YJIT_SRC_FILES)
20+
$(BUILD_YJIT_LIBS): $(YJIT_SRC_FILES) $(rustc-version-check)
2021
$(ECHO) 'building Rust YJIT (release mode)'
2122
$(gnumake_recursive)$(Q) $(RUSTC) $(YJIT_RUSTC_ARGS)
2223
else ifneq ($(strip $(RLIB_DIR)),) # combo build
2324
# Absolute path to avoid VPATH ambiguity
2425
YJIT_RLIB = $(TOP_BUILD_DIR)/$(RLIB_DIR)/libyjit.rlib
2526

26-
$(YJIT_RLIB): $(YJIT_SRC_FILES)
27+
$(YJIT_RLIB): $(YJIT_SRC_FILES) $(rustc-version-check)
2728
$(ECHO) 'building $(@F)'
2829
$(gnumake_recursive)$(Q) $(RUSTC) '-L$(@D)' --extern=jit $(YJIT_RUSTC_ARGS)
2930

zjit/zjit.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- mode: makefile-gmake; indent-tabs-mode: t -*-
2+
include $(top_srcdir)/defs/rustc.mk
23

34
# Put no definitions when ZJIT isn't configured
45
ifneq ($(ZJIT_SUPPORT),no)
@@ -20,14 +21,14 @@ BUILD_ZJIT_LIBS = $(TOP_BUILD_DIR)/$(ZJIT_LIBS)
2021

2122
# In a ZJIT-only build (no YJIT)
2223
ifneq ($(strip $(ZJIT_LIBS)),)
23-
$(BUILD_ZJIT_LIBS): $(ZJIT_SRC_FILES)
24+
$(BUILD_ZJIT_LIBS): $(ZJIT_SRC_FILES) $(rustc-version-check)
2425
$(ECHO) 'building Rust ZJIT (release mode)'
2526
$(gnumake_recursive)$(Q) $(RUSTC) $(ZJIT_RUSTC_ARGS)
2627
else ifneq ($(strip $(RLIB_DIR)),) # combo build
2728
# Absolute path to avoid VPATH ambiguity
2829
ZJIT_RLIB = $(TOP_BUILD_DIR)/$(RLIB_DIR)/libzjit.rlib
2930

30-
$(ZJIT_RLIB): $(ZJIT_SRC_FILES)
31+
$(ZJIT_RLIB): $(ZJIT_SRC_FILES) $(rustc-version-check)
3132
$(ECHO) 'building $(@F)'
3233
$(gnumake_recursive)$(Q) $(RUSTC) '-L$(@D)' --extern=jit $(ZJIT_RUSTC_ARGS)
3334

0 commit comments

Comments
 (0)