cs configure: add --disable-wpo

Builing Racket CS on a 64-bit platform requires a little more than 1.5
GB of memory due to whole-program optimization of the Racket core
immplementation. Add a `--disable-wpo` configure option, which keeps
memory use below 0.5 MB to provide the option of building Racket in a
more constrained environment.
This commit is contained in:
Matthew Flatt 2020-11-03 08:11:44 -07:00
parent 7ef4ac10d2
commit 6e917a610e
5 changed files with 37 additions and 2 deletions

View File

@ -17,6 +17,11 @@ COMPRESS_COMP = # --compress
# "--srcloc" for procedure-level source locations:
DEBUG_COMP = # --debug
# To disable whole-program optimization for "main.sps", set
# `WHEN_WPO=no_` and `UNLESS_WPO=`.
WHEN_WPO =
UNLESS_WPO = no_
# For cross-compiling, set `CROSS_COMP` to `-m <machine>`, where
# the Chez Scheme directory must have "<machine>/s/xpatch":
CROSS_COMP =
@ -92,9 +97,12 @@ setup-v:
run-wpo: $(BUILDDIR)racket.so ../../bin/racket
$(SCHEME) --script $(BUILDDIR)racket.so $(RACKET_SETUP_ARGS) $(ARGS)
$(BUILDDIR)racket.so: $(BUILDDIR)main.so $(COMPILE_FILE_DEPS)
$(WHEN_WPO)$(BUILDDIR)racket.so: $(BUILDDIR)main.so $(COMPILE_FILE_DEPS)
$(COMPILE_FILE) --whole-program $(BUILDDIR)racket.so $(BUILDDIR)main.wpo
$(UNLESS_WPO)$(BUILDDIR)racket.so: $(BUILDDIR)main.so $(COMPILE_FILE_DEPS)
cat $(MAIN_DEPS) $(BUILDDIR)main.so > $(BUILDDIR)racket.so
MAIN_SRCS = main/help.ss
$(BUILDDIR)main.so: $(MAIN_DEPS) main.sps $(MAIN_SRCS) $(COMPILE_FILE_DEPS)

View File

@ -103,7 +103,7 @@ racket-so:
RACKET_SO_ENV = @CONFIGURE_RACKET_SO_COMPILE@
CS_PROGS = SCHEME="$(SCHEME)"
CS_OPTS = COMPRESS_COMP=@COMPRESS_COMP@
CS_OPTS = COMPRESS_COMP=@COMPRESS_COMP@ @ENABLE_OR_DISABLE_WPO@
CS_OPTScross = $(CS_OPTS) CSO=$(MACH) CROSS_COMP="--xpatch $(SCHEME_WORKAREA)/$(TARGET_MACH)/s/xpatch"
PASS_COMPILE_DEPS = EXTRA_COMPILE_DEPS="$(SCHEME_INC)/petite.boot $(SCHEME_INC)/scheme.boot"

View File

@ -628,6 +628,7 @@ INSTALL_SETUP_FLAGS
RUN_RACKET
CROSS_COMPILE_TARGET_KIND
COMP_SUBDIR_CONFIGURE_ARGS
ENABLE_OR_DISABLE_WPO
CS_COMPILED_SUBDIR
CS_INSTALLED
FRAMEWORK_REL_INSTALL
@ -774,6 +775,7 @@ enable_shared
enable_standalone
enable_pthread
enable_iconv
enable_wpo
enable_compress
enable_compressboot
enable_origtree
@ -1420,6 +1422,7 @@ Optional Features:
--enable-standalone create a standalone shared library
--enable-pthread link with pthreads (usually auto-enabled if needed)
--enable-iconv use iconv (usually auto-enabled)
--enable-wpo agressively optimize Racket core (enabled by default)
--enable-compress compress compiled code (enabled by default)
--enable-compressboot compress boot files
--enable-origtree install with original directory structure
@ -2528,6 +2531,11 @@ if test "${enable_iconv+set}" = set; then :
enableval=$enable_iconv;
fi
# Check whether --enable-wpo was given.
if test "${enable_wpo+set}" = set; then :
enableval=$enable_wpo;
fi
# Check whether --enable-compress was given.
if test "${enable_compress+set}" = set; then :
enableval=$enable_compress;
@ -2971,6 +2979,13 @@ $as_echo "#define CS_COMPILED_SUBDIR 1" >>confdefs.h
fi
show_explicitly_disabled "${enable_wpo}" "Agressive core optimization"
if test "${enable_wpo}" = "no" ; then
ENABLE_OR_DISABLE_WPO="WHEN_WPO=no_ UNLESS_WPO="
else
ENABLE_OR_DISABLE_WPO=""
fi
############## Install targets ################
PREFIX_PATH_RELATIVE=/../..
@ -5621,6 +5636,7 @@ SCHEME_CROSS_CONFIG_ARGS="--machine=${TARGET_MACH} --disable-x11 ${cs_auto_flags
makefiles="Makefile"

View File

@ -16,6 +16,7 @@ AC_ARG_ENABLE(shared, [ --enable-shared create shared libraries (no
AC_ARG_ENABLE(standalone, [ --enable-standalone create a standalone shared library])
AC_ARG_ENABLE(pthread, [ --enable-pthread link with pthreads (usually auto-enabled if needed)])
AC_ARG_ENABLE(iconv, [ --enable-iconv use iconv (usually auto-enabled)])
AC_ARG_ENABLE(wpo, [ --enable-wpo agressively optimize Racket core (enabled by default)])
AC_ARG_ENABLE(compress, [ --enable-compress compress compiled code (enabled by default)])
AC_ARG_ENABLE(compressboot, [ --enable-compressboot compress boot files])
m4_include(../ac/path_arg.m4)
@ -108,6 +109,13 @@ else
AC_DEFINE(CS_COMPILED_SUBDIR,1,[Use a subdirectory of "compiled"])
fi
show_explicitly_disabled "${enable_wpo}" "Agressive core optimization"
if test "${enable_wpo}" = "no" ; then
ENABLE_OR_DISABLE_WPO="WHEN_WPO=no_ UNLESS_WPO="
else
ENABLE_OR_DISABLE_WPO=""
fi
############## Install targets ################
PREFIX_PATH_RELATIVE=/../..
@ -748,6 +756,7 @@ AC_SUBST(FRAMEWORK_PREFIX)
AC_SUBST(FRAMEWORK_REL_INSTALL)
AC_SUBST(CS_INSTALLED)
AC_SUBST(CS_COMPILED_SUBDIR)
AC_SUBST(ENABLE_OR_DISABLE_WPO)
AC_SUBST(COMP_SUBDIR_CONFIGURE_ARGS)
AC_SUBST(CROSS_COMPILE_TARGET_KIND)
AC_SUBST(RUN_RACKET)

View File

@ -113,6 +113,8 @@
[whole-program?
(unless (= 1 (length deps))
(error 'compile-file "expected a single dependency for whole-program compilation"))
(printf "Whole-program optimizaton for Racket core...\n")
(printf " [If this runs out of memory, try configuring with `--disable-wpo`]\n")
(unless (equal? build-dir "")
(library-directories (list (cons "." build-dir))))
(compile-whole-program (car deps) src #t)]