mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 12:14:51 +00:00
Support customizable rustc_flags for rustc builds.
Add `rustc_flags` option for configure that appends to RUSTC_FLAGS flags used when compiling with rustc for customizable build flags. It appends to existing defaults in RUSTC_FLAGS. Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
This commit is contained in:
parent
1abb609d66
commit
25c72b0e8e
Notes:
git
2026-01-07 04:55:33 +00:00
10
common.mk
10
common.mk
@ -269,21 +269,15 @@ MAKE_LINK = $(MINIRUBY) -rfileutils -e "include FileUtils::Verbose" \
|
|||||||
# For release builds
|
# For release builds
|
||||||
YJIT_RUSTC_ARGS = --crate-name=yjit \
|
YJIT_RUSTC_ARGS = --crate-name=yjit \
|
||||||
$(JIT_RUST_FLAGS) \
|
$(JIT_RUST_FLAGS) \
|
||||||
|
$(RUSTC_FLAGS) \
|
||||||
--edition=2021 \
|
--edition=2021 \
|
||||||
-g \
|
|
||||||
-C lto=thin \
|
|
||||||
-C opt-level=3 \
|
|
||||||
-C overflow-checks=on \
|
|
||||||
'--out-dir=$(CARGO_TARGET_DIR)/release/' \
|
'--out-dir=$(CARGO_TARGET_DIR)/release/' \
|
||||||
'$(top_srcdir)/yjit/src/lib.rs'
|
'$(top_srcdir)/yjit/src/lib.rs'
|
||||||
|
|
||||||
ZJIT_RUSTC_ARGS = --crate-name=zjit \
|
ZJIT_RUSTC_ARGS = --crate-name=zjit \
|
||||||
$(JIT_RUST_FLAGS) \
|
$(JIT_RUST_FLAGS) \
|
||||||
|
$(RUSTC_FLAGS) \
|
||||||
--edition=2024 \
|
--edition=2024 \
|
||||||
-g \
|
|
||||||
-C lto=thin \
|
|
||||||
-C opt-level=3 \
|
|
||||||
-C overflow-checks=on \
|
|
||||||
'--out-dir=$(CARGO_TARGET_DIR)/release/' \
|
'--out-dir=$(CARGO_TARGET_DIR)/release/' \
|
||||||
'$(top_srcdir)/zjit/src/lib.rs'
|
'$(top_srcdir)/zjit/src/lib.rs'
|
||||||
|
|
||||||
|
|||||||
@ -69,6 +69,7 @@ dnl 93(bright yellow) is copied from .github/workflows/mingw.yml
|
|||||||
AC_ARG_VAR([cflags], [additional CFLAGS (ignored when CFLAGS is given)])dnl
|
AC_ARG_VAR([cflags], [additional CFLAGS (ignored when CFLAGS is given)])dnl
|
||||||
AC_ARG_VAR([cppflags], [additional CPPFLAGS (ignored when CPPFLAGS is given)])dnl
|
AC_ARG_VAR([cppflags], [additional CPPFLAGS (ignored when CPPFLAGS is given)])dnl
|
||||||
AC_ARG_VAR([cxxflags], [additional CXXFLAGS (ignored when CXXFLAGS is given)])dnl
|
AC_ARG_VAR([cxxflags], [additional CXXFLAGS (ignored when CXXFLAGS is given)])dnl
|
||||||
|
AC_ARG_VAR([rustc_flags], [additional RUSTC_FLAGS])dnl
|
||||||
|
|
||||||
[begin]_group "environment section" && {
|
[begin]_group "environment section" && {
|
||||||
HAVE_BASERUBY=yes
|
HAVE_BASERUBY=yes
|
||||||
@ -4049,6 +4050,11 @@ AS_CASE(["${ZJIT_SUPPORT}"],
|
|||||||
AC_DEFINE(USE_ZJIT, 0)
|
AC_DEFINE(USE_ZJIT, 0)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
RUSTC_FLAGS='-g -C lto=thin -C opt-level=3 -C overflow-checks=on'
|
||||||
|
AS_IF([test -n "${rustc_flags}"], [
|
||||||
|
RUSTC_FLAGS="${RUSTC_FLAGS} ${rustc_flags}"
|
||||||
|
])
|
||||||
|
|
||||||
JIT_RUST_FLAGS='--crate-type=staticlib --cfg feature=\"stats_allocator\"'
|
JIT_RUST_FLAGS='--crate-type=staticlib --cfg feature=\"stats_allocator\"'
|
||||||
RLIB_DIR=
|
RLIB_DIR=
|
||||||
AS_CASE(["$JIT_CARGO_SUPPORT:$YJIT_SUPPORT:$ZJIT_SUPPORT"],
|
AS_CASE(["$JIT_CARGO_SUPPORT:$YJIT_SUPPORT:$ZJIT_SUPPORT"],
|
||||||
@ -4106,6 +4112,7 @@ AS_IF([test -n "$RUST_LIB"], [
|
|||||||
dnl These variables end up in ::RbConfig::CONFIG
|
dnl These variables end up in ::RbConfig::CONFIG
|
||||||
AC_SUBST(RUSTC)dnl Rust compiler command
|
AC_SUBST(RUSTC)dnl Rust compiler command
|
||||||
AC_SUBST(JIT_RUST_FLAGS)dnl the common rustc flags for JIT crates such as zjit
|
AC_SUBST(JIT_RUST_FLAGS)dnl the common rustc flags for JIT crates such as zjit
|
||||||
|
AC_SUBST(RUSTC_FLAGS)dnl user-configurable rustc compiler flags
|
||||||
AC_SUBST(CARGO)dnl Cargo command for Rust builds
|
AC_SUBST(CARGO)dnl Cargo command for Rust builds
|
||||||
AC_SUBST(CARGO_BUILD_ARGS)dnl for selecting Rust build profiles
|
AC_SUBST(CARGO_BUILD_ARGS)dnl for selecting Rust build profiles
|
||||||
AC_SUBST(YJIT_SUPPORT)dnl what flavor of YJIT the Ruby build includes
|
AC_SUBST(YJIT_SUPPORT)dnl what flavor of YJIT the Ruby build includes
|
||||||
@ -4838,6 +4845,7 @@ config_summary "strip command" "$STRIP"
|
|||||||
config_summary "install doc" "$DOCTARGETS"
|
config_summary "install doc" "$DOCTARGETS"
|
||||||
config_summary "YJIT support" "$YJIT_SUPPORT"
|
config_summary "YJIT support" "$YJIT_SUPPORT"
|
||||||
config_summary "ZJIT support" "$ZJIT_SUPPORT"
|
config_summary "ZJIT support" "$ZJIT_SUPPORT"
|
||||||
|
config_summary "RUSTC_FLAGS" "$RUSTC_FLAGS"
|
||||||
config_summary "man page type" "$MANTYPE"
|
config_summary "man page type" "$MANTYPE"
|
||||||
config_summary "search path" "$search_path"
|
config_summary "search path" "$search_path"
|
||||||
config_summary "static-linked-ext" ${EXTSTATIC:+"yes"}
|
config_summary "static-linked-ext" ${EXTSTATIC:+"yes"}
|
||||||
|
|||||||
@ -40,6 +40,7 @@ else ifneq ($(strip $(RLIB_DIR)),) # combo build
|
|||||||
$(RUST_LIB): $(srcdir)/ruby.rs
|
$(RUST_LIB): $(srcdir)/ruby.rs
|
||||||
$(ECHO) 'building $(@F)'
|
$(ECHO) 'building $(@F)'
|
||||||
$(gnumake_recursive)$(Q) $(RUSTC) --edition=2024 \
|
$(gnumake_recursive)$(Q) $(RUSTC) --edition=2024 \
|
||||||
|
$(RUSTC_FLAGS) \
|
||||||
'-L$(@D)' \
|
'-L$(@D)' \
|
||||||
--extern=yjit \
|
--extern=yjit \
|
||||||
--extern=zjit \
|
--extern=zjit \
|
||||||
@ -58,6 +59,7 @@ $(JIT_RLIB):
|
|||||||
$(gnumake_recursive)$(Q) $(RUSTC) --crate-name=jit \
|
$(gnumake_recursive)$(Q) $(RUSTC) --crate-name=jit \
|
||||||
--edition=2024 \
|
--edition=2024 \
|
||||||
$(JIT_RUST_FLAGS) \
|
$(JIT_RUST_FLAGS) \
|
||||||
|
$(RUSTC_FLAGS) \
|
||||||
'--out-dir=$(@D)' \
|
'--out-dir=$(@D)' \
|
||||||
'$(top_srcdir)/jit/src/lib.rs'
|
'$(top_srcdir)/jit/src/lib.rs'
|
||||||
endif # ifneq ($(JIT_CARGO_SUPPORT),no)
|
endif # ifneq ($(JIT_CARGO_SUPPORT),no)
|
||||||
|
|||||||
@ -115,6 +115,7 @@ CARGO_TARGET_DIR=@abs_top_builddir@/target
|
|||||||
CARGO_BUILD_ARGS=@CARGO_BUILD_ARGS@
|
CARGO_BUILD_ARGS=@CARGO_BUILD_ARGS@
|
||||||
ZJIT_TEST_FEATURES=@ZJIT_TEST_FEATURES@
|
ZJIT_TEST_FEATURES=@ZJIT_TEST_FEATURES@
|
||||||
JIT_RUST_FLAGS=@JIT_RUST_FLAGS@
|
JIT_RUST_FLAGS=@JIT_RUST_FLAGS@
|
||||||
|
RUSTC_FLAGS=@RUSTC_FLAGS@
|
||||||
RLIB_DIR=@RLIB_DIR@
|
RLIB_DIR=@RLIB_DIR@
|
||||||
RUST_LIB=@RUST_LIB@
|
RUST_LIB=@RUST_LIB@
|
||||||
RUST_LIBOBJ = $(RUST_LIB:.a=.@OBJEXT@)
|
RUST_LIBOBJ = $(RUST_LIB:.a=.@OBJEXT@)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user