first step of Racket CS cross-compilation for Windows

Adjust build process to be able to generate Racket.exe, etc, for
Racket CS using MinGW. Much of this cross-compilation support can work
for building other platforms, too, but some of the details are filled
in only for generating Windows executables.
This commit is contained in:
Matthew Flatt 2019-03-01 17:03:28 -07:00
parent 961454e011
commit 33a5c30073
20 changed files with 831 additions and 202 deletions

View File

@ -324,9 +324,6 @@ variant of MinGW without "libdelayimp.a", get the implementation of
Cross-compiling
========================================================================
[Currently, cross-compilation works only for the traditional Racket
implementation.]
Cross-compilation requires at least two flags to `configure`:
* `--host=OS`, where OS is something like `i386-gnu-linux` to
@ -337,7 +334,9 @@ Cross-compilation requires at least two flags to `configure`:
* `--enable-racket=RACKET`, where RACKET is a path to a Racket
executable that runs on the build platform; the executable must be
the same version of Racket as being built for the target platform.
the same version of Racket and the same virtual machine (i.e.,
traditional Racket or Racket on Chez Scheme) as being built for the
target platform.
This flag is needed because building and installing Racket requires
running (an existing build of) Racket.
@ -347,7 +346,14 @@ Cross-compilation requires at least two flags to `configure`:
run `configure` again (with no arguments) in a "local" subdirectory
to create a build for the current platform.
Some less commonly needed `configure` flags:
For Racket-on-Chez, an additional flag is needed:
* `--enable-scheme=SCHEME`, where SCHEME is a path to a Chez Scheme
build directory. Chez Scheme must be built there already for the
current platform, and a cross-compiled Chez Scheme will be created
in the same directory.
Some less commonly needed `configure` flags for traditional Racket:
* `--enable-stackup`, if the target platform`s stack grows up.
@ -363,8 +369,8 @@ Some less commonly needed `configure` flags:
Cross-compiling for Android
========================================================================
[Currently, cross-compilation works only for the traditional Racket
implementation.]
[Currently, cross-compilation for Android works only for the
traditional Racket implementation.]
As an example of cross-compiling, to compile for Android on ARM using
the NDK, use (all on one line)

View File

@ -1,2 +1,4 @@
*.so
*.wpo
*.ta6osx
*.ta6le

View File

@ -15,7 +15,11 @@ COMPRESS_COMP = # --compress
# "--srcloc" for procedure-level source locations:
DEBUG_COMP = # --debug
COMPILE_FILE = $(SCHEME) --script compile-file.ss $(UNSAFE_COMP) $(COMPRESS_COMP) $(DEBUG_COMP) --dest "$(BUILDDIR)"
# For cross-compiling, set `CROSS_COMP` to `-m <machine>`, where
# the Chez Scheme directory must have "<machine>/s/xpatch":
CROSS_COMP =
COMPILE_FILE = $(SCHEME) --script compile-file.ss $(UNSAFE_COMP) $(COMPRESS_COMP) $(DEBUG_COMP) $(CROSS_COMP) --dest "$(BUILDDIR)"
COMPILE_FILE_DEPS = compile-file.ss include.ss place-register.ss
RACKET_SETUP_ARGS = ../../bin/racket ../../bin/racket ../collects ../etc 0 true false 0 ""
@ -40,26 +44,33 @@ CONVERT_DEPS = $(PRIMITIVES_TABLES)
CONVERT_RACKET = $(RACKET) -l- setup --chain ../setup-go.rkt $(BUILDDIR)compiled
CONVERT = $(CONVERT_RACKET) '(CONVERTED)' $(BUILDDIR)compiled/convert.d convert.rkt $(UNSAFE_COMP)
# This extension changes for cross builds:
CSO = so
# Depenency chain for ".so" files:
RUMBLE_DEPS = $(BUILDDIR)chezpart.so
THREAD_DEPS = $(RUMBLE_DEPS) $(BUILDDIR)rumble.so
IO_DEPS = $(THREAD_DEPS) $(BUILDDIR)thread.so
REGEXP_DEPS = $(IO_DEPS) $(BUILDDIR)io.so
SCHEMIFY_DEPS = $(REGEXP_DEPS) $(BUILDDIR)regexp.so
LINKLET_DEPS = $(SCHEMIFY_DEPS) $(BUILDDIR)schemify.so
EXPANDER_DEPS = $(LINKLET_DEPS) $(BUILDDIR)linklet.so
MAIN_DEPS = $(EXPANDER_DEPS) $(BUILDDIR)expander.so
RUMBLE_DEPS = $(BUILDDIR)chezpart.$(CSO)
THREAD_DEPS = $(RUMBLE_DEPS) $(BUILDDIR)rumble.$(CSO)
IO_DEPS = $(THREAD_DEPS) $(BUILDDIR)thread.$(CSO)
REGEXP_DEPS = $(IO_DEPS) $(BUILDDIR)io.$(CSO)
SCHEMIFY_DEPS = $(REGEXP_DEPS) $(BUILDDIR)regexp.$(CSO)
LINKLET_DEPS = $(SCHEMIFY_DEPS) $(BUILDDIR)schemify.$(CSO)
EXPANDER_DEPS = $(LINKLET_DEPS) $(BUILDDIR)linklet.$(CSO)
MAIN_DEPS = $(EXPANDER_DEPS) $(BUILDDIR)expander.$(CSO)
all:
$(MAKE) rktio
$(MAKE) rktl
$(MAKE) $(BUILDDIR)racket.so
expander-demo: $(BUILDDIR)expander.so demo/expander.ss ../../bin/racket
$(SCHEME) $(EXPANDER_DEPS) $(BUILDDIR)expander.so demo/expander.ss
CROSS_TARGET = all
cross:
$(MAKE) $(CROSS_TARGET) CSO=$(HOST) CROSS_COMP="--xpatch $(XPATCH)"
run: $(BUILDDIR)main.so ../../bin/racket
$(SCHEME) --script $(BUILDDIR)main.so $(RACKET_SETUP_ARGS) $(ARGS)
expander-demo: $(BUILDDIR)expander.$(CSO) demo/expander.ss ../../bin/racket
$(SCHEME) $(EXPANDER_DEPS) $(BUILDDIR)expander.$(CSO) demo/expander.ss
run: $(BUILDDIR)main.$(CSO) ../../bin/racket
$(SCHEME) --script $(BUILDDIR)main.$(CSO) $(RACKET_SETUP_ARGS) $(ARGS)
setup:
$(MAKE) run ARGS="-l- setup $(ARGS)"
@ -70,10 +81,10 @@ 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)
$(BUILDDIR)racket.so: $(BUILDDIR)main.$(CSO) $(COMPILE_FILE_DEPS)
$(COMPILE_FILE) --whole-program $(BUILDDIR)racket.so $(BUILDDIR)main.wpo
$(BUILDDIR)main.so: $(MAIN_DEPS) main.sps main/help.ss $(COMPILE_FILE_DEPS)
$(BUILDDIR)main.$(CSO): $(MAIN_DEPS) main.sps main/help.ss $(COMPILE_FILE_DEPS)
$(COMPILE_FILE) main.sps $(MAIN_DEPS)
strip:
@ -92,7 +103,7 @@ rktl:
mkdir -p ../../bin
touch ../../bin/racket
$(BUILDDIR)expander.so: expander.sls $(BUILDDIR)compiled/expander.scm $(PRIMITIVES_TABLES) $(EXPANDER_DEPS) $(COMPILE_FILE_DEPS)
$(BUILDDIR)expander.$(CSO): expander.sls $(BUILDDIR)compiled/expander.scm $(PRIMITIVES_TABLES) $(EXPANDER_DEPS) $(COMPILE_FILE_DEPS)
$(COMPILE_FILE) expander.sls $(EXPANDER_DEPS)
$(BUILDDIR)compiled/expander.scm: $(BUILDDIR)compiled/expander.rktl $(CONVERT_DEPS)
@ -104,8 +115,8 @@ $(BUILDDIR)compiled/expander.rktl:
expander-rktl:
$(MAKE) bounce BOUNCE_DIR=../expander BOUNCE_TARGET=expander-src BUILDDIR="../cs/"
linklet-demo: $(BUILDDIR)linklet.so
$(SCHEME) $(LINKLET_DEPS) $(BUILDDIR)linklet.so demo/linklet.ss
linklet-demo: $(BUILDDIR)linklet.$(CSO)
$(SCHEME) $(LINKLET_DEPS) $(BUILDDIR)linklet.$(CSO) demo/linklet.ss
LINKLET_SRCS = linklet/read.ss \
linklet/write.ss \
@ -114,11 +125,11 @@ LINKLET_SRCS = linklet/read.ss \
linklet/compress.ss \
linklet/db.ss
$(BUILDDIR)linklet.so: linklet.sls $(LINKLET_SRCS) $(LINKLET_DEPS) $(COMPILE_FILE_DEPS)
$(BUILDDIR)linklet.$(CSO): linklet.sls $(LINKLET_SRCS) $(LINKLET_DEPS) $(COMPILE_FILE_DEPS)
$(COMPILE_FILE) linklet.sls $(LINKLET_DEPS)
$(BUILDDIR)schemify.so: schemify.sls $(BUILDDIR)compiled/schemify.scm $(BUILDDIR)compiled/known.scm $(SCHEMIFY_DEPS) $(COMPILE_FILE_DEPS)
$(BUILDDIR)schemify.$(CSO): schemify.sls $(BUILDDIR)compiled/schemify.scm $(BUILDDIR)compiled/known.scm $(SCHEMIFY_DEPS) $(COMPILE_FILE_DEPS)
$(COMPILE_FILE) schemify.sls $(SCHEMIFY_DEPS)
$(BUILDDIR)compiled/schemify.scm: $(BUILDDIR)compiled/schemify.rktl $(CONVERT_DEPS)
@ -142,10 +153,10 @@ known-rktl:
$(MAKE) bounce BOUNCE_DIR=../schemify BOUNCE_TARGET=known-src BUILDDIR="../cs/"
regexp-demo: $(BUILDDIR)regexp.so
$(SCHEME) $(REGEXP_DEPS) $(BUILDDIR)regexp.so demo/regexp.ss
regexp-demo: $(BUILDDIR)regexp.$(CSO)
$(SCHEME) $(REGEXP_DEPS) $(BUILDDIR)regexp.$(CSO) demo/regexp.ss
$(BUILDDIR)regexp.so: $(BUILDDIR)compiled/regexp.scm regexp.sls $(REGEXP_DEPS) $(COMPILE_FILE_DEPS)
$(BUILDDIR)regexp.$(CSO): $(BUILDDIR)compiled/regexp.scm regexp.sls $(REGEXP_DEPS) $(COMPILE_FILE_DEPS)
$(COMPILE_FILE) regexp.sls $(REGEXP_DEPS)
$(BUILDDIR)compiled/regexp.scm: $(BUILDDIR)compiled/regexp.rktl $(CONVERT_DEPS)
@ -158,10 +169,10 @@ regexp-rktl:
$(MAKE) bounce BOUNCE_DIR=../regexp BOUNCE_TARGET=regexp-src BUILDDIR="../cs/"
io-demo: $(BUILDDIR)io.so
$(SCHEME) $(IO_DEPS) $(BUILDDIR)io.so demo/io.ss
io-demo: $(BUILDDIR)io.$(CSO)
$(SCHEME) $(IO_DEPS) $(BUILDDIR)io.$(CSO) demo/io.ss
$(BUILDDIR)io.so: $(BUILDDIR)compiled/io.scm io.sls $(IO_DEPS) ../rktio/rktio.rktl $(COMPILE_FILE_DEPS)
$(BUILDDIR)io.$(CSO): $(BUILDDIR)compiled/io.scm io.sls $(IO_DEPS) ../rktio/rktio.rktl $(COMPILE_FILE_DEPS)
$(COMPILE_FILE) io.sls $(IO_DEPS)
$(BUILDDIR)compiled/io.scm: $(BUILDDIR)compiled/io.rktl $(CONVERT_DEPS)
@ -177,10 +188,10 @@ rktio:
$(MAKE) bounce BOUNCE_DIR=../io BOUNCE_TARGET=rktio
thread-demo: $(BUILDDIR)thread.so
$(SCHEME) $(THREAD_DEPS) $(BUILDDIR)thread.so demo/thread.ss
thread-demo: $(BUILDDIR)thread.$(CSO)
$(SCHEME) $(THREAD_DEPS) $(BUILDDIR)thread.$(CSO) demo/thread.ss
$(BUILDDIR)thread.so: $(BUILDDIR)compiled/thread.scm thread.sls $(THREAD_DEPS) $(COMPILE_FILE_DEPS)
$(BUILDDIR)thread.$(CSO): $(BUILDDIR)compiled/thread.scm thread.sls $(THREAD_DEPS) $(COMPILE_FILE_DEPS)
$(COMPILE_FILE) thread.sls $(THREAD_DEPS)
$(BUILDDIR)compiled/thread.scm: $(BUILDDIR)compiled/thread.rktl $(CONVERT_DEPS)
@ -200,29 +211,29 @@ bounce-go:
cd $(BOUNCE_DIR); $(MAKE) RACO="$(RACKET) -N raco -l- raco" $(BOUNCE_TARGET)
chaperone-demo: $(BUILDDIR)rumble.so
$(SCHEME) $(BUILDDIR)chezpart.so $(BUILDDIR)rumble.so demo/chaperone.ss
chaperone-demo: $(BUILDDIR)rumble.$(CSO)
$(SCHEME) $(BUILDDIR)chezpart.$(CSO) $(BUILDDIR)rumble.$(CSO) demo/chaperone.ss
hash-demo: $(BUILDDIR)rumble.so
$(SCHEME) $(BUILDDIR)chezpart.so $(BUILDDIR)rumble.so demo/hash.ss
hash-demo: $(BUILDDIR)rumble.$(CSO)
$(SCHEME) $(BUILDDIR)chezpart.$(CSO) $(BUILDDIR)rumble.$(CSO) demo/hash.ss
struct-demo: $(BUILDDIR)rumble.so
$(SCHEME) $(BUILDDIR)chezpart.so $(BUILDDIR)rumble.so demo/struct.ss
struct-demo: $(BUILDDIR)rumble.$(CSO)
$(SCHEME) $(BUILDDIR)chezpart.$(CSO) $(BUILDDIR)rumble.$(CSO) demo/struct.ss
control-demo: $(BUILDDIR)rumble.so
$(SCHEME) $(BUILDDIR)chezpart.so $(BUILDDIR)rumble.so demo/control.ss
control-demo: $(BUILDDIR)rumble.$(CSO)
$(SCHEME) $(BUILDDIR)chezpart.$(CSO) $(BUILDDIR)rumble.$(CSO) demo/control.ss
foreign-demo: $(BUILDDIR)rumble.so
$(SCHEME) $(BUILDDIR)chezpart.so $(BUILDDIR)rumble.so demo/foreign.ss
foreign-demo: $(BUILDDIR)rumble.$(CSO)
$(SCHEME) $(BUILDDIR)chezpart.$(CSO) $(BUILDDIR)rumble.$(CSO) demo/foreign.ss
will-demo: $(BUILDDIR)rumble.so
$(SCHEME) $(BUILDDIR)chezpart.so $(BUILDDIR)rumble.so demo/will.ss
will-demo: $(BUILDDIR)rumble.$(CSO)
$(SCHEME) $(BUILDDIR)chezpart.$(CSO) $(BUILDDIR)rumble.$(CSO) demo/will.ss
future-demo: $(BUILDDIR)rumble.so
$(SCHEME) $(BUILDDIR)chezpart.so $(BUILDDIR)rumble.so demo/future.ss
future-demo: $(BUILDDIR)rumble.$(CSO)
$(SCHEME) $(BUILDDIR)chezpart.$(CSO) $(BUILDDIR)rumble.$(CSO) demo/future.ss
future2-demo: $(BUILDDIR)rumble.so
$(SCHEME) $(BUILDDIR)chezpart.so $(BUILDDIR)rumble.so demo/future2.ss
future2-demo: $(BUILDDIR)rumble.$(CSO)
$(SCHEME) $(BUILDDIR)chezpart.$(CSO) $(BUILDDIR)rumble.$(CSO) demo/future2.ss
RUMBLE_SRCS = rumble/define.ss \
rumble/virtual-register.ss \
@ -286,16 +297,16 @@ RUMBLE_SRCS = rumble/define.ss \
rumble/inline.ss \
../racket/src/schvers.h
$(BUILDDIR)rumble.so: $(RUMBLE_DEPS) rumble.sls $(RUMBLE_SRCS) $(COMPILE_FILE_DEPS)
$(BUILDDIR)rumble.$(CSO): $(RUMBLE_DEPS) rumble.sls $(RUMBLE_SRCS) $(COMPILE_FILE_DEPS)
$(COMPILE_FILE) rumble.sls $(RUMBLE_DEPS)
$(BUILDDIR)chezpart.so: chezpart.sls $(COMPILE_FILE_DEPS)
$(BUILDDIR)chezpart.$(CSO): chezpart.sls $(COMPILE_FILE_DEPS)
$(COMPILE_FILE) chezpart.sls
clean:
rm -f chezpart.so rumble.so regexp.so io.so linklet.so expander.so schemify.so
rm -f chezpart.$(CSO) rumble.$(CSO) regexp.$(CSO) io.$(CSO) linklet.$(CSO) expander.$(CSO) schemify.$(CSO)
rm -f chezpart.wpo rumble.wpo regexp.wpo io.wpo linklet.wpo expander.wpo schemify.wpo
rm -f thread.so thread.wpo main.wpo main.so
rm -f thread.$(CSO) thread.wpo main.wpo main.$(CSO)
rm -rf compiled

View File

@ -10,11 +10,18 @@ SCHEME_BIN = $(SCHEME_SRC)/$(MACH)/bin/$(MACH)/scheme
SCHEME_INC = $(SCHEME_SRC)/$(MACH)/boot/$(MACH)
SCHEME = $(SCHEME_BIN) -b $(SCHEME_INC)/petite.boot -b $(SCHEME_INC)/scheme.boot
TARGET_MACH = @TARGET_MACH@
SCHEME_TARGET_INC = $(SCHEME_SRC)/$(TARGET_MACH)/boot/$(TARGET_MACH)
CC = @CC@
BASE_CFLAGS = @CFLAGS@ @CPPFLAGS@
CFLAGS = $(BASE_CFLAGS) -I$(SCHEME_INC) -I$(srcdir)/../../rktio -Irktio -I.
CFLAGS = $(BASE_CFLAGS) -I$(SCHEME_TARGET_INC) -I$(srcdir)/../../rktio -Irktio -I.
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
AR = @AR@
ARFLAGS = @ARFLAGS@
RANLIB = @RANLIB@
STRIP_DEBUG = @STRIP_DEBUG@
STRIP_LIB_DEBUG = @STRIP_LIB_DEBUG@
@ -44,7 +51,7 @@ mainsrcdir = @srcdir@/../..
@INCLUDEDEP@ @srcdir@/../../racket/version.mak
cs:
$(MAKE) scheme
$(MAKE) scheme@T_CROSS_MODE@
$(MAKE) racket-so
cd rktio; $(MAKE)
$(MAKE) racketcs
@ -76,6 +83,7 @@ RACKET_SO_ENV = @CONFIGURE_RACKET_SO_COMPILE@ env COMPILED_SCM_DIR="$(builddir)/
CS_PROGS = RACKET="$(RACKET)" SCHEME="$(SCHEME)" CONVERT_RACKET="$(CONVERT_RACKET)"
CS_OPTS = COMPRESS_COMP=@COMPRESS_COMP@
CS_OPTScross = $(CS_OPTS) CSO=@MACH@ CROSS_COMP="--xpatch $(SCHEME_SRC)/@TARGET_MACH@/s/xpatch"
build-racket-so:
$(MAKE) @RKTL_PRE@expander@RKTL_POST@
@ -84,7 +92,7 @@ build-racket-so:
$(MAKE) @RKTL_PRE@regexp@RKTL_POST@
$(MAKE) @RKTL_PRE@schemify@RKTL_POST@
$(MAKE) @RKTL_PRE@known@RKTL_POST@
cd $(srcdir)/.. && $(RACKET_SO_ENV) $(MAKE) "$(builddir)/racket.so" $(CS_PROGS) $(CS_OPTS) BUILDDIR="$(builddir)/"
cd $(srcdir)/.. && $(RACKET_SO_ENV) $(MAKE) "$(builddir)/racket.so" $(CS_PROGS) $(CS_OPTS@CROSS_MODE@) BUILDDIR="$(builddir)/"
bounce:
$(RACKET) -O 'info@compiler/cm' $(ABS_BOOT) $(srcdir)/../absify.rkt just-to-compile-absify
@ -121,9 +129,11 @@ scheme:
if [ "$(MAKE_BUILD_SCHEME)" = "y" ] ; \
then $(MAKE) scheme-make ; fi
SCHEME_CONFIG_VARS = CC="$(CC)" CFLAGS="$(BASE_CFLAGS)" LD="$(LD)" LDFLAGS="$(LDFLAGS)" AR="$(AR)" ARFLAGS="$(ARFLAGS)" RANLIB="$(RANLIB)"
scheme-make:
cd @SCHEME_SRC@ && git submodule -q init && git submodule -q update
cd @SCHEME_SRC@ && ./configure @SCHEME_CONFIG_ARGS@ CC="$(CC)" CFLAGS="$(BASE_CFLAGS)" LDFLAGS="$(LDFLAGS)"
cd @SCHEME_SRC@ && ./configure @SCHEME_CONFIG_ARGS@ $(SCHEME_CONFIG_VARS)
mkdir -p @SCHEME_SRC@/@MACH@/boot/@MACH@
$(MAKE) @SCHEME_SRC@/@MACH@/boot/@MACH@/equates.h
$(MAKE) @SCHEME_SRC@/@MACH@/boot/@MACH@/petite.boot
@ -131,7 +141,7 @@ scheme-make:
cd @SCHEME_SRC@ && $(MAKE)
# Replace "equates.h", etc., if they seem to be out of date.
# Otherwise, `make` on Chez Scheme cna fail.
# Otherwise, `make` on Chez Scheme can fail.
@SCHEME_SRC@/@MACH@/boot/@MACH@/equates.h: @SCHEME_SRC@/boot/@MACH@/equates.h
cp @SCHEME_SRC@/boot/@MACH@/equates.h @SCHEME_SRC@/@MACH@/boot/@MACH@/equates.h
@SCHEME_SRC@/@MACH@/boot/@MACH@/petite.boot: @SCHEME_SRC@/boot/@MACH@/petite.boot
@ -139,8 +149,22 @@ scheme-make:
@SCHEME_SRC@/@MACH@/boot/@MACH@/scheme.boot: @SCHEME_SRC@/boot/@MACH@/scheme.boot
cp @SCHEME_SRC@/boot/@MACH@/scheme.boot @SCHEME_SRC@/@MACH@/boot/@MACH@/scheme.boot
scheme-cross:
cd @SCHEME_SRC@ && git submodule -q init && git submodule -q update
cd @SCHEME_SRC@ && ./configure @SCHEME_CROSS_CONFIG_ARGS@ $(SCHEME_CONFIG_VARS)
cd @SCHEME_SRC@/@TARGET_MACH@/c && $(MAKE) o=o cross=t
$(MAKE) @SCHEME_SRC@/@TARGET_MACH@/boot/@TARGET_MACH@/scheme.boot
# Rebuild cross "petite.boot" and "scheme.boot" when older
# than the build-host "scheme.boot"
@SCHEME_SRC@/@TARGET_MACH@/boot/@TARGET_MACH@/scheme.boot: @SCHEME_SRC@/@MACH@/boot/@MACH@/scheme.boot
cd @SCHEME_SRC@/@TARGET_MACH@/s && $(MAKE) -f Mf-cross m=@MACH@ xm=@TARGET_MACH@ Scheme="$(SCHEME_BIN)" SCHEMEHEAPDIRS="$(SCHEME_INC)"
XPATCH =
XPATCHcross = --xpatch $(SCHEME_SRC)/@TARGET_MACH@/s/xpatch
racket.boot: racket.so
$(SCHEME) --script $(srcdir)/convert-to-boot.ss @COMPRESS_COMP@ racket.so racket.boot
$(SCHEME) --script $(srcdir)/convert-to-boot.ss @COMPRESS_COMP@ $(XPATCH@CROSS_MODE@) racket.so racket.boot $(TARGET_MACH)
@INCLUDEDEP@ compiled/expander.d
@INCLUDEDEP@ compiled/thread.d
@ -154,13 +178,13 @@ racket.boot: racket.so
EMBED_DEPS = $(srcdir)/embed-boot.rkt
racketcs@NOT_OSX@: raw_racketcs petite-v.boot scheme-v.boot racket-v.boot $(EMBED_DEPS)
racketcs@NOT_OSX@@NOT_MINGW@: raw_racketcs petite-v.boot scheme-v.boot racket-v.boot $(EMBED_DEPS)
$(BOOTSTRAP_RACKET) $(srcdir)/embed-boot.rkt @ELF_COMP@ @COMPRESS_COMP@ raw_racketcs racketcs petite-v.boot scheme-v.boot racket-v.boot
gracketcs@NOT_OSX@: raw_gracketcs petite-v.boot scheme-v.boot racket-v.boot $(EMBED_DEPS)
gracketcs@NOT_OSX@@NOT_MINGW@: raw_gracketcs petite-v.boot scheme-v.boot racket-v.boot $(EMBED_DEPS)
$(BOOTSTRAP_RACKET) $(srcdir)/embed-boot.rkt @ELF_COMP@ @COMPRESS_COMP@ raw_gracketcs gracketcs petite-v.boot scheme-v.boot racket-v.boot
BOOT_OBJS = boot.o $(SCHEME_INC)/kernel.o rktio/librktio.a
BOOT_OBJS = boot.o $(SCHEME_TARGET_INC)/kernel.o rktio/librktio.a
raw_racketcs: main.o boot.o $(BOOT_OBJS)
$(CC) $(CFLAGS) -o raw_racketcs main.o $(BOOT_OBJS) $(LDFLAGS) $(LIBS)
@ -168,14 +192,14 @@ raw_racketcs: main.o boot.o $(BOOT_OBJS)
raw_gracketcs: grmain.o boot.o $(BOOT_OBJS)
$(CC) $(CFLAGS) -o raw_gracketcs grmain.o $(BOOT_OBJS) $(LDFLAGS) $(LIBS)
petite-v.boot: $(SCHEME_INC)/petite.boot
$(SCHEME) --script $(srcdir)/to-vfasl.ss @COMPRESS_COMP@ $(SCHEME_INC)/petite.boot petite-v.boot
petite-v.boot: $(SCHEME_TARGET_INC)/petite.boot
$(SCHEME) --script $(srcdir)/to-vfasl.ss @COMPRESS_COMP@ @TT_CROSS_MODE@ $(SCHEME_TARGET_INC)/petite.boot petite-v.boot
scheme-v.boot: $(SCHEME_INC)/scheme.boot
$(SCHEME) --script $(srcdir)/to-vfasl.ss @COMPRESS_COMP@ $(SCHEME_INC)/scheme.boot scheme-v.boot petite
scheme-v.boot: $(SCHEME_TARGET_INC)/scheme.boot
$(SCHEME) --script $(srcdir)/to-vfasl.ss @COMPRESS_COMP@ @TT_CROSS_MODE@ $(SCHEME_TARGET_INC)/scheme.boot scheme-v.boot petite
racket-v.boot: racket.boot
$(SCHEME) --script $(srcdir)/to-vfasl.ss @COMPRESS_COMP@ racket.boot racket-v.boot petite scheme
$(SCHEME) --script $(srcdir)/to-vfasl.ss @COMPRESS_COMP@ @TT_CROSS_MODE@ racket.boot racket-v.boot petite scheme
# ----------------------------------------
# Mac OS
@ -200,20 +224,86 @@ $(GRACKET_BIN): grmain.o $(RKTFW) $(GRAPPSKEL)
$(GRAPPSKEL): $(srcdir)/../../mac/osx_appl.rkt $(srcdir)/../../racket/src/schvers.h $(srcdir)/../../mac/icon/GRacket.icns
$(BOOTSTRAP_RACKET) $(srcdir)/../../mac/osx_appl.rkt $(srcdir)/../.. "CS"
BOOT_FILES = $(SCHEME_INC)/petite.boot $(SCHEME_INC)/scheme.boot racket.boot
BOOT_FILES = $(SCHEME_TARGET_INC)/petite.boot $(SCHEME_TARGET_INC)/scheme.boot racket.boot
FW_BOOT_DEST = Racket.framework/Versions/$(FWVERSION)_CS/boot
$(RKTFW): $(BOOT_OBJS) $(BOOT_FILES)
mkdir -p Racket.framework/Versions/$(FWVERSION)_CS
@RKTLINKER@ -o $(RKTFW) @LDFLAGS@ -dynamiclib -all_load $(BOOT_OBJS) $(LDFLAGS) $(LIBS)
@RKTLINKER@ -o $(RKTFW) -dynamiclib -all_load $(BOOT_OBJS) $(LDFLAGS) $(LIBS)
rm -f Racket.framework/Racket
ln -s Versions/$(FWVERSION)_CS/Racket Racket.framework/Racket
mkdir -p Racket.framework/Versions/$(FWVERSION)_CS/boot
$(SCHEME) --script $(srcdir)/to-vfasl.ss @COMPRESS_COMP@ $(SCHEME_INC)/petite.boot $(FW_BOOT_DEST)/petite.boot
$(SCHEME) --script $(srcdir)/to-vfasl.ss @COMPRESS_COMP@ $(SCHEME_INC)/scheme.boot $(FW_BOOT_DEST)/scheme.boot petite
$(SCHEME) --script $(srcdir)/to-vfasl.ss @COMPRESS_COMP@ racket.boot $(FW_BOOT_DEST)/racket.boot petite scheme
$(SCHEME) --script $(srcdir)/to-vfasl.ss @COMPRESS_COMP@ @TT_CROSS_MODE@ $(SCHEME_TARGET_INC)/petite.boot $(FW_BOOT_DEST)/petite.boot
$(SCHEME) --script $(srcdir)/to-vfasl.ss @COMPRESS_COMP@ @TT_CROSS_MODE@ $(SCHEME_TARGET_INC)/scheme.boot $(FW_BOOT_DEST)/scheme.boot petite
$(SCHEME) --script $(srcdir)/to-vfasl.ss @COMPRESS_COMP@ @TT_CROSS_MODE@ racket.boot $(FW_BOOT_DEST)/racket.boot petite scheme
$(BOOTSTRAP_RACKET) $(srcdir)/adjust-compress.rkt @COMPRESS_COMP@ $(FW_BOOT_DEST)/petite.boot $(FW_BOOT_DEST)/scheme.boot $(FW_BOOT_DEST)/racket.boot
# ----------------------------------------
# MinGW
racketcs@MINGW@:
$(MAKE) RacketCS.exe
gracketcs@MINGW@:
$(MAKE) GRacketCS.exe
RKT_DLL = libracketcsxxxxxxx.dll
EXE_DESTS = ++exe raw_racketcs.exe RacketCS.exe ++exe raw_gracketcs.exe GRacketCS.exe
V_BOOTS = petite-v.boot scheme-v.boot racket-v.boot
RacketCS.exe GRacketCS.exe $(RKT_DLL): raw_libracketcs.dll raw_gracketcs.exe raw_racketcs.exe $(EMBED_DEPS) $(V_BOOTS)
$(BOOTSTRAP_RACKET) $(srcdir)/embed-boot.rkt --target @TARGET_MACH@ @COMPRESS_COMP@ $(EXE_DESTS) raw_libracketcs.dll $(RKT_DLL) $(V_BOOTS)
raw_racketcs.exe: main.o MemoryModule.o rres.o
$(CC) $(CFLAGS) -o raw_racketcs.exe main.o MemoryModule.o rres.o $(LDFLAGS)
raw_gracketcs.exe: grmain.o MemoryModule.o grres.o
$(CC) $(CFLAGS) -mwindows -o raw_gracketcs.exe grmain.o MemoryModule.o grres.o $(LDFLAGS)
MINGW_LIBS = -lshell32 -luser32 -lole32 -lRpcrt4 -luuid -lws2_32 -ladvapi32
raw_libracketcs.dll: boot.o $(BOOT_OBJS) libres.o
$(CC) $(CFLAGS) --shared -o raw_libracketcs.dll $(BOOT_OBJS) libres.o $(LDFLAGS) rktio/librktio.a $(MINGW_LIBS) -static-libgcc $(LIBS)
MemoryModule.o: $(srcdir)/../../start/MemoryModule.c
$(CC) -c $(CFLAGS) -o MemoryModule.o $(srcdir)/../../start/MemoryModule.c
rres.o: $(srcdir)/../../worksp/racket/racket.rc $(srcdir)/../../worksp/racket/racket.ico
@WINDRES@ -i $(srcdir)/../../worksp/racket/racket.rc -o rres.o
grres.o: $(srcdir)/../../worksp/gracket/gracket.rc $(srcdir)/../../worksp/gracket/gracket.ico
@WINDRES@ -i $(srcdir)/../../worksp/gracket/gracket.rc -o grres.o
libres.o: $(srcdir)/../../worksp/cs/libracket.rc
@WINDRES@ -i $(srcdir)/../../worksp/cs/libracket.rc -o libres.o
starter:
$(MAKE) MzStart.exe
$(MAKE) MrStart.exe
MzStart.exe: $(srcdir)/../../start/start.c start_rc.o
$(CC) $(CFLAGS) -o MzStart.exe -DMZSTART $(srcdir)/../../start/start.c start_rc.o
MrStart.exe: $(srcdir)/../../start/start.c gstart_rc.o
$(CC) -mwindows $(CFLAGS) -o MrStart.exe -DMRSTART $(srcdir)/../../start/start.c gstart_rc.o
start_rc.o: $(srcdir)/../../worksp/starters/start.rc
@WINDRES@ -DMZSTART -i $(srcdir)/../../worksp/starters/start.rc -o start_rc.o
gstart_rc.o: $(srcdir)/../../worksp/starters/start.rc
@WINDRES@ -DMRSTART -i $(srcdir)/../../worksp/starters/start.rc -o gstart_rc.o
install@MINGW@:
$(MAKE) plain-install CS_INSTALLED=`echo $(CS_INSTALLED) | awk '{print toupper($0)}'`
plain-install@MINGW@:
$(ICP) libracketcsxxxxxxx.dll $(libdir)/libracketcsxxxxxxx.dll
$(ICP) RacketCS.exe $(prefix)/Racket$(CS_INSTALLED).exe
$(ICP) GRacketCS.exe $(libpltdir)/GRacket$(CS_INSTALLED).exe
$(ICP) MzStart.exe $(libpltdir)/MzStart.exe
$(ICP) MrStart.exe $(libpltdir)/MrStart.exe
$(MAKE) system-install
# ----------------------------------------
# Common
@ -233,7 +323,7 @@ grmain.o: $(srcdir)/grmain.c $(MAIN_DEPS) $(srcdir)/../../start/gui_filter.inc
boot.o: $(srcdir)/boot.c $(srcdir)/../../rktio/rktio.inc $(srcdir)/boot.h
$(CC) $(CFLAGS) -c -o boot.o $(srcdir)/boot.c
starter: $(srcdir)/../../start/ustart.c
starter@NOT_MINGW@: $(srcdir)/../../start/ustart.c
$(CC) $(CFLAGS) -o starter $(srcdir)/../../start/ustart.c
# ----------------------------------------
@ -241,7 +331,7 @@ starter: $(srcdir)/../../start/ustart.c
ICP=@ICP@
install:
install@NOT_MINGW@:
$(MAKE) plain-install
$(MAKE) setup-install
@ -251,7 +341,7 @@ setup-install:
no-setup-install:
echo done
plain-install@NOT_OSX@:
plain-install@NOT_OSX@@NOT_MINGW@:
$(MAKE) unix-install
plain-install@OSX@:
@ -268,7 +358,10 @@ common-install:
$(STRIP_DEBUG) "$(DESTDIR)$(libpltdir)/starter"
$(ICP) $(srcdir)/../../start/starter-sh "$(DESTDIR)$(libpltdir)/starter-sh"
$(RACKET) -cu "$(srcdir)/../../racket/collects-path.rkt" "$(DESTDIR)$(libpltdir)/starter" $(DESTDIR)@COLLECTS_PATH@ $(DESTDIR)@CONFIG_PATH@
$(RACKET) -cu "$(srcdir)/gen-system.rkt" $(DESTDIR)$(libpltdir)/system$(CS_INSTALLED).rktd $(MACH) @CROSS_COMPILE_TARGET_KIND@
$(MAKE) system-install
system-install:
$(RACKET) -cu "$(srcdir)/gen-system.rkt" $(DESTDIR)$(libpltdir)/system$(CS_INSTALLED).rktd $(TARGET_MACH) @CROSS_COMPILE_TARGET_KIND@
unix-install:
$(MAKE) common-install

View File

@ -171,7 +171,7 @@ void racket_boot(int argc, char **argv, char *exec_file, char *run_file,
#endif
Sbuild_heap(NULL, init_foreign);
{
ptr l = Snil;
int i;

View File

@ -628,14 +628,21 @@ CS_INSTALLED
FRAMEWORK_REL_INSTALL
FRAMEWORK_PREFIX
FRAMEWORK_INSTALL_DIR
SCHEME_CROSS_CONFIG_ARGS
SCHEME_CONFIG_ARGS
MAKE_BUILD_SCHEME
SCHEME_SRC
ELF_COMP
COMPRESS_COMP
CONFIGURE_RACKET_SO_COMPILE
NOT_MINGW
MINGW
NOT_OSX
OSX
TT_CROSS_MODE
T_CROSS_MODE
CROSS_MODE
TARGET_MACH
MACH
SCHEME_DIR
RACKET
@ -646,14 +653,17 @@ RKTLINKER
STRIP_LIB_DEBUG
STRIP_DEBUG
ICP
WINDRES
STATIC_AR
RANLIB
ARFLAGS
AR
LD
EGREP
GREP
CPP
STRIP
platform_ar_found
RANLIB
OBJEXT
EXEEXT
ac_ct_CC
@ -755,6 +765,7 @@ enable_usersetup
enable_racket
enable_scheme
enable_mach
enable_target
enable_sdk
enable_xonx
enable_macprefix
@ -1390,7 +1401,8 @@ Optional Features:
--enable-usersetup setup user-specific files on install
--enable-racket=<path> use <path> as Racket to build; or "auto" to create
--enable-scheme=<path> Chez Scheme build directory at <path>
--enable-mach=<mac> Use Chez Scheme machine type <mach>
--enable-mach=<mach> Use Chez Scheme machine type <mach>
--enable-target=<mach> Cross-build for Chez Scheme machine type <mach>
--enable-sdk=<path> use Mac OS 10.4 SDK directory
--enable-sdk5=<path> use Mac OS 10.5 SDK directory
--enable-sdk6=<path> use Mac OS 10.6 SDK directory
@ -2341,6 +2353,11 @@ if test "${enable_mach+set}" = set; then :
enableval=$enable_mach;
fi
# Check whether --enable-target was given.
if test "${enable_target+set}" = set; then :
enableval=$enable_target;
fi
# Check whether --enable-sdk was given.
if test "${enable_sdk+set}" = set; then :
enableval=$enable_sdk;
@ -2486,6 +2503,7 @@ show_explicitly_enabled "${enable_xonx}" "Unix style"
show_explicitly_set "${enable_racket}" "Racket"
show_explicitly_set "${enable_scheme}" "Chez Scheme build directory"
show_explicitly_set "${enable_mach}" "machine type"
show_explicitly_set "${enable_target}" "cross-build machine type"
if test "${enable_csonly}" = "yes" ; then
enable_csdefault=yes
@ -2779,6 +2797,8 @@ use_flag_posix_pthread=no
INCLUDEDEP="#"
OSX="not_osx"
NOT_OSX=""
MINGW="not_mingw"
NOT_MINGW=""
CONFIGURE_RACKET_SO_COMPILE=""
COMPRESS_COMP=""
ELF_COMP=""
@ -3679,8 +3699,155 @@ _ACEOF
fi
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
set dummy ${ac_tool_prefix}ranlib; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_RANLIB+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$RANLIB"; then
ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
RANLIB=$ac_cv_prog_RANLIB
if test -n "$RANLIB"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
$as_echo "$RANLIB" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
fi
if test -z "$ac_cv_prog_RANLIB"; then
ac_ct_RANLIB=$RANLIB
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_RANLIB"; then
ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_RANLIB="ranlib"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
if test -n "$ac_ct_RANLIB"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
$as_echo "$ac_ct_RANLIB" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "x$ac_ct_RANLIB" = x; then
RANLIB=":"
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
RANLIB=$ac_ct_RANLIB
fi
else
RANLIB="$ac_cv_prog_RANLIB"
fi
if test "$AR" = '' ; then
AR="${ac_tool_prefix}ar"
# Extract the first word of "$AR", so it can be a program name with args.
set dummy $AR; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_platform_ar_found+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$platform_ar_found"; then
ac_cv_prog_platform_ar_found="$platform_ar_found" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_platform_ar_found="yes"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
test -z "$ac_cv_prog_platform_ar_found" && ac_cv_prog_platform_ar_found="no"
fi
fi
platform_ar_found=$ac_cv_prog_platform_ar_found
if test -n "$platform_ar_found"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $platform_ar_found" >&5
$as_echo "$platform_ar_found" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "$platform_ar_found" = 'no' ; then
AR="ar"
fi
fi
if test "$ARFLAGS" = '' ; then
ARFLAGS=ruv
fi
LD="${ac_tool_prefix}ld"
WINDRES=windres
############## platform tests ################
# At first, `MACH` means the target that we're building for. In
# cross-build mode, `MACH` will be moved to `TARGET_MACH`.
MACH_HOST_CPU="${host_cpu}"
extra_scheme_config_args=
disable_curses_arg=--disable-curses
@ -3718,6 +3885,13 @@ case "$host_os" in
;;
*mingw*)
skip_iconv_check=yes
use_flag_pthread=no
MACH_OS=nt
MINGW=""
NOT_MINGW="mingw"
if `which ${host}-windres > /dev/null` ; then
WINDRES="${host}-windres"
fi
;;
cygwin*)
;;
@ -3841,10 +4015,8 @@ if test "${enable_pthread}" = "" ; then
fi
thread_prefix=""
thread_config_arg=""
if test "${enable_pthread}" = "yes" ; then
thread_prefix="t"
thread_config_arg="--threads"
fi
case "$MACH_HOST_CPU" in
@ -3862,6 +4034,88 @@ case "$MACH_HOST_CPU" in
;;
esac
if test "${enable_mach}" != "" ; then
MACH="${enable_mach}"
fi
if test "${enable_target}" != "" ; then
TARGET_MACH=${enable_target}
CROSS_MODE="cross"
elif test "${build_os}_${build_cpu}" != "${host_os}_${host_cpu}" ; then
BUILD_THREAD_PREFIX="${thread_prefix}"
case "$build_os" in
solaris2*)
BUILD_OS=s2
;;
*freebsd*)
BUILD_OS=fb
;;
openbsd*)
BUILD_OS=ob
;;
netbsd*)
BUILD_OS=nb
;;
linux*)
BUILD_OS=le
;;
*mingw*)
BUILD_OS=nt
;;
darwin*)
BUILD_OS=osx
;;
nto-qnx*)
BUILD_OS=qnx
;;
*)
echo "unknown build OS"
exit 1
;;
esac
case "$build_cpu" in
x86_64)
BUILD_MACH="${BUILD_THREAD_PREFIX}a6${BUILD_OS}"
;;
x86|i*86)
BUILD_MACH="${BUILD_THREAD_PREFIX}i3${BUILD_OS}"
;;
arm*)
BUILD_MACH="${BUILD_THREAD_PREFIX}arm32${BUILD_OS}"
;;
power*)
BUILD_MACH="${BUILD_THREAD_PREFIX}ppc32${BUILD_OS}"
;;
esac
TARGET_MACH=${MACH}
MACH=${BUILD_MACH}
CROSS_MODE="cross"
else
BUILD_MACH=${MACH}
TARGET_MACH=${MACH}
CROSS_MODE=""
fi
if test "${CROSS_MODE}" = "cross" ; then
if test "${enable_scheme}" = "" ; then
echo "Need --enable-scheme=... for cross-build mode"
exit 1
fi
if test "${enable_racket}" = "" ; then
echo "Need --enable-racket=... for cross-build mode"
exit 1
fi
T_CROSS_MODE="-cross"
TT_CROSS_MODE="--cross"
else
T_CROSS_MODE=""
TT_CROSS_MODE=""
fi
# From this point on, `MACH` means the build machine, and
# `TARGET_MACH` is the target that we're building for (which
# is different in cross-build mode).
SCHEME_SRC=../../ChezScheme
MAKE_BUILD_SCHEME=y
@ -3874,11 +4128,8 @@ if test "${enable_racket}" != "" ; then
RACKET="${enable_racket}"
fi
if test "${enable_mach}" != "" ; then
MACH="${enable_mach}"
fi
SCHEME_CONFIG_ARGS="--machine=${MACH} ${thread_config_arg} --disable-x11 ${disable_curses_arg} ${extra_scheme_config_args}"
SCHEME_CONFIG_ARGS="--machine=${MACH} --disable-x11 ${disable_curses_arg} ${extra_scheme_config_args}"
SCHEME_CROSS_CONFIG_ARGS="--machine=${TARGET_MACH} --disable-x11 ${disable_curses_arg} ${extra_scheme_config_args}"
if test "${enable_compress}" = "yes" ; then
COMPRESS_COMP="--compress"
@ -4636,6 +4887,35 @@ fi
############## final output ################
# Pass certain configure args on to rktio
keep_configure_args=
fixup_prev=
eval "set x $ac_configure_args"
shift
for fixup_arg
do
case $fixup_arg in
# Strip away all feature choices
-enable* | --enable* | -disable* | --disable*)
;;
*)
case $fixup_arg in
*\'*) fixup_arg=`echo "$fixup_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
esac
keep_configure_args="$keep_configure_args '$fixup_arg'" ;;
esac
done
SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} CC="'"'"${CC}"'"'
SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} CFLAGS="'"'"${CFLAGS}"'"'
SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} LD="'"'"${LD}"'"'
SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} LDFLAGS="'"'"${LDFLAGS}"'"'
SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} AR="'"'"${AR}"'"'
SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} ARFLAGS="'"'"${ARFLAGS}"'"'
SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} RANLIB="'"'"${RANLIB}"'"'
############## final output ################
CPPFLAGS="$CPPFLAGS $PREFLAGS"
@ -4662,6 +4942,15 @@ CPPFLAGS="$CPPFLAGS $PREFLAGS"
@ -5952,4 +6241,4 @@ fi
mkdir -p rktio
abssrcdir=`(cd ${srcdir}; pwd)`
echo "=== configuring in rktio (${abssrcdir}/../../rktio)"
cd rktio; eval "${abssrcdir}/../../rktio/configure ${SUB_CONFIGURE_EXTRAS}"
cd rktio; eval "${abssrcdir}/../../rktio/configure ${keep_configure_args} ${SUB_CONFIGURE_EXTRAS}"

View File

@ -20,7 +20,8 @@ AC_ARG_ENABLE(compress, [ --enable-compress compress compiled code])
m4_include(../ac/path_arg.m4)
AC_ARG_ENABLE(racket, [ --enable-racket=<path> use <path> as Racket to build; or "auto" to create])
AC_ARG_ENABLE(scheme, [ --enable-scheme=<path> Chez Scheme build directory at <path>])
AC_ARG_ENABLE(mach, [ --enable-mach=<mac> Use Chez Scheme machine type <mach>])
AC_ARG_ENABLE(mach, [ --enable-mach=<mach> Use Chez Scheme machine type <mach>])
AC_ARG_ENABLE(target, [ --enable-target=<mach> Cross-build for Chez Scheme machine type <mach>])
m4_include(../ac/sdk_arg.m4)
m4_include(../ac/strip_arg.m4)
AC_ARG_ENABLE(csdefault, [ --enable-csdefault use CS as default build])
@ -61,6 +62,7 @@ show_explicitly_enabled "${enable_xonx}" "Unix style"
show_explicitly_set "${enable_racket}" "Racket"
show_explicitly_set "${enable_scheme}" "Chez Scheme build directory"
show_explicitly_set "${enable_mach}" "machine type"
show_explicitly_set "${enable_target}" "cross-build machine type"
if test "${enable_csonly}" = "yes" ; then
enable_csdefault=yes
@ -111,6 +113,8 @@ use_flag_posix_pthread=no
INCLUDEDEP="#"
OSX="not_osx"
NOT_OSX=""
MINGW="not_mingw"
NOT_MINGW=""
CONFIGURE_RACKET_SO_COMPILE=""
COMPRESS_COMP=""
ELF_COMP=""
@ -134,8 +138,27 @@ fi
AC_CHECK_LIB(m, fmod)
AC_CHECK_LIB(dl, dlopen)
AC_PROG_RANLIB
if test "$AR" = '' ; then
AR="${ac_tool_prefix}ar"
AC_CHECK_PROG(platform_ar_found, $AR, yes, no)
if test "$platform_ar_found" = 'no' ; then
AR="ar"
fi
fi
if test "$ARFLAGS" = '' ; then
ARFLAGS=ruv
fi
LD="${ac_tool_prefix}ld"
WINDRES=windres
############## platform tests ################
# At first, `MACH` means the target that we're building for. In
# cross-build mode, `MACH` will be moved to `TARGET_MACH`.
MACH_HOST_CPU="${host_cpu}"
extra_scheme_config_args=
disable_curses_arg=--disable-curses
@ -173,7 +196,14 @@ case "$host_os" in
;;
*mingw*)
skip_iconv_check=yes
;;
use_flag_pthread=no
MACH_OS=nt
MINGW=""
NOT_MINGW="mingw"
if `which ${host}-windres > /dev/null` ; then
WINDRES="${host}-windres"
fi
;;
cygwin*)
;;
darwin*)
@ -242,10 +272,8 @@ if test "${enable_pthread}" = "" ; then
fi
thread_prefix=""
thread_config_arg=""
if test "${enable_pthread}" = "yes" ; then
thread_prefix="t"
thread_config_arg="--threads"
fi
case "$MACH_HOST_CPU" in
@ -263,6 +291,88 @@ case "$MACH_HOST_CPU" in
;;
esac
if test "${enable_mach}" != "" ; then
MACH="${enable_mach}"
fi
if test "${enable_target}" != "" ; then
TARGET_MACH=${enable_target}
CROSS_MODE="cross"
elif test "${build_os}_${build_cpu}" != "${host_os}_${host_cpu}" ; then
BUILD_THREAD_PREFIX="${thread_prefix}"
case "$build_os" in
solaris2*)
BUILD_OS=s2
;;
*freebsd*)
BUILD_OS=fb
;;
openbsd*)
BUILD_OS=ob
;;
netbsd*)
BUILD_OS=nb
;;
linux*)
BUILD_OS=le
;;
*mingw*)
BUILD_OS=nt
;;
darwin*)
BUILD_OS=osx
;;
nto-qnx*)
BUILD_OS=qnx
;;
*)
echo "unknown build OS"
exit 1
;;
esac
case "$build_cpu" in
x86_64)
BUILD_MACH="${BUILD_THREAD_PREFIX}a6${BUILD_OS}"
;;
x86|i*86)
BUILD_MACH="${BUILD_THREAD_PREFIX}i3${BUILD_OS}"
;;
arm*)
BUILD_MACH="${BUILD_THREAD_PREFIX}arm32${BUILD_OS}"
;;
power*)
BUILD_MACH="${BUILD_THREAD_PREFIX}ppc32${BUILD_OS}"
;;
esac
TARGET_MACH=${MACH}
MACH=${BUILD_MACH}
CROSS_MODE="cross"
else
BUILD_MACH=${MACH}
TARGET_MACH=${MACH}
CROSS_MODE=""
fi
if test "${CROSS_MODE}" = "cross" ; then
if test "${enable_scheme}" = "" ; then
echo "Need --enable-scheme=... for cross-build mode"
exit 1
fi
if test "${enable_racket}" = "" ; then
echo "Need --enable-racket=... for cross-build mode"
exit 1
fi
T_CROSS_MODE="-cross"
TT_CROSS_MODE="--cross"
else
T_CROSS_MODE=""
TT_CROSS_MODE=""
fi
# From this point on, `MACH` means the build machine, and
# `TARGET_MACH` is the target that we're building for (which
# is different in cross-build mode).
SCHEME_SRC=../../ChezScheme
MAKE_BUILD_SCHEME=y
@ -275,11 +385,8 @@ if test "${enable_racket}" != "" ; then
RACKET="${enable_racket}"
fi
if test "${enable_mach}" != "" ; then
MACH="${enable_mach}"
fi
SCHEME_CONFIG_ARGS="--machine=${MACH} ${thread_config_arg} --disable-x11 ${disable_curses_arg} ${extra_scheme_config_args}"
SCHEME_CONFIG_ARGS="--machine=${MACH} --disable-x11 ${disable_curses_arg} ${extra_scheme_config_args}"
SCHEME_CROSS_CONFIG_ARGS="--machine=${TARGET_MACH} --disable-x11 ${disable_curses_arg} ${extra_scheme_config_args}"
if test "${enable_compress}" = "yes" ; then
COMPRESS_COMP="--compress"
@ -435,17 +542,48 @@ fi
############## final output ################
# Pass certain configure args on to rktio
keep_configure_args=
fixup_prev=
eval "set x $ac_configure_args"
shift
for fixup_arg
do
case $fixup_arg in
# Strip away all feature choices
-enable* | --enable* | -disable* | --disable*)
;;
*)
case $fixup_arg in
*\'*) fixup_arg=`echo "$fixup_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
esac
keep_configure_args="$keep_configure_args '$fixup_arg'" ;;
esac
done
SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} CC="'"'"${CC}"'"'
SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} CFLAGS="'"'"${CFLAGS}"'"'
SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} LD="'"'"${LD}"'"'
SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} LDFLAGS="'"'"${LDFLAGS}"'"'
SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} AR="'"'"${AR}"'"'
SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} ARFLAGS="'"'"${ARFLAGS}"'"'
SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} RANLIB="'"'"${RANLIB}"'"'
############## final output ################
CPPFLAGS="$CPPFLAGS $PREFLAGS"
AC_SUBST(CC)
AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(LD)
AC_SUBST(LDFLAGS)
AC_SUBST(LIBS)
AC_SUBST(AR)
AC_SUBST(ARFLAGS)
AC_SUBST(RANLIB)
AC_SUBST(STATIC_AR)
AC_SUBST(WINDRES)
AC_SUBST(ICP)
AC_SUBST(STRIP_DEBUG)
AC_SUBST(STRIP_LIB_DEBUG)
@ -456,14 +594,21 @@ AC_SUBST(RKTL_POST)
AC_SUBST(RACKET)
AC_SUBST(SCHEME_DIR)
AC_SUBST(MACH)
AC_SUBST(TARGET_MACH)
AC_SUBST(CROSS_MODE)
AC_SUBST(T_CROSS_MODE)
AC_SUBST(TT_CROSS_MODE)
AC_SUBST(OSX)
AC_SUBST(NOT_OSX)
AC_SUBST(MINGW)
AC_SUBST(NOT_MINGW)
AC_SUBST(CONFIGURE_RACKET_SO_COMPILE)
AC_SUBST(COMPRESS_COMP)
AC_SUBST(ELF_COMP)
AC_SUBST(SCHEME_SRC)
AC_SUBST(MAKE_BUILD_SCHEME)
AC_SUBST(SCHEME_CONFIG_ARGS)
AC_SUBST(SCHEME_CROSS_CONFIG_ARGS)
AC_SUBST(FRAMEWORK_INSTALL_DIR)
AC_SUBST(FRAMEWORK_PREFIX)
AC_SUBST(FRAMEWORK_REL_INSTALL)
@ -478,4 +623,4 @@ AC_OUTPUT($makefiles)
mkdir -p rktio
abssrcdir=`(cd ${srcdir}; pwd)`
echo "=== configuring in rktio (${abssrcdir}/../../rktio)"
cd rktio; eval "${abssrcdir}/../../rktio/configure ${SUB_CONFIGURE_EXTRAS}"
cd rktio; eval "${abssrcdir}/../../rktio/configure ${keep_configure_args} ${SUB_CONFIGURE_EXTRAS}"

View File

@ -1,17 +1,26 @@
(compile-compressed #f)
(define-values (src dest)
(define-values (src dest machine)
(let loop ([args (command-line-arguments)])
(cond
[(and (pair? args)
(equal? (car args) "--compress"))
(compile-compressed #t)
(loop (cdr args))]
[(and (pair? args)
(equal? (car args) "--xpatch")
(pair? (cdr args)))
(load (cadr args))
(loop (cddr args))]
[(null? args)
(error 'convert-to-boot "missing file arguments")]
[(and (pair? (cdr args)) (null? (cddr args)))
(values (car args) (cadr args))]
[(null? (cdr args))
(error 'convert-to-boot "missing destination-file argument")]
[(null? (cddr args))
(error 'convert-to-boot "missing machine argument")]
[(pair? (cdddr args))
(error 'convert-to-boot "extra arguments after files")]
[else
(error 'convert-to-boot "extra arguments after files")])))
(values (car args) (cadr args) (caddr args))])))
(make-boot-file dest '("petite" "scheme") src)
(#%$make-boot-file dest (string->symbol machine) '("petite" "scheme") src)

View File

@ -8,6 +8,7 @@
(define expect-elf? #f)
(define alt-dests '())
(define target #f)
(command-line
#:once-each
@ -15,6 +16,8 @@
(enable-compress!)]
[("--expect-elf") "Record offset from ELF section"
(set! expect-elf? #t)]
[("--target") machine "Select target machine"
(set! target machine)]
#:multi
[("++exe") src dest "Select an alternative executable"
(set! alt-dests (cons (cons src dest) alt-dests))]
@ -39,12 +42,12 @@
bstr2 terminator
bstr3 terminator))
(define pos
(case (path->string (system-library-subpath #f))
(case (or target (path->string (system-library-subpath #f)))
[("x86_64-darwin" "i386-darwin" "x86_64-macosx" "i386-macosx")
;; Mach-O
(copy-file src-file dest-file #t)
(add-plt-segment dest-file data #:name #"__RKTBOOT")]
[("win32\\x86_64" "win32\\i386")
[("ta6nt" "ti3nt" "win32\\x86_64" "win32\\i386")
(copy-file src-file dest-file #t)
(define-values (pe rsrcs) (call-with-input-file*
dest-file

View File

@ -1,20 +1,49 @@
(module gen-system '#%kernel
;; Command-line argument: <dest-file> <target-machine> <cross-target-machine>
(define-values (machine) (string->symbol (vector-ref (current-command-line-arguments) 1)))
;; Check for cross-compile to Windows:
(define-values (windows?) (if (eq? machine 'ta6nt)
#t
(if (eq? machine 'ti3nt)
#t
(if (eq? machine 'a6nt)
#t
(if (eq? machine 'i3nt)
#t
#f)))))
(define-values (ht)
(hash 'os (system-type 'os)
'word (system-type 'word)
(hash 'os (if windows? 'windows (system-type 'os))
'word (if (eq? machine 'ta6nt)
64
(if (eq? machine 'a6nt)
64
(if (eq? machine 'ti3nt)
32
(if (eq? machine 'i3nt)
32
(system-type 'word)))))
'gc 'cs
'vm 'chez-scheme
'link 'static
'machine (bytes->string/utf-8 (path->bytes (system-library-subpath #f)))
'so-suffix (system-type 'so-suffix)
'machine (if (eq? machine 'ta6nt)
"win32\\x86_64"
(if (eq? machine 'a6nt)
"win32\\x86_64"
(if (eq? machine 'ti3nt)
"win32\\i386"
(if (eq? machine 'i3nt)
"win32\\i386"
(bytes->string/utf-8 (path->bytes (system-library-subpath #f)))))))
'so-suffix (if windows? #".dll" (system-type 'so-suffix))
'so-mode 'local
'fs-change '#(#f #f #f #f)
'target-machine (if (equal? "any" (vector-ref (current-command-line-arguments) 2))
#f
(string->symbol (vector-ref (current-command-line-arguments) 1)))))
machine)))
(call-with-output-file
(vector-ref (current-command-line-arguments) 0)

View File

@ -376,7 +376,7 @@ static int bytes_main(int argc, char **argv,
return 0;
}
#if defined(WIN32) && defined(CHECK_SINGLE_INSTANCE)
#if defined(WIN32) && (defined(CHECK_SINGLE_INSTANCE) || defined(__MINGW32__))
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR ignored, int nCmdShow)
{
int argc;
@ -387,11 +387,13 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR ignored
argv = cmdline_to_argv(&argc, &normalized_path);
#ifdef CHECK_SINGLE_INSTANCE
if (CheckSingleInstance(normalized_path, argv))
return 0;
wm = wm_is_gracket;
guid = GRACKET_GUID;
#endif
return bytes_main(argc, argv, wm, guid);
}
#elif defined(WIN32)

View File

@ -1,4 +1,5 @@
(compile-compressed #f)
(define compile-cross? #f)
(define-values (src dest deps)
(let loop ([args (command-line-arguments)])
@ -7,6 +8,10 @@
(equal? (car args) "--compress"))
(compile-compressed #t)
(loop (cdr args))]
[(and (pair? args)
(equal? (car args) "--cross"))
(set! compile-cross? #t)
(loop (cdr args))]
[(null? args)
(error 'to-vfasl "missing src argument")]
[(null? (cdr args))
@ -14,4 +19,17 @@
[else
(values (car args) (cadr args) (cddr args))])))
(vfasl-convert-file src dest deps)
(cond
[compile-cross?
(printf "Cross-compile cannot convert to vfasl; leaving as-is\n")
(let ([i (open-file-input-port src)]
[o (open-file-output-port dest (file-options no-fail))])
(let loop ()
(define c (get-u8 i))
(unless (eof-object? c)
(put-u8 o c)
(loop)))
(close-port i)
(close-port o))]
[else
(vfasl-convert-file src dest deps)])

View File

@ -74,6 +74,7 @@
(compile-compressed #f)
(enable-arithmetic-left-associative #t)
(define build-dir "")
(define xpatch-path #f)
(define-values (src deps)
(let loop ([args (command-line-arguments)])
@ -103,6 +104,10 @@
=> (lambda (args)
(set! build-dir (car args))
(loop (cdr args)))]
[(get-opt args "--xpatch" 1)
=> (lambda (args)
(set! xpatch-path (car args))
(loop (cdr args)))]
[(null? args)
(error 'compile-file "missing source file")]
[else
@ -122,6 +127,9 @@
src-so
(string-append build-dir src-so)))
(when xpatch-path
(load xpatch-path))
(cond
[whole-program?
(unless (= 1 (length deps))
@ -139,4 +147,24 @@
[g (gensym (symbol->string sym) (format "rkt-~a-~a-~a" src s n))])
(eq-hashtable-set! counter-ht sym (+ n 1))
g)))])
(compile-file src dest))])
(cond
[xpatch-path
;; Cross compile: use `compile-to-file` to get a second, host-format output file
(let ([sfd (let ([i (open-file-input-port src)])
(make-source-file-descriptor src i #t))])
(let ([exprs (call-with-input-file
src
(lambda (i)
(let loop ([pos 0])
(let-values ([(e pos) (get-datum/annotations i sfd pos)])
(if (eof-object? e)
'()
;; Strip enough of the annotation to expose 'library
;; or 'top-level-program:
(let ([e (map annotation-expression
(annotation-expression e))])
(cons e (loop pos))))))))])
(compile-to-file exprs dest)))]
[else
;; Normal mode
(compile-file src dest)]))])

View File

@ -359,7 +359,7 @@
'rktio_get_ctl_c_handler rktio_get_ctl_c_handler]
form ...)]))
(include "../rktio/rktio.rktl"))))
;; ----------------------------------------
(define format

View File

@ -182,7 +182,7 @@
;; that need to be managed correctly when swapping Racket
;; engines/threads.
(define (compile* e)
(call-with-system-wind (lambda () (compile e))))
(call-with-system-wind (lambda () (eval e)))) ; eval => compile, except in cross mode
(define (interpret* e)
(call-with-system-wind (lambda () (interpret e))))
(define (fasl-write* s o)

View File

@ -273,6 +273,7 @@
hash? hash-eq? hash-equal? hash-eqv? hash-weak? immutable-hash?
hash-count
hash-keys-subset?
eq-hashtable->hash ; not exported to racket
datum-intern-literal
set-intern-regexp?! ; not exported to racket

View File

@ -128,23 +128,9 @@
;; ----------------------------------------
(define vector-content-offset
(let-syntax ([vector-content-offset
(lambda (stx)
;; Hack: use `s_fxmul` as an identity function
;; to corece a bytevector's start to an address
(define hack-bytevector->addr ; call with GC disabled
(foreign-procedure "(cs)fxmul"
(u8* uptr)
uptr))
(let* ([s (make-bytevector 1 0)]
[offset
;; Disable interrupts to avoid a GC:
(with-interrupts-disabled
(- (hack-bytevector->addr s 1)
(#%$object-address s 0)))])
(datum->syntax #'here offset)))])
(vector-content-offset)))
;; Hack: hardwired number that depends on the tagging regime,
;; but happens currently to be the same for all platforms:
(define bytevector-content-offset 9)
(define (object->addr v) ; call with GC disabled
(#%$object-address v 0))
@ -153,13 +139,13 @@
(#%$address->object n 0))
(define (bytevector->addr bv) ; call with GC disabled
(#%$object-address bv vector-content-offset))
(#%$object-address bv bytevector-content-offset))
;; Convert a raw foreign address to a Scheme value on the
;; assumption that the address is the payload of a byte
;; string or vector:
;; string:
(define (addr->gcpointer-memory v) ; call with GC disabled
(#%$address->object v (- vector-content-offset)))
(#%$address->object v (- bytevector-content-offset)))
;; Converts a primitive cpointer (normally the result of
;; `unwrap-cpointer`) to a raw foreign address. The
@ -199,9 +185,8 @@
(cond
[(integer? memory) memory]
[(bytes? memory) (bytevector->addr memory)]
[else
(+ (object->addr memory)
vector-content-offset)]))
[else (object->addr memory)]))
;; ----------------------------------------
(define (cpointer-strip p)
@ -1065,67 +1050,63 @@
"source" from)])]
[else
(with-interrupts-disabled
(let ([to (fx+ (cpointer*-address to) to-offset)]
[from (fx+ (cpointer*-address from) from-offset)])
(let ([to (+ (cpointer*-address to) to-offset)]
[from (+ (cpointer*-address from) from-offset)])
(cond
[(and move?
;; overlap?
(or (<= to from (fx+ to len -1))
(<= from to (fx+ from len -1)))
(or (<= to from (+ to len -1))
(<= from to (+ from len -1)))
;; shifting up?
(< from to))
;; Copy from high to low to move in overlapping region
(let loop ([to (+ to len)] [from (+ from len)] [len len])
(let loop ([len len])
(unless (fx= len 0)
(cond
#;
[(fx>= len 8)
(let ([to (fx- to 8)]
[from (fx- from 8)])
(foreign-set! 'integer-64 to 0
(foreign-ref 'integer-64 from 0))
(loop to from (fx- len 8)))]
[(and (meta-cond [(> (fixnum-width) 32) #t] [else #f])
[(and (> (fixnum-width) 64)
(fx>= len 8))
(let ([len (fx- len 8)])
(foreign-set! 'integer-64 to len
(foreign-ref 'integer-64 from len))
(loop len))]
[(and (> (fixnum-width) 32)
(fx>= len 4))
(let ([to (fx- to 4)]
[from (fx- from 4)])
(foreign-set! 'integer-32 to 0
(foreign-ref 'integer-32 from 0))
(loop to from (fx- len 4)))]
(let ([len (fx- len 4)])
(foreign-set! 'integer-32 to len
(foreign-ref 'integer-32 from len))
(loop len))]
[(fx>= len 2)
(let ([to (fx- to 2)]
[from (fx- from 2)])
(foreign-set! 'integer-16 to 0
(foreign-ref 'integer-16 from 0))
(loop to from (fx- len 2)))]
(let ([len (fx- len 2)])
(foreign-set! 'integer-16 to len
(foreign-ref 'integer-16 from len))
(loop len))]
[else
(let ([to (fx- to 1)]
[from (fx- from 1)])
(foreign-set! 'integer-8 to 0
(foreign-ref 'integer-8 from 0))
(loop to from (fx- len 1)))])))]
(let ([len (fx- len 1)])
(foreign-set! 'integer-8 to len
(foreign-ref 'integer-8 from len))
(loop len))])))]
[else
(let loop ([to to] [from from] [len len])
(unless (fx= len 0)
(let loop ([pos 0])
(when (fx< pos len)
(cond
#;
[(fx>= len 8)
(foreign-set! 'integer-64 to 0
(foreign-ref 'integer-64 from 0))
(loop (fx+ to 8) (fx+ from 8) (fx- len 8))]
[(and (meta-cond [(> (fixnum-width) 32) #t] [else #f])
(fx>= len 4))
(foreign-set! 'integer-32 to 0
(foreign-ref 'integer-32 from 0))
(loop (fx+ to 4) (fx+ from 4) (fx- len 4))]
[(fx>= len 2)
(foreign-set! 'integer-16 to 0
(foreign-ref 'integer-16 from 0))
(loop (fx+ to 2) (fx+ from 2) (fx- len 2))]
[(and (> (fixnum-width) 64)
(fx<= (fx+ pos 8) len))
(foreign-set! 'integer-64 to pos
(foreign-ref 'integer-64 from pos))
(loop (fx+ pos 8))]
[(and (> (fixnum-width) 32)
(fx<= (fx+ pos 4) len))
(foreign-set! 'integer-32 to pos
(foreign-ref 'integer-32 from pos))
(loop (fx+ pos 4))]
[(fx<= (fx+ pos 2) len)
(foreign-set! 'integer-16 to pos
(foreign-ref 'integer-16 from pos))
(loop (fx+ pos 2))]
[else
(foreign-set! 'integer-8 to 0
(foreign-ref 'integer-8 from 0))
(loop (fx+ to 1) (fx+ from 1) (fx- len 1))])))])))])))
(foreign-set! 'integer-8 to pos
(foreign-ref 'integer-8 from pos))
(loop (fx+ pos 1))])))])))])))
(define memcpy/memmove
(case-lambda

View File

@ -28,6 +28,9 @@
[() (create-mutable-hash (make-eq-hashtable) 'eq?)]
[(alist) (fill-hash! 'make-hasheq (make-hasheq) alist)]))
(define (eq-hashtable->hash ht)
(create-mutable-hash ht 'eq?))
(define make-weak-hasheq
(case-lambda
[() (create-mutable-hash (make-weak-eq-hashtable) 'eq?)]

View File

@ -219,10 +219,9 @@
[x4 (fxior x3 (fxsrl x3 4))]
[x5 (fxior x4 (fxsrl x4 8))]
[x6 (fxior x5 (fxsrl x5 16))]
[x7 (meta-cond
[(> (fixnum-width) 32)
(fxior x6 (fxsrl x6 32))]
[else x6])])
[x7 (if (> (fixnum-width) 32)
(fxior x6 (fxsrl x6 32))
x6)])
(fxxor x7 (fxsrl x7 1))))
;; basic utils

View File

@ -61,14 +61,13 @@
(define prim-knowns
(let-syntax ([gen
(lambda (stx)
(include-generated "known.scm")
;; Constructed a quoted literal hash table that
;; maps symbols to `known` prefabs
;; Construct a hash table that maps symbols to
;; `known` prefabs
(let ([known-l '()])
(define-syntax define-primitive-table
(syntax-rules ()
[(_ id [prim known] ...)
(begin (set! known-l (cons (cons 'prim known) known-l))
(begin (set! known-l (cons (cons 'prim 'known) known-l))
...)]))
(include "primitive/kernel.ss")
(include "primitive/unsafe.ss")
@ -80,9 +79,20 @@
(include "primitive/place.ss")
(include "primitive/foreign.ss")
(include "primitive/linklet.ss")
(let loop ([l known-l] [knowns (hasheq)])
(if (null? l)
#`(quote #,knowns)
(loop (cdr l)
(hash-set knowns (caar l) (cdar l)))))))])
(let ([knowns (make-hashtable equal-hash equal?)])
(for-each (lambda (k)
(hashtable-set! knowns (cdr k) (gensym)))
known-l)
(with-syntax ([(id) stx])
(#%datum->syntax
#'id
`(let ([ht (make-eq-hashtable)]
,@(#%map (lambda (k)
`[,(hashtable-ref knowns k #f) ,k])
(#%vector->list (hashtable-keys knowns))))
,@(#%map (lambda (k)
`(hashtable-set! ht ',(car k)
,(hashtable-ref knowns (cdr k) #f)))
known-l)
(eq-hashtable->hash ht)))))))])
(gen))))