@@ -22,7 +22,7 @@ RUST_LIB_TOUCH = touch $@
2222# ld: warning: object file (target/debug/libjit.a(<libcapstone object>)) was built for
2323# newer macOS version (15.2) than being linked (15.0)
2424# This limits us to an older set of macOS API in the rust code, but we don't use any.
25- $(RUST_LIB ) : $(srcdir ) /ruby.rs
25+ $(RUST_LIB ) : $(srcdir ) /ruby.rs target/.rustc-version
2626 $(Q ) if [ ' $(ZJIT_SUPPORT)' != no -a ' $(YJIT_SUPPORT)' != no ]; then \
2727 echo ' building YJIT and ZJIT ($(JIT_CARGO_SUPPORT:yes=release) mode)' ; \
2828 elif [ ' $(ZJIT_SUPPORT)' != no ]; then \
@@ -37,7 +37,7 @@ $(RUST_LIB): $(srcdir)/ruby.rs
3737 $(RUST_LIB_TOUCH )
3838else ifneq ($(strip $(RLIB_DIR)),) # combo build
3939
40- $(RUST_LIB ) : $(srcdir ) /ruby.rs
40+ $(RUST_LIB ) : $(srcdir ) /ruby.rs target/.rustc-version
4141 $(ECHO ) ' building $(@F)'
4242 $(gnumake_recursive )$(Q ) $(RUSTC ) --edition=2024 \
4343 $(RUSTC_FLAGS ) \
@@ -54,7 +54,7 @@ $(RUST_LIB): $(srcdir)/ruby.rs
5454JIT_RLIB = $(TOP_BUILD_DIR ) /$(RLIB_DIR ) /libjit.rlib
5555$(YJIT_RLIB ) : $(JIT_RLIB )
5656$(ZJIT_RLIB ) : $(JIT_RLIB )
57- $(JIT_RLIB ) :
57+ $(JIT_RLIB ) : target/.rustc-version
5858 $(ECHO ) ' building $(@F)'
5959 $(gnumake_recursive )$(Q ) $(RUSTC ) --crate-name=jit \
6060 --edition=2024 \
7777rust-libobj : $(RUST_LIBOBJ )
7878rust-lib : $(RUST_LIB )
7979
80+ rustc-version-check : target/.rustc-version
81+
82+ target/.rustc-version : PHONY
83+ $(eval prev_version := $(if $(wildcard $@ ) ,$(shell cat $@ ) ) )
84+ $(eval curr_version := $(shell $(RUSTC ) -V | cut -d' ' -f2) )
85+ $(eval clean := $(filter-out $(prev_version ) ,$(curr_version ) ) )
86+ $(if $(clean ) ,$(ECHO ) Cleaning $(@D ) for rustc $(curr_version ) )
87+ $(if $(clean ) ,$(Q )$(RMALL ) $(@D ) )
88+ $(Q )$(MAKEDIRS ) $(@D )
89+ $(Q ) echo $(curr_version ) > $@
90+
8091# For Darwin only: a list of symbols that we want the glommed Rust static lib to export.
8192# Unfortunately, using wildcard like '_rb_*' with -exported-symbol does not work, at least
8293# not on version 820.1. Assume llvm-nm, so XCode 8.0 (from 2016) or newer.
0 commit comments