configure and makesfiles: make code compression more configurable

Add a `configure` argument to enable even more compression in ".zo"
forms, and introduce environment variables to enable compression
control for Windows builds using MSVC.
This commit is contained in:
Matthew Flatt 2021-04-06 13:57:34 -06:00
parent 069e6d1417
commit 548aca02e7
9 changed files with 73 additions and 9 deletions

View File

@ -783,6 +783,7 @@ enable_pthread
enable_iconv
enable_wpo
enable_compress
enable_compressmore
enable_compressboot
enable_origtree
enable_sharezo
@ -1432,6 +1433,7 @@ Optional Features:
--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-compressmore compress compiled code even more
--enable-compressboot compress boot files
--enable-origtree install with original directory structure
--enable-sharezo install ".zo"s to "share", not "lib"
@ -2550,6 +2552,11 @@ if test "${enable_compress+set}" = set; then :
enableval=$enable_compress;
fi
# Check whether --enable-compressmore was given.
if test "${enable_compressmore+set}" = set; then :
enableval=$enable_compressmore;
fi
# Check whether --enable-compressboot was given.
if test "${enable_compressboot+set}" = set; then :
enableval=$enable_compressboot;
@ -2821,6 +2828,7 @@ fi
show_explicitly_enabled "${enable_pthread}" "pthreads"
show_explicitly_disabled "${enable_pthread}" "pthreads"
show_explicitly_disabled "${enable_compress}" "Compressed code"
show_explicitly_disabled "${enable_compressmore}" "Compressed code even more"
show_explicitly_enabled "${enable_compressboot}" "Compressed boot files"
show_explicitly_enabled "${enable_xonx}" "Unix style"
show_explicitly_enabled "${enable_libzo}" 'Compiled ".zo" files moved to lib'
@ -4677,6 +4685,9 @@ fi
if test "${enable_compress}" != "no" ; then
COMPRESS_COMP="--compress"
fi
if test "${enable_compressmore}" = "yes" ; then
COMPRESS_COMP="--compress-more"
fi
if test "${enable_compressboot}" = "yes" ; then
BOOT_COMPRESS_COMP="--compress"

View File

@ -18,6 +18,7 @@ AC_ARG_ENABLE(pthread, [ --enable-pthread link with pthreads (usually
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(compressmore, [ --enable-compressmore compress compiled code even more])
AC_ARG_ENABLE(compressboot, [ --enable-compressboot compress boot files])
m4_include(../ac/path_arg.m4)
AC_ARG_ENABLE(racket, [ --enable-racket=<path> use <path> as Racket for build; or "auto" to create])
@ -72,6 +73,7 @@ fi
show_explicitly_enabled "${enable_pthread}" "pthreads"
show_explicitly_disabled "${enable_pthread}" "pthreads"
show_explicitly_disabled "${enable_compress}" "Compressed code"
show_explicitly_disabled "${enable_compressmore}" "Compressed code even more"
show_explicitly_enabled "${enable_compressboot}" "Compressed boot files"
show_explicitly_enabled "${enable_xonx}" "Unix style"
m4_include(../ac/path_show.m4)
@ -489,6 +491,9 @@ fi
if test "${enable_compress}" != "no" ; then
COMPRESS_COMP="--compress"
fi
if test "${enable_compressmore}" = "yes" ; then
COMPRESS_COMP="--compress-more"
fi
if test "${enable_compressboot}" = "yes" ; then
BOOT_COMPRESS_COMP="--compress"

View File

@ -67,6 +67,12 @@
(fasl-compressed #t)
(putenv "PLT_CS_MAKE_COMPRESSED" "y") ; for "linklet.sls"
(loop args))]
[(get-opt args "--compress-more" 0)
=> (lambda (args)
(fasl-compressed #t)
(putenv "PLT_CS_MAKE_COMPRESSED" "y") ; for "linklet.sls"
(putenv "PLT_CS_MAKE_COMPRESSED_DATA" "y") ; ditto
(loop args))]
[(get-opt args "--whole-program" 0)
=> (lambda (args)
(set! whole-program? #t)

View File

@ -39,3 +39,6 @@ cstartup.exe
/bc_suffix_new.h
/compiled
/liblz4.dll
/liblz4.lib
/liblz4.exp

View File

@ -50,6 +50,12 @@ Many intermediate files will be put in "../build".
To add a "CS" suffix to the generated executables, call "csbuild.rkt"
with `--racketcs-suffix "CS"`.
To enable compression of embedded boot files, set the
`PLT_BOOTFILE_COMPRESS` environment variable (to anything). To
increase compression of compiled code (at the expense of load times),
set the `PLT_CS_MAKE_COMPRESSED_DATA`. To instead disable the
compression of compiled code, set `PLT_CS_MAKE_NO_COMPRESSED`.
See also "Completing the Build" below.
Racket BC

View File

@ -10,6 +10,9 @@ LIBS = $(RKTIO_LIB) \
$(SCHEME_LIB_FULL) \
$(WIN32_LIBS)
LZ4_DLL = ..\liblz4.dll
LZ4_LIB = $(SCHEME_DIR)\$(MACHINE)\lz4\lib\liblz4.lib
DEST_DLL = ..\..\build\raw_libracketcs.dll
DEST = ..\..\build\raw_racketcs.exe
GDEST = ..\..\build\raw_gracketcs.exe
@ -27,7 +30,7 @@ MEMMOD = ..\..\start\MemoryModule.c
FLAGS = /DWIN32 /Ox /MT /GF
COMP_SUBDIR = /DCS_COMPILED_SUBDIR=1
all: $(DEST) $(GDEST)
all: $(DEST) $(GDEST) $(LZ4_DLL)
$(DEST_DLL): $(CSDIR)\boot.c libracket.res $(RKTIO_LIB) $(SCHEME_LIB_FULL)
cl /LD /DLL /Fe$(DEST_DLL) $(FLAGS) $(INCS) $(CSDIR)\boot.c libracket.res $(LIBS)
@ -47,6 +50,11 @@ $(GDEST): $(CSDIR)\grmain.c $(CSDIR)\main.c $(MAIN_DEPS) $(DEST_DLL) gracket.res
gracket.res: ../gracket/gracket.rc ../gracket/gracket.ico
rc /l 0x409 /fogracket.res ../gracket/gracket.rc
# Useful for adjusting boot file compression:
$(LZ4_DLL): lz4.c lz4.def
cl /LD /DLL /Fe$(LZ4_DLL) $(FLAGS) lz4.c $(LZ4_LIB) $(WIN32_LIBS) /link /DEF:lz4.def
# Useful for debugging:
RKTIO_DLL = ..\..\lib\librktio.dll

View File

@ -0,0 +1,9 @@
extern void LZ4_decompress_safe(void);
extern void LZ4_compressBound(void);
extern void LZ4_compress_default(void);
void lz4_stub(void) {
LZ4_decompress_safe();
LZ4_compressBound();
LZ4_compress_default();
}

View File

@ -0,0 +1,4 @@
EXPORTS
LZ4_decompress_safe
LZ4_compressBound
LZ4_compress_default

View File

@ -8,6 +8,11 @@
"cs/prep.rkt"
"cs/recompile.rkt")
;; Environment variables that affect the build:
;; PLT_BOOTFILE_COMPRESS - enables compression of boot files
;; PLT_CS_MAKE_COMPRESSED_DATA - enables more ".zo" compression
;; PLT_CS_MAKE_NO_COMPRESSED - disables default ".zo" compression
(define-runtime-path here ".")
(define scheme-dir (build-path 'up "ChezScheme"))
@ -139,7 +144,8 @@
(parameterize ([current-directory (build-path 'up "cs")])
(define convert.d (build-path build-dir "compiled" "convert.d"))
(unless (file-exists? convert.d) (call-with-output-file convert.d void))
(putenv "PLT_CS_MAKE_COMPRESSED" "yes")
(unless (getenv "PLT_CS_MAKE_NO_COMPRESSED")
(putenv "PLT_CS_MAKE_COMPRESSED" "yes"))
(system*! "nmake"
(build-path "../build/racket.so") ; need forward slashes
(format "RACKET=~a" rel-racket)
@ -220,13 +226,19 @@
args))
(make-directory* "../../lib")
(bootstrap-racket! "../cs/c/embed-boot.rkt"
"++exe" "../build/raw_racketcs.exe" (format "../../Racket~a.exe" cs-suffix)
"++exe" "../build/raw_gracketcs.exe" (format "../../lib/GRacket~a.exe" cs-suffix)
"../build/raw_libracketcs.dll" "../../lib/libracketcsxxxxxxx.dll"
"../build/petite-v.boot"
"../build/scheme-v.boot"
"../build/racket-v.boot")
(apply bootstrap-racket!
"../cs/c/embed-boot.rkt"
(append
(if (getenv "PLT_BOOTFILE_COMPRESS")
'("--compress")
'())
(list
"++exe" "../build/raw_racketcs.exe" (format "../../Racket~a.exe" cs-suffix)
"++exe" "../build/raw_gracketcs.exe" (format "../../lib/GRacket~a.exe" cs-suffix)
"../build/raw_libracketcs.dll" "../../lib/libracketcsxxxxxxx.dll"
"../build/petite-v.boot"
"../build/scheme-v.boot"
"../build/racket-v.boot")))
(system*! "mt"
"-manifest" "racket/racket.manifest"