2022-05-27 05:27:15 +03: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 09:22:22 +03: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-27 05:27:15 +03:00
|
|
|
|
2022-09-14 09:23:04 +03: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-27 05:27:15 +03:00
|
|
|
# YJIT_SUPPORT=yes when `configure` gets `--enable-yjit`
|
2022-08-19 09:22:22 +03:00
|
|
|
ifeq ($(YJIT_SUPPORT),yes)
|
|
|
|
$(YJIT_LIBS): $(YJIT_SRC_FILES)
|
2022-05-27 05:27:15 +03:00
|
|
|
$(ECHO) 'building Rust YJIT (release mode)'
|
2022-09-20 15:36:06 +03:00
|
|
|
$(Q) $(RUSTC) $(YJIT_RUSTC_ARGS)
|
2022-09-14 09:23:04 +03:00
|
|
|
$(YJIT_LIB_TOUCH)
|
2022-08-19 09:22:22 +03:00
|
|
|
else ifeq ($(YJIT_SUPPORT),no)
|
|
|
|
$(YJIT_LIBS):
|
2022-05-27 05:27:15 +03:00
|
|
|
$(ECHO) 'Error: Tried to build YJIT without configuring it first. Check `make showconfig`?'
|
|
|
|
@false
|
2022-08-19 09:22:22 +03:00
|
|
|
else ifeq ($(YJIT_SUPPORT),$(filter dev dev_nodebug stats,$(YJIT_SUPPORT)))
|
|
|
|
$(YJIT_LIBS): $(YJIT_SRC_FILES)
|
2022-07-07 08:14:25 +03:00
|
|
|
$(ECHO) 'building Rust YJIT ($(YJIT_SUPPORT) mode)'
|
2022-05-27 05:27:15 +03: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 09:23:04 +03:00
|
|
|
$(YJIT_LIB_TOUCH)
|
2022-08-19 09:22:22 +03:00
|
|
|
else
|
|
|
|
endif
|
2022-05-27 05:27:15 +03:00
|
|
|
|
2023-01-18 23:58:35 +03:00
|
|
|
yjit-libobj: $(YJIT_LIBOBJ)
|
|
|
|
|
|
|
|
# Note, BSD handling is in yjit/not_gmake.mk
|
|
|
|
YJIT_LIB_SYMBOLS = $(YJIT_LIBS:.a=).symbols
|
|
|
|
$(YJIT_LIBOBJ): $(YJIT_LIBS)
|
|
|
|
$(ECHO) 'partial linking $(YJIT_LIBS) into $@'
|
|
|
|
ifneq ($(findstring linux,$(target_os)),)
|
|
|
|
$(Q) $(LD) -r -o $@ --whole-archive $(YJIT_LIBS)
|
|
|
|
-$(Q) $(OBJCOPY) --wildcard --keep-global-symbol='$(SYMBOL_PREFIX)rb_*' $(@)
|
|
|
|
else ifneq ($(findstring darwin,$(target_os)),)
|
|
|
|
$(Q) $(CC) -nodefaultlibs -r -o $@ -exported_symbols_list $(YJIT_LIB_SYMBOLS) $(YJIT_LIBS)
|
|
|
|
else
|
|
|
|
false
|
|
|
|
endif
|
|
|
|
|
|
|
|
# For Darwin only: a list of symbols that we want the glommed Rust static lib to export.
|
|
|
|
# Unfortunately, using wildcard like '_rb_*' with -exported-symbol does not work, at least
|
|
|
|
# not on version 820.1. Assume llvm-nm, so XCode 8.0 (from 2016) or newer.
|
|
|
|
#
|
|
|
|
# The -exported_symbols_list pulls out the right archive members. Symbols not listed
|
|
|
|
# in the list are made private extern, which are in turn made local as we're using `ld -r`.
|
|
|
|
# Note, section about -keep_private_externs in ld's man page hints at this behavior on which
|
|
|
|
# we rely.
|
|
|
|
ifneq ($(findstring darwin,$(target_os)),)
|
|
|
|
$(YJIT_LIB_SYMBOLS): $(YJIT_LIBS)
|
2023-01-31 13:42:01 +03:00
|
|
|
$(Q) $(tooldir)/darwin-ar $(NM) --no-llvm-bc --defined-only --extern-only $(YJIT_LIBS) | \
|
2023-01-18 23:58:35 +03:00
|
|
|
sed -n -e 's/.* //' -e '/^$(SYMBOL_PREFIX)rb_/p' \
|
|
|
|
-e '/^$(SYMBOL_PREFIX)rust_eh_personality/p' \
|
|
|
|
> $@
|
|
|
|
|
|
|
|
$(YJIT_LIBOBJ): $(YJIT_LIB_SYMBOLS)
|
|
|
|
endif
|
2022-05-27 05:27:15 +03:00
|
|
|
|
2022-09-20 00:07:28 +03:00
|
|
|
# By using YJIT_BENCH_OPTS instead of RUN_OPTS, you can skip passing the options to `make install`
|
|
|
|
YJIT_BENCH_OPTS = $(RUN_OPTS) --enable-gems
|
|
|
|
YJIT_BENCH = benchmarks/railsbench/benchmark.rb
|
|
|
|
|
|
|
|
# Run yjit-bench's ./run_once.sh for CI
|
|
|
|
yjit-bench: install update-yjit-bench PHONY
|
|
|
|
$(Q) cd $(srcdir)/yjit-bench && PATH=$(prefix)/bin:$$PATH \
|
|
|
|
./run_once.sh $(YJIT_BENCH_OPTS) $(YJIT_BENCH)
|
|
|
|
|
|
|
|
update-yjit-bench:
|
|
|
|
$(Q) $(tooldir)/git-refresh -C $(srcdir) --branch main \
|
|
|
|
https://github.com/Shopify/yjit-bench yjit-bench $(GIT_OPTS)
|
|
|
|
|
2023-02-23 19:49:00 +03:00
|
|
|
# Gives quick feedback about YJIT. Not a replacement for a full test run.
|
|
|
|
.PHONY: yjit-smoke-test
|
|
|
|
yjit-smoke-test:
|
|
|
|
ifneq ($(strip $(CARGO)),)
|
|
|
|
$(CARGO) test --all-features -q --manifest-path='$(top_srcdir)/yjit/Cargo.toml'
|
|
|
|
endif
|
|
|
|
$(MAKE) btest RUN_OPTS='--yjit-call-threshold=1' BTESTS=-j
|
|
|
|
$(MAKE) test-all TESTS='$(top_srcdir)/test/ruby/test_yjit.rb'
|
|
|
|
|
2022-05-27 05:27:15 +03:00
|
|
|
# Generate Rust bindings. See source for details.
|
|
|
|
# Needs `./configure --enable-yjit=dev` and Clang.
|
|
|
|
ifneq ($(strip $(CARGO)),) # if configure found Cargo
|
2022-06-29 19:49:46 +03:00
|
|
|
.PHONY: yjit-bindgen yjit-bindgen-show-unused
|
2022-05-27 05:27:15 +03: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-12-14 09:25:47 +03:00
|
|
|
$(Q) if [ 'x$(HAVE_GIT)' = xyes ]; then $(GIT) -C "$(top_srcdir)" diff --exit-code yjit/src/cruby_bindings.inc.rs; fi
|
2022-05-27 05:27:15 +03:00
|
|
|
|
2022-06-29 19:49:46 +03: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-27 05:27:15 +03:00
|
|
|
endif
|