Skip to content

Commit a8f7be7

Browse files
committed
rustc only builds, openbsd duplicate fix
1 parent 36eda72 commit a8f7be7

4 files changed

Lines changed: 49 additions & 47 deletions

File tree

common.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ ZJIT_RUSTC_ARGS = --crate-name=zjit \
353353
-C lto=thin \
354354
-C opt-level=3 \
355355
-C overflow-checks=on \
356-
'--out-dir=$(ZJIT_CARGO_TARGET_DIR)/release/' \
356+
'--out-dir=$(CARGO_TARGET_DIR)/release/' \
357357
$(top_srcdir)/zjit/src/lib.rs
358358

359359
all: $(SHOWFLAGS) main

configure.ac

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3926,6 +3926,7 @@ AC_ARG_ENABLE(yjit,
39263926
CARGO=
39273927
CARGO_BUILD_ARGS=
39283928
YJIT_LIBS=
3929+
RUST_JIT_SUPPORT=no
39293930
AS_CASE(["${YJIT_SUPPORT}"],
39303931
[yes|dev|stats|dev_nodebug], [
39313932
AS_IF([test x"$RUSTC" = "xno"],
@@ -3934,37 +3935,24 @@ AS_CASE(["${YJIT_SUPPORT}"],
39343935
39353936
AS_CASE(["${YJIT_SUPPORT}"],
39363937
[yes], [
3937-
rb_rust_target_subdir=release
39383938
],
39393939
[dev], [
3940-
rb_rust_target_subdir=debug
3941-
CARGO_BUILD_ARGS='--features disasm,runtime_checks'
3940+
rb_cargo_features='disasm,runtime_checks'
3941+
RUST_JIT_SUPPORT=dev
39423942
AC_DEFINE(RUBY_DEBUG, 1)
39433943
],
39443944
[dev_nodebug], [
3945-
rb_rust_target_subdir=dev_nodebug
3946-
CARGO_BUILD_ARGS='--profile dev_nodebug --features disasm'
3945+
rb_cargo_features='disasm'
3946+
RUST_JIT_SUPPORT=dev_nodebug
39473947
AC_DEFINE(YJIT_STATS, 1)
39483948
],
39493949
[stats], [
3950-
rb_rust_target_subdir=stats
3951-
CARGO_BUILD_ARGS='--profile stats'
3950+
RUST_JIT_SUPPORT=stats
39523951
AC_DEFINE(YJIT_STATS, 1)
39533952
])
39543953
3955-
AS_IF([test -n "${CARGO_BUILD_ARGS}"], [
3956-
AC_CHECK_TOOL(CARGO, [cargo], [no])
3957-
AS_IF([test x"$CARGO" = "xno"],
3958-
AC_MSG_ERROR([cargo is required. Installation instructions available at https://www.rust-lang.org/tools/install])
3959-
]))
3960-
3961-
YJIT_LIBS="target/${rb_rust_target_subdir}/libyjit.a"
3954+
YJIT_LIBS="target/release/libyjit.a"
39623955
RUST_LIB='$(YJIT_LIBS)'
3963-
RUST_JIT_SUPPORT="yjit"
3964-
AS_CASE(["$target_os"],[openbsd*],[
3965-
# Link libc++abi (which requires libpthread) for _Unwind_* functions needed by yjit
3966-
LDFLAGS="$LDFLAGS -lpthread -lc++abi"
3967-
])
39683956
YJIT_OBJ='yjit.$(OBJEXT)'
39693957
JIT_OBJ='jit.$(OBJEXT)'
39703958
AS_IF([test x"$YJIT_SUPPORT" != "xyes" ], [
@@ -3984,37 +3972,16 @@ AS_CASE(["${ZJIT_SUPPORT}"],
39843972
39853973
AS_CASE(["${ZJIT_SUPPORT}"],
39863974
[yes], [
3987-
rb_rust_target_subdir=release
39883975
],
39893976
[dev], [
3990-
rb_rust_target_subdir=debug
3991-
CARGO_BUILD_ARGS="${CARGO_BUILD_ARGS} --profile dev --features disasm,zjit"
3977+
RUST_JIT_SUPPORT=dev
39923978
AC_DEFINE(RUBY_DEBUG, 1)
39933979
])
39943980
3995-
dnl TODO(alan): for commit message: note that for combo builds, when one is in dev mode everyone is in dev mode.
3996-
AS_IF([test -n "${CARGO_BUILD_ARGS}" -o x"$YJIT_SUPPORT" != "xno"], [dnl YJIT+ZJIT build
3997-
AC_CHECK_TOOL(CARGO, [cargo], [no])
3998-
AS_IF([test x"$CARGO" = "xno"],
3999-
AC_MSG_ERROR([failed to find "cargo" for building YJIT and ZJIT together]))
4000-
YJIT_LIBS=
4001-
ZJIT_LIBS=
4002-
# default when CARGO_BUILD_ARGS is not set
4003-
CARGO_BUILD_ARGS="${CARGO_BUILD_ARGS:---release --features yjit,zjit}"
4004-
RUST_LIB="target/${rb_rust_target_subdir}/libjit.a"
4005-
RUST_JIT_SUPPORT="$ZJIT_SUPPORT"
4006-
], [
4007-
ZJIT_LIBS="target/${rb_rust_target_subdir}/libzjit.a"
4008-
RUST_LIB='$(ZJIT_LIBS)'
4009-
RUST_JIT_SUPPORT="zjit"
4010-
])
4011-
3981+
ZJIT_LIBS="target/release/libzjit.a"
3982+
RUST_LIB='$(ZJIT_LIBS)'
40123983
ZJIT_OBJ='zjit.$(OBJEXT)'
40133984
JIT_OBJ='jit.$(OBJEXT)'
4014-
AS_CASE(["$target_os"],[openbsd*],[
4015-
# Link libc++abi (which requires libpthread) for _Unwind_* functions needed by yjit
4016-
LDFLAGS="$LDFLAGS -lpthread -lc++abi"
4017-
])
40183985
AS_IF([test x"$ZJIT_SUPPORT" != "xyes" ], [
40193986
AC_DEFINE_UNQUOTED(ZJIT_SUPPORT, [$ZJIT_SUPPORT])
40203987
])
@@ -4023,6 +3990,41 @@ dnl TODO(alan): for commit message: note that for combo builds, when one is in d
40233990
AC_DEFINE(USE_ZJIT, 0)
40243991
])
40253992

3993+
# if YJIT+ZJIT release build, or any build that requires Cargo
3994+
AS_IF([test x"$RUST_JIT_SUPPORT" != "xno" -o \( x"$YJIT_SUPPORT" != "xno" -a x"$ZJIT_SUPPORT" != "xno" \)], [
3995+
AC_CHECK_TOOL(CARGO, [cargo], [no])
3996+
AS_IF([test x"$CARGO" = "xno"],
3997+
AC_MSG_ERROR([cargo is required. Installation instructions available at https://www.rust-lang.org/tools/install]))
3998+
3999+
YJIT_LIBS=
4000+
ZJIT_LIBS=
4001+
4002+
AS_IF([test x"${YJIT_SUPPORT}" != x"no"], [
4003+
rb_cargo_features="$rb_cargo_features,yjit"
4004+
])
4005+
AS_IF([test x"${ZJIT_SUPPORT}" != x"no"], [
4006+
rb_cargo_features="$rb_cargo_features,zjit"
4007+
])
4008+
# if YJIT and ZJIT release mode
4009+
AS_IF([test "${YJIT_SUPPORT}:${ZJIT_SUPPORT}" = "yes:yes"], [
4010+
RUST_JIT_SUPPORT=release
4011+
])
4012+
CARGO_BUILD_ARGS="--profile ${RUST_JIT_SUPPORT} --features ${rb_cargo_features}"
4013+
AS_IF([test "${RUST_JIT_SUPPORT}" = "dev"], [
4014+
RUST_LIB="target/debug/libjit.a"
4015+
], [
4016+
RUST_LIB="target/${RUST_JIT_SUPPORT}/libjit.a"
4017+
])
4018+
])
4019+
4020+
# In case either we're linking rust code
4021+
AS_IF([test -n "$RUST_LIB"], [
4022+
AS_CASE(["$target_os"],[openbsd*],[
4023+
# Link libc++abi (which requires libpthread) for _Unwind_* functions needed by rust stdlib
4024+
LDFLAGS="$LDFLAGS -lpthread -lc++abi"
4025+
])
4026+
])
4027+
40264028
dnl These variables end up in ::RbConfig::CONFIG
40274029
AC_SUBST(RUSTC)dnl Rust compiler command
40284030
AC_SUBST(CARGO)dnl Cargo command for Rust builds

defs/gmake.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ include $(top_srcdir)/zjit/zjit.mk
450450
# rebuild at the next build.
451451
RUST_LIB_TOUCH = touch $@
452452

453-
ifeq ($(RUST_JIT_SUPPORT),$(filter yes dev dev_nodebug stats,$(RUST_JIT_SUPPORT)))
453+
ifneq ($(RUST_JIT_SUPPORT),no)
454454
$(RUST_LIB):
455455
$(Q)if [ '$(ZJIT_SUPPORT)' != no -a '$(YJIT_SUPPORT)' != no ]; then \
456456
echo 'building YJIT and ZJIT ($(RUST_JIT_SUPPORT:yes=release) mode)'; \

template/Makefile.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ ZJIT_SUPPORT=@ZJIT_SUPPORT@
110110
ZJIT_LIBS=@ZJIT_LIBS@
111111
ZJIT_OBJ=@ZJIT_OBJ@
112112
RUST_JIT_SUPPORT=@RUST_JIT_SUPPORT@
113-
CARGO_TARGET_DIR=@abs_top_builddir@/target
113+
CARGO_TARGET_DIR=@top_builddir@/target
114114
CARGO_BUILD_ARGS=@CARGO_BUILD_ARGS@
115-
RUST_LIB=@abs_top_builddir@/@RUST_LIB@
115+
RUST_LIB=@top_builddir@/@RUST_LIB@
116116
RUST_LIBOBJ = $(RUST_LIB:.a=.@OBJEXT@)
117117
LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
118118
EXE_LDFLAGS = $(LDFLAGS)

0 commit comments

Comments
 (0)