2022-05-26 22:27:15 -04:00
|
|
|
# -*- mode: makefile-gmake; indent-tabs-mode: t -*-
|
|
|
|
|
|
|
|
# Show Cargo progress when doing `make V=1`
|
|
|
|
CARGO_VERBOSE_0 = -q
|
|
|
|
CARGO_VERBOSE_1 =
|
|
|
|
CARGO_VERBOSE = $(CARGO_VERBOSE_$(V))
|
|
|
|
|
2022-08-19 02:22:22 -04:00
|
|
|
YJIT_SRC_FILES = $(wildcard \
|
|
|
|
$(top_srcdir)/yjit/Cargo.* \
|
|
|
|
$(top_srcdir)/yjit/src/*.rs \
|
|
|
|
$(top_srcdir)/yjit/src/*/*.rs \
|
|
|
|
$(top_srcdir)/yjit/src/*/*/*.rs \
|
|
|
|
$(top_srcdir)/yjit/src/*/*/*/*.rs \
|
|
|
|
)
|
2022-05-26 22:27:15 -04:00
|
|
|
|
2022-09-14 02:23:04 -04:00
|
|
|
# Because of Cargo cache, if the actual binary is not changed from the
|
|
|
|
# previous build, the mtime is preserved as the cached file.
|
|
|
|
# This means the target is not updated actually, and it will need to
|
|
|
|
# rebuild at the next build.
|
|
|
|
YJIT_LIB_TOUCH = touch $@
|
|
|
|
|
2022-05-26 22:27:15 -04:00
|
|
|
# YJIT_SUPPORT=yes when `configure` gets `--enable-yjit`
|
2022-08-19 02:22:22 -04:00
|
|
|
ifeq ($(YJIT_SUPPORT),yes)
|
|
|
|
$(YJIT_LIBS): $(YJIT_SRC_FILES)
|
2022-05-26 22:27:15 -04:00
|
|
|
$(ECHO) 'building Rust YJIT (release mode)'
|
|
|
|
$(Q) $(RUSTC) \
|
|
|
|
--crate-name=yjit \
|
|
|
|
--crate-type=staticlib \
|
|
|
|
--edition=2021 \
|
|
|
|
-C opt-level=3 \
|
|
|
|
-C overflow-checks=on \
|
|
|
|
'--out-dir=$(CARGO_TARGET_DIR)/release/' \
|
|
|
|
$(top_srcdir)/yjit/src/lib.rs
|
2022-09-14 02:23:04 -04:00
|
|
|
$(YJIT_LIB_TOUCH)
|
2022-08-19 02:22:22 -04:00
|
|
|
else ifeq ($(YJIT_SUPPORT),no)
|
|
|
|
$(YJIT_LIBS):
|
2022-05-26 22:27:15 -04:00
|
|
|
$(ECHO) 'Error: Tried to build YJIT without configuring it first. Check `make showconfig`?'
|
|
|
|
@false
|
2022-08-19 02:22:22 -04:00
|
|
|
else ifeq ($(YJIT_SUPPORT),$(filter dev dev_nodebug stats,$(YJIT_SUPPORT)))
|
|
|
|
$(YJIT_LIBS): $(YJIT_SRC_FILES)
|
2022-07-07 01:14:25 -04:00
|
|
|
$(ECHO) 'building Rust YJIT ($(YJIT_SUPPORT) mode)'
|
2022-05-26 22:27:15 -04:00
|
|
|
$(Q)$(CHDIR) $(top_srcdir)/yjit && \
|
|
|
|
CARGO_TARGET_DIR='$(CARGO_TARGET_DIR)' \
|
|
|
|
CARGO_TERM_PROGRESS_WHEN='never' \
|
|
|
|
$(CARGO) $(CARGO_VERBOSE) build $(CARGO_BUILD_ARGS)
|
2022-09-14 02:23:04 -04:00
|
|
|
$(YJIT_LIB_TOUCH)
|
2022-08-19 02:22:22 -04:00
|
|
|
else
|
|
|
|
endif
|
2022-05-26 22:27:15 -04:00
|
|
|
|
|
|
|
# Put this here instead of in common.mk to avoid breaking nmake builds
|
|
|
|
# TODO: might need to move for BSD Make support
|
|
|
|
miniruby$(EXEEXT): $(YJIT_LIBS)
|
|
|
|
|
|
|
|
# Generate Rust bindings. See source for details.
|
|
|
|
# Needs `./configure --enable-yjit=dev` and Clang.
|
|
|
|
ifneq ($(strip $(CARGO)),) # if configure found Cargo
|
2022-06-29 12:49:46 -04:00
|
|
|
.PHONY: yjit-bindgen yjit-bindgen-show-unused
|
2022-05-26 22:27:15 -04:00
|
|
|
yjit-bindgen: yjit.$(OBJEXT)
|
|
|
|
YJIT_SRC_ROOT_PATH='$(top_srcdir)' $(CARGO) run --manifest-path '$(top_srcdir)/yjit/bindgen/Cargo.toml' -- $(CFLAGS) $(XCFLAGS) $(CPPFLAGS)
|
|
|
|
|
2022-06-29 12:49:46 -04:00
|
|
|
check-yjit-bindgen-unused: yjit.$(OBJEXT)
|
|
|
|
RUST_LOG=warn YJIT_SRC_ROOT_PATH='$(top_srcdir)' $(CARGO) run --manifest-path '$(top_srcdir)/yjit/bindgen/Cargo.toml' -- $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) 2>&1 | (! grep "unused option: --allow")
|
|
|
|
|
2022-05-26 22:27:15 -04:00
|
|
|
# For CI, check whether YJIT's FFI bindings are up-to-date.
|
2022-06-29 12:49:46 -04:00
|
|
|
check-yjit-bindings: check-yjit-bindgen-unused
|
2022-05-26 22:27:15 -04:00
|
|
|
git -C "$(top_srcdir)" diff --exit-code yjit/src/cruby_bindings.inc.rs
|
|
|
|
endif
|