cs: support Android on 32-bit and 64-bit ARM

Various configure and makefile improvements apply more broadly to
environments that, say, lack iconv or target 32-bit ARM without Thumb.
This commit is contained in:
Matthew Flatt 2021-02-07 07:53:02 -07:00
parent 342bd6645c
commit 8a08704012
20 changed files with 167 additions and 63 deletions

View File

@ -12,6 +12,8 @@ Supported platforms:
* OpenBSD: x86, x86_64 * OpenBSD: x86, x86_64
* NetBSD: x86, x86_64 * NetBSD: x86, x86_64
* Solaris: x86, x86_64 * Solaris: x86, x86_64
* Android: ARMv7, AArch64
* iOS: AArch64
As a superset of the language described in the As a superset of the language described in the
[Revised<sup>6</sup> Report on the Algorithmic Language Scheme](http://www.r6rs.org) [Revised<sup>6</sup> Report on the Algorithmic Language Scheme](http://www.r6rs.org)

View File

@ -22,7 +22,7 @@ Main=../boot/$m/main.$o
Scheme=../bin/$m/scheme Scheme=../bin/$m/scheme
# CFLAGS is propagated separately: # CFLAGS is propagated separately:
SetConfigEnv = CC="${CC}" CPPFLAGS="${CPPFLAGS}" AR="${AR}" ARFLAGS="${ARFLAGS}" SetConfigEnv = CC="${CC}" CPPFLAGS="${CPPFLAGS}" AR="${AR}" ARFLAGS="${ARFLAGS}" RANLIB="${RANLIB}"
# One of these sets is referenced in Mf-config to select between # One of these sets is referenced in Mf-config to select between
# linking with kernel.o or libkernel.a # linking with kernel.o or libkernel.a

View File

@ -5,7 +5,7 @@
# define ACQUIRE_FENCE() __asm__ __volatile__ ("dmb ish" : : : "memory") # define ACQUIRE_FENCE() __asm__ __volatile__ ("dmb ish" : : : "memory")
# define RELEASE_FENCE() ACQUIRE_FENCE() # define RELEASE_FENCE() ACQUIRE_FENCE()
#elif defined(__arm__) #elif defined(__arm__)
# if arm_isa_version == 7 # if (arm_isa_version >= 7) || (__ARM_ARCH >= 7)
# define STORE_FENCE() __asm__ __volatile__ ("dmb ishst" : : : "memory") # define STORE_FENCE() __asm__ __volatile__ ("dmb ishst" : : : "memory")
# define ACQUIRE_FENCE() __asm__ __volatile__ ("dmb ish" : : : "memory") # define ACQUIRE_FENCE() __asm__ __volatile__ ("dmb ish" : : : "memory")
# define RELEASE_FENCE() ACQUIRE_FENCE() # define RELEASE_FENCE() ACQUIRE_FENCE()
@ -72,15 +72,18 @@ FORCEINLINE int CAS_STORE_RELEASE(volatile void *addr, void *old_val, void *new_
return ret; return ret;
} }
#elif defined(__arm__) #elif defined(__arm__)
FORCEINLINE int S_cas_any_fence(volatile void *addr, void *old_val, void *new_val) { FORCEINLINE int S_cas_any_fence(int load_acquire, volatile void *addr, void *old_val, void *new_val) {
int ret; int ret;
__asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5\n\t" if (load_acquire)
"mov %0, #0\n\t" ACQUIRE_FENCE();
else
RELEASE_FENCE();
__asm__ __volatile__ ("mov %0, #0\n\t"
"0:\n\t" "0:\n\t"
"ldrex r12, [%1, #0]\n\t" "ldrex r12, [%1]\n\t"
"cmp r12, %2\n\t" "cmp r12, %2\n\t"
"bne 1f\n\t" "bne 1f\n\t"
"strex r7, %3, [%1, #0]\n\t" "strex r7, %3, [%1]\n\t"
"cmp r7, #0\n\t" "cmp r7, #0\n\t"
"bne 1f\n\t" "bne 1f\n\t"
"it eq\n\t" "it eq\n\t"
@ -91,7 +94,8 @@ FORCEINLINE int S_cas_any_fence(volatile void *addr, void *old_val, void *new_va
: "cc", "memory", "r12", "r7"); : "cc", "memory", "r12", "r7");
return ret; return ret;
} }
# define CAS_ANY_FENCE(a, old, new) S_cas_any_fence(a, old, new) # define CAS_LOAD_ACQUIRE(a, old, new) S_cas_any_fence(1, a, old, new)
# define CAS_STORE_RELEASE(a, old, new) S_cas_any_fence(0, a, old, new)
#elif (__GNUC__ >= 5) || defined(__clang__) #elif (__GNUC__ >= 5) || defined(__clang__)
# define CAS_ANY_FENCE(a, old, new) __sync_bool_compare_and_swap(a, old, new) # define CAS_ANY_FENCE(a, old, new) __sync_bool_compare_and_swap(a, old, new)
#elif defined(_MSC_VER) #elif defined(_MSC_VER)

View File

@ -2088,7 +2088,12 @@ static void s_free(uptr addr) {
} }
#ifdef FEATURE_ICONV #ifdef FEATURE_ICONV
#ifdef WIN32 #ifdef DISABLE_ICONV
# define iconv_t int
#define ICONV_OPEN(to, from) -1
#define ICONV(cd, in, inb, out, outb) -1
#define ICONV_CLOSE(cd) -1
#elif defined(WIN32)
typedef void *iconv_t; typedef void *iconv_t;
typedef iconv_t (*iconv_open_ft)(const char *tocode, const char *fromcode); typedef iconv_t (*iconv_open_ft)(const char *tocode, const char *fromcode);
typedef size_t (*iconv_ft)(iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft); typedef size_t (*iconv_ft)(iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);

View File

@ -134,7 +134,9 @@ typedef char *memcpy_t;
#define MAKE_NAN(x) { x = 0.0; x = x / x; } #define MAKE_NAN(x) { x = 0.0; x = x / x; }
#define GETWD(x) getcwd((x),PATH_MAX) #define GETWD(x) getcwd((x),PATH_MAX)
typedef int tputsputcchar; typedef int tputsputcchar;
#define LOCKF #ifndef __ANDROID__
# define LOCKF
#endif
#define DIRMARKERP(c) ((c) == '/') #define DIRMARKERP(c) ((c) == '/')
#ifndef DISABLE_X11 #ifndef DISABLE_X11
# define LIBX11 "libX11.so" # define LIBX11 "libX11.so"
@ -149,6 +151,10 @@ typedef int tputsputcchar;
#define NSECCTIME(sb) (sb).st_ctim.tv_nsec #define NSECCTIME(sb) (sb).st_ctim.tv_nsec
#define NSECMTIME(sb) (sb).st_mtim.tv_nsec #define NSECMTIME(sb) (sb).st_mtim.tv_nsec
#define ICONV_INBUF_TYPE char ** #define ICONV_INBUF_TYPE char **
#ifdef __ANDROID__
# define NOFILE 256
# define NO_USELOCALE
#endif
#define UNUSED __attribute__((__unused__)) #define UNUSED __attribute__((__unused__))
#endif #endif
@ -175,7 +181,7 @@ typedef int tputsputcchar;
#define SECMTIME(sb) (sb).st_mtimespec.tv_sec #define SECMTIME(sb) (sb).st_mtimespec.tv_sec
#define NSECATIME(sb) (sb).st_atimespec.tv_nsec #define NSECATIME(sb) (sb).st_atimespec.tv_nsec
#define NSECCTIME(sb) (sb).st_ctimespec.tv_nsec #define NSECCTIME(sb) (sb).st_ctimespec.tv_nsec
#define NSECMTIME(sb) (sb).st_mtimespec.tv_nsec #define NSECM<TIME(sb) (sb).st_mtimespec.tv_nsec
#define ICONV_INBUF_TYPE char ** #define ICONV_INBUF_TYPE char **
#define UNUSED __attribute__((__unused__)) #define UNUSED __attribute__((__unused__))
#define USE_OSSP_UUID #define USE_OSSP_UUID

View File

@ -57,6 +57,7 @@ installscriptname="scheme-script"
cflagsset=no cflagsset=no
disablex11=no disablex11=no
disablecurses=no disablecurses=no
disableiconv=no
addflags=yes addflags=yes
addwarningflags=no addwarningflags=no
default_warning_flags="-Wpointer-arith -Wall -Wextra -Werror -Wno-implicit-fallthrough" default_warning_flags="-Wpointer-arith -Wall -Wextra -Werror -Wno-implicit-fallthrough"
@ -273,6 +274,9 @@ while [ $# != 0 ] ; do
--disable-curses) --disable-curses)
disablecurses=yes disablecurses=yes
;; ;;
--disable-iconv)
disableiconv=yes
;;
--disable-auto-flags) --disable-auto-flags)
addflags=no addflags=no
;; ;;
@ -420,6 +424,7 @@ if [ "$help" = "yes" ]; then
echo " --32|--64 specify 32/64-bit version ($bits)" echo " --32|--64 specify 32/64-bit version ($bits)"
echo " --disable-x11 disable X11 support" echo " --disable-x11 disable X11 support"
echo " --disable-curses disable [n]curses support" echo " --disable-curses disable [n]curses support"
echo " --disable-iconv disable iconv support"
echo " --disable-auto-flags no auto additions to CFLAGS/LDFLAGS/LIBS" echo " --disable-auto-flags no auto additions to CFLAGS/LDFLAGS/LIBS"
echo " --enable-warning-flags add GCC warning flags to CFLAGS" echo " --enable-warning-flags add GCC warning flags to CFLAGS"
echo " --libkernel build libkernel.a (the default)" echo " --libkernel build libkernel.a (the default)"
@ -565,6 +570,13 @@ if [ "$disablecurses" = "yes" ]; then
ncursesLib= ncursesLib=
fi fi
if [ "$disableiconv" = "yes" ]; then
iconvLib=
CPPFLAGS="${CPPFLAGS} -DDISABLE_ICONV"
else
iconvLib="-liconv"
fi
# Add automatic linking flags, unless suppressed by --disable-auto-flags # Add automatic linking flags, unless suppressed by --disable-auto-flags
if [ "$addflags" = "yes" ] ; then if [ "$addflags" = "yes" ] ; then
case "${flagsm}" in case "${flagsm}" in
@ -586,22 +598,28 @@ if [ "$addflags" = "yes" ] ; then
LIBS="${LIBS} -lm -ldl ${ncursesLib} -lrt" LIBS="${LIBS} -lm -ldl ${ncursesLib} -lrt"
;; ;;
*fb|*ob) *fb|*ob)
LIBS="${LIBS} -liconv -lm ${ncursesLib}" LIBS="${LIBS} ${iconvLib} -lm ${ncursesLib}"
;; ;;
*nb) *nb)
LIBS="${LIBS} /usr/lib/i18n/libiconv_std.a -lm /usr/pkg/lib/libncurses.a" if [ "$disablecurses" = "no" ]; then
iconvLib="/usr/lib/i18n/libiconv_std.a"
fi
LIBS="${LIBS} ${iconvLib} -lm /usr/pkg/lib/libncurses.a"
;; ;;
*s2) *s2)
LIBS="${LIBS} -lnsl -ldl -lm ${cursesLib} -lrt" LIBS="${LIBS} -lnsl -ldl -lm ${cursesLib} -lrt"
;; ;;
*osx) *osx)
LIBS="${LIBS} -liconv -lm ${ncursesLib}" LIBS="${LIBS} ${iconvLib} -lm ${ncursesLib}"
;; ;;
*nt) *nt)
LIBS="${LIBS} -lshell32 -luser32 -lole32 -lrpcrt4 -luuid" LIBS="${LIBS} -lshell32 -luser32 -lole32 -lrpcrt4 -luuid"
;; ;;
8qnx) 8qnx)
LIBS="${LIBS} -lm /usr/local/lib/libiconv.so -lsocket ${ncursesLib}" if [ "$disablecurses" = "no" ]; then
iconvLib="/usr/local/lib/libiconv.so"
fi
LIBS="${LIBS} -lm ${iconvLib} -lsocket ${ncursesLib}"
;; ;;
esac esac
if [ "$threadLibs" != "" ] ; then if [ "$threadLibs" != "" ] ; then

View File

@ -734,7 +734,7 @@
(nl) (nl)
(pr "#define SPINLOCK(addr) \\~%") (pr "#define SPINLOCK(addr) \\~%")
(pr " __asm__ __volatile__ (\"0:\\n\\t\"\\~%") (pr " __asm__ __volatile__ (\"0:\\n\\t\"\\~%")
(pr " \"ldrex r12, [%0, #0]\\n\\t\"\\~%") (pr " \"ldrex r12, [%0]\\n\\t\"\\~%")
(pr " \"cmp r12, #0\\n\\t\"\\~%") (pr " \"cmp r12, #0\\n\\t\"\\~%")
(pr " \"bne 1f\\n\\t\"\\~%") (pr " \"bne 1f\\n\\t\"\\~%")
(pr " \"mov r12, #1\\n\\t\"\\~%") (pr " \"mov r12, #1\\n\\t\"\\~%")
@ -763,7 +763,7 @@
(pr "#define LOCKED_INCR(addr, ret) \\~%") (pr "#define LOCKED_INCR(addr, ret) \\~%")
(pr " __asm__ __volatile__ (\"mov %0, #0\\n\\t\"\\~%") (pr " __asm__ __volatile__ (\"mov %0, #0\\n\\t\"\\~%")
(pr " \"0:\\n\\t\"\\~%") (pr " \"0:\\n\\t\"\\~%")
(pr " \"ldrex r12, [%1, #0]\\n\\t\"\\~%") (pr " \"ldrex r12, [%1]\\n\\t\"\\~%")
(pr " \"add r12, r12, #1\\n\\t\"\\~%") (pr " \"add r12, r12, #1\\n\\t\"\\~%")
(pr " \"strex r7, r12, [%1]\\n\\t\"\\~%") (pr " \"strex r7, r12, [%1]\\n\\t\"\\~%")
(pr " \"cmp r7, #0\\n\\t\"\\~%") (pr " \"cmp r7, #0\\n\\t\"\\~%")
@ -779,7 +779,7 @@
(pr "#define LOCKED_DECR(addr, ret) \\~%") (pr "#define LOCKED_DECR(addr, ret) \\~%")
(pr " __asm__ __volatile__ (\"mov %0, #0\\n\\t\"\\~%") (pr " __asm__ __volatile__ (\"mov %0, #0\\n\\t\"\\~%")
(pr " \"0:\\n\\t\"\\~%") (pr " \"0:\\n\\t\"\\~%")
(pr " \"ldrex r12, [%1, #0]\\n\\t\"\\~%") (pr " \"ldrex r12, [%1]\\n\\t\"\\~%")
(pr " \"sub r12, r12, #1\\n\\t\"\\~%") (pr " \"sub r12, r12, #1\\n\\t\"\\~%")
(pr " \"strex r7, r12, [%1]\\n\\t\"\\~%") (pr " \"strex r7, r12, [%1]\\n\\t\"\\~%")
(pr " \"cmp r7, #0\\n\\t\"\\~%") (pr " \"cmp r7, #0\\n\\t\"\\~%")

View File

@ -94,7 +94,7 @@ no-local-racket:
@RUN_LOCAL_RACKET@: @RUN_LOCAL_RACKET@:
mkdir -p local mkdir -p local
$(MAKE) local/Makefile $(MAKE) local/Makefile
cd local && $(MAKE) cd local && $(MAKE) @LOCAL_RACKET_TARGET@
local/Makefile: local/Makefile:
cd local && `cd ..; cd $(srcdir); pwd`/configure --disable-gracket @CONFIGURE_LOCAL_RACKET@ cd local && `cd ..; cd $(srcdir); pwd`/configure --disable-gracket @CONFIGURE_LOCAL_RACKET@

View File

@ -371,66 +371,84 @@ Some less commonly needed `configure` flags are for Racket BC:
Cross-compiling for Android Cross-compiling for Android
======================================================================== ========================================================================
[Currently, cross-compilation for Android works only for the Racket BC As an example of cross-compiling Racket for Android on ARMv7 using the
implementation.] NDK, use (all on one line)
As an example of cross-compiling, to compile for Android on ARM using
the NDK, use (all on one line)
configure --host=arm-linux-androideabi configure --host=arm-linux-androideabi
--enable-sysroot="[ndk]/platforms/android-[N]/arch-arm" --enable-sysroot="[sysroot]"
--enable-racket=auto --enable-racket=auto
where [ndk] is the path to the installed NDK, [N] is a target version If you use the NDK script "make-standalone-toolchain.sh" to generate a
of Android (such as 14), and toolchain directory, then include that directory's "bin" in your PATH
(so that `arm-linux-androideabi-gcc`, etc., are found), and you can
omit `--enable-sysroot` (or specify [sysroot] as the toolchain
directory's "sysroot" subdirectory).
In other NDK configurations, you may have
[ndk]/toolchains/arm-linux-androideabi-[comp]/prebuilt/[platform]/bin [ndk]/toolchains/arm-linux-androideabi-[comp]/prebuilt/[platform]/bin
is in your PATH (so that a suitable `gcc`, `ar`, etc., are found) for in your PATH (so that `arm-linux-androideabi-gcc`, etc., are found)
the [comp] of your choice and the [platform] used to compile. where [ndk] is the path to the installed NDK and for the [comp] of
your choice and the [platform] used to compile, and then [sysroot] is
[ndk]/platforms/android-[N]/arch-arm
where [N] is a target version of Android (such as 14).
For 64-bit ARM, replace "arm" above with "aarch64", and replace
"androideabi" with "android".
When building BC, you may need to add `--disable-cify` for 32-bit ARM
and `--enable-cify` for 64-bit ARM instead of inheriting the build
machine's disposition.
======================================================================== ========================================================================
Cross-compiling for iOS Cross-compiling for iOS
======================================================================== ========================================================================
To compile the Racket BC runtime system as a Framework for iOS, use To compile the Racket runtime system as a Framework for iOS, use (all
(all on one line) on one line)
configure --host=[arch]-apple-darwin configure --host=[arch]-apple-darwin
--enable-ios="[sdk]" --enable-ios="[sdk]"
--enable-racket=racket --enable-racket=auto
--enable-bcdefault
where [arch] is one of where [arch] is one of
- armv7, armv7s, or aarch64: to run on iOS - armv7, armv7s, or aarch64: to run on iOS
- i386 or x86_64: to run on the simulator - x86_64 or aarch64: to run on the simulator
The [sdk] argument is a path to an iOS SDK, but if it is "iPhoneOS" or The [sdk] argument is a path to an iOS SDK for "iPhoneOS" or
"iPhoneSimulator", then the corresponding SDK is located in the "iPhoneSimulator". The corresponding SDK is located in the standard
standard place within the XCode application. For example, "iPhoneOS" place within the XCode application. For example, "iPhoneOS" becomes
becomes the path (all on one line) the path (all on one line)
/Applications/Xcode.app/Contents/Developer/Platforms/ /Applications/Xcode.app/Contents/Developer/Platforms/
iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
To cross-compile for CS, you must supply the Chez Scheme compiler that To use an existing Racket build for the build platform using
Racket CS was built with. Assuming you have built Racket CS for your `--enable-racket`, be sure to include `--enable-scheme` for Racket CS.
machine at "/path/to/racket" using the default `make` target, you can For example, if you have built Racket CS for your machine at
configure the cross build using that Racket binary and a path to the "/path/to/racket" using the default `make` target, you can configure
Chez Scheme build folder as follows (all on one line) the cross build using that Racket binary and a path to the Chez Scheme
build folder as follows (all on one line)
configure --host=[arch]-apple-darwin configure --host=[arch]-apple-darwin
--enable-ios="[sdk]" --enable-ios="[sdk]"
--enable-racket=/path/to/racket/bin/racket --enable-racket=/path/to/racket/bin/racket
--enable-scheme=/path/to/racket/src/build/cs/c --enable-scheme=/path/to/racket/src/build/cs/c
Currently, iOS enforces strict W^X protection on memory pages. See the Currently, iOS enforces W^X protection on memory pages, which is
note about "writes to `space_code` memory" in "ChezScheme/c/segment.c" technically a problem for Racket CS. See the note about "writes to
for the implications this has on Racket CS. In principle, if you avoid `space_code` memory" in "ChezScheme/c/segment.c" for the implications.
passing newly-allocated code between threads and avoid `#:blocking?` If you avoid passing newly-allocated code between threads and avoid
foreign callbacks, you should not run into any issues. `#:blocking?` foreign callbacks, you might not run into any issues.
When building BC for iOS, you may need to add `--disable-cify` for
32-bit target and `--enable-cify` for 64-bit target instead of
inheriting the build machine's disposition.
======================================================================== ========================================================================

View File

@ -40,6 +40,7 @@ if test "${enable_racket}" = "auto" ; then
fi fi
RUN_LOCAL_RACKET="local/bc/racket3m" RUN_LOCAL_RACKET="local/bc/racket3m"
CONFIGURE_LOCAL_RACKET=--enable-bc CONFIGURE_LOCAL_RACKET=--enable-bc
LOCAL_RACKET_TARGET=bc
if test "${enable_cgcdefault}" = "yes" ; then if test "${enable_cgcdefault}" = "yes" ; then
MAIN_VARIANT=cgc MAIN_VARIANT=cgc
@ -62,6 +63,7 @@ AC_SUBST(RUN_RACKET)
AC_SUBST(MAKE_LOCAL_RACKET) AC_SUBST(MAKE_LOCAL_RACKET)
AC_SUBST(RUN_LOCAL_RACKET) AC_SUBST(RUN_LOCAL_RACKET)
AC_SUBST(CONFIGURE_LOCAL_RACKET) AC_SUBST(CONFIGURE_LOCAL_RACKET)
AC_SUBST(LOCAL_RACKET_TARGET)
makefiles="Makefile" makefiles="Makefile"

View File

@ -585,6 +585,7 @@ ac_unique_file="setup-go.rkt"
enable_option_checking=no enable_option_checking=no
ac_subst_vars='LTLIBOBJS ac_subst_vars='LTLIBOBJS
LIBOBJS LIBOBJS
LOCAL_RACKET_TARGET
CONFIGURE_LOCAL_RACKET CONFIGURE_LOCAL_RACKET
RUN_LOCAL_RACKET RUN_LOCAL_RACKET
RUN_RACKET RUN_RACKET
@ -2330,6 +2331,7 @@ if test "${enable_racket}" = "auto" ; then
fi fi
RUN_LOCAL_RACKET="local/bc/racket3m" RUN_LOCAL_RACKET="local/bc/racket3m"
CONFIGURE_LOCAL_RACKET=--enable-bc CONFIGURE_LOCAL_RACKET=--enable-bc
LOCAL_RACKET_TARGET=bc
if test "${enable_cgcdefault}" = "yes" ; then if test "${enable_cgcdefault}" = "yes" ; then
MAIN_VARIANT=cgc MAIN_VARIANT=cgc
@ -2353,6 +2355,7 @@ fi
makefiles="Makefile" makefiles="Makefile"
ac_config_files="$ac_config_files $makefiles" ac_config_files="$ac_config_files $makefiles"

View File

@ -585,6 +585,7 @@ ac_unique_file="setup-go.rkt"
enable_option_checking=no enable_option_checking=no
ac_subst_vars='LTLIBOBJS ac_subst_vars='LTLIBOBJS
LIBOBJS LIBOBJS
LOCAL_RACKET_TARGET
CONFIGURE_LOCAL_RACKET CONFIGURE_LOCAL_RACKET
RUN_LOCAL_RACKET RUN_LOCAL_RACKET
RUN_RACKET RUN_RACKET
@ -2239,6 +2240,7 @@ if test "${enable_racket}" = "auto" ; then
fi fi
RUN_LOCAL_RACKET="local/cs/c/racketcs" RUN_LOCAL_RACKET="local/cs/c/racketcs"
CONFIGURE_LOCAL_RACKET=--enable-cs CONFIGURE_LOCAL_RACKET=--enable-cs
LOCAL_RACKET_TARGET=cs
# If BC is the default, then we rely on BC configure-parent # If BC is the default, then we rely on BC configure-parent
# being used instead of this one: # being used instead of this one:
@ -2256,6 +2258,7 @@ fi
makefiles="Makefile" makefiles="Makefile"
ac_config_files="$ac_config_files $makefiles" ac_config_files="$ac_config_files $makefiles"

View File

@ -155,6 +155,11 @@ mach-make:
$(MAKE) config-scheme $(MAKE) config-scheme
cd $(SCHEME_WORKAREA) && $(MAKE) cd $(SCHEME_WORKAREA) && $(MAKE)
# Makes cross compilation work more reliably for zlib, because
# it causes zlib/configure to use given AR, etc.
CHOST_HACK-cross = env "CHOST=hack-do-not-use"
CHOST_HACK =
SCHEME_CONFIG_VARS = CC="$(CC)" CFLAGS="$(BASE_CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" \ SCHEME_CONFIG_VARS = CC="$(CC)" CFLAGS="$(BASE_CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" \
AR="$(AR)" ARFLAGS="$(ARFLAGS)" RANLIB="$(RANLIB)" \ AR="$(AR)" ARFLAGS="$(ARFLAGS)" RANLIB="$(RANLIB)" \
WINDRES="$(WINDRES)" WINDRES="$(WINDRES)"
@ -167,7 +172,7 @@ scheme-cross:
env MAKE_BOOT_FOR_CROSS=yes SCHEME_SRC="$(SCHEME_DIR)" SCHEME_WORKAREA=$(SCHEME_WORKAREA) MACH="$(TARGET_MACH)" $(BOOTSTRAP_RACKET) "$(SCHEME_DIR)"/rktboot/make-boot.rkt env MAKE_BOOT_FOR_CROSS=yes SCHEME_SRC="$(SCHEME_DIR)" SCHEME_WORKAREA=$(SCHEME_WORKAREA) MACH="$(TARGET_MACH)" $(BOOTSTRAP_RACKET) "$(SCHEME_DIR)"/rktboot/make-boot.rkt
/bin/sh $(srcdir)/reset_boot.sh $(TARGET_MACH) $(SCHEME_WORKAREA) /bin/sh $(srcdir)/reset_boot.sh $(TARGET_MACH) $(SCHEME_WORKAREA)
cd $(SCHEME_WORKAREA) && "$(UP_SCHEME_DIR)"/configure @SCHEME_CROSS_CONFIG_ARGS@ $(SCHEME_CONFIG_VARS) cd $(SCHEME_WORKAREA) && "$(UP_SCHEME_DIR)"/configure @SCHEME_CROSS_CONFIG_ARGS@ $(SCHEME_CONFIG_VARS)
cd $(SCHEME_WORKAREA)/$(TARGET_MACH)/c && $(MAKE) o=o cross=t cd $(SCHEME_WORKAREA)/$(TARGET_MACH)/c && $(CHOST_HACK@T_CROSS_MODE@) $(MAKE) o=o cross=t
$(MAKE) $(SCHEME_WORKAREA)/$(TARGET_MACH)/s/xpatch $(MAKE) $(SCHEME_WORKAREA)/$(TARGET_MACH)/s/xpatch
# Rebuild patch file and cross "petite.boot" and "scheme.boot" when older # Rebuild patch file and cross "petite.boot" and "scheme.boot" when older
@ -200,11 +205,11 @@ racket.boot: racket.so
EMBED_DEPS = $(srcdir)/embed-boot.rkt EMBED_DEPS = $(srcdir)/embed-boot.rkt
racketcs@NOT_OSX@@NOT_MINGW@: 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@ @BOOT_COMPRESS_COMP@ raw_racketcs racketcs petite-v.boot scheme-v.boot racket-v.boot $(BOOTSTRAP_RACKET) $(srcdir)/embed-boot.rkt @ELF_COMP@ --target $(TARGET_MACH) @BOOT_COMPRESS_COMP@ raw_racketcs racketcs petite-v.boot scheme-v.boot racket-v.boot
@POST_LINKER@ racketcs @POST_LINKER@ racketcs
gracketcs@NOT_OSX@@NOT_MINGW@: 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@ @BOOT_COMPRESS_COMP@ raw_gracketcs gracketcs petite-v.boot scheme-v.boot racket-v.boot $(BOOTSTRAP_RACKET) $(srcdir)/embed-boot.rkt @ELF_COMP@ --target $(TARGET_MACH) @BOOT_COMPRESS_COMP@ raw_gracketcs gracketcs petite-v.boot scheme-v.boot racket-v.boot
@POST_LINKER@ gracketcs @POST_LINKER@ gracketcs
OWN_Z_LIB = $(SCHEME_TARGET_INC)/../../zlib/libz.a OWN_Z_LIB = $(SCHEME_TARGET_INC)/../../zlib/libz.a

View File

@ -4304,7 +4304,8 @@ case "$host_os" in
MACH_OS=fb MACH_OS=fb
CFLAGS="${CFLAGS} -I/usr/local/include" CFLAGS="${CFLAGS} -I/usr/local/include"
LDFLAGS="${LDFLAGS} -L/usr/local/lib" LDFLAGS="${LDFLAGS} -L/usr/local/lib"
LIBS="${LIBS} -liconv -lm -lpthread" LIBS="${LIBS} -lm -lpthread"
add_iconv_lib="-liconv"
CPPFLAGS="${CPPFLAGS} -DELF_FIND_BOOT_SECTION" CPPFLAGS="${CPPFLAGS} -DELF_FIND_BOOT_SECTION"
ELF_COMP="--expect-elf" ELF_COMP="--expect-elf"
;; ;;
@ -4312,7 +4313,8 @@ case "$host_os" in
MACH_OS=ob MACH_OS=ob
CFLAGS="${CFLAGS} -I/usr/local/include" CFLAGS="${CFLAGS} -I/usr/local/include"
LDFLAGS="${LDFLAGS} -L/usr/local/lib" LDFLAGS="${LDFLAGS} -L/usr/local/lib"
LIBS="${LIBS} -liconv -lm -lpthread" LIBS="${LIBS} -lm -lpthread"
add_iconv_lib="-liconv"
LDFLAGS="${LDFLAGS} -Wl,-zwxneeded" LDFLAGS="${LDFLAGS} -Wl,-zwxneeded"
CPPFLAGS="${CPPFLAGS} -DELF_FIND_BOOT_SECTION" CPPFLAGS="${CPPFLAGS} -DELF_FIND_BOOT_SECTION"
ELF_COMP="--expect-elf" ELF_COMP="--expect-elf"
@ -4323,7 +4325,8 @@ case "$host_os" in
;; ;;
netbsd*) netbsd*)
MACH_OS=nb MACH_OS=nb
LIBS="${LIBS} /usr/lib/i18n/libiconv_std.a -lm -lpthread" LIBS="${LIBS} -lm -lpthread"
add_iconv_lib="/usr/lib/i18n/libiconv_std.a"
CPPFLAGS="${CPPFLAGS} -DELF_FIND_BOOT_SECTION" CPPFLAGS="${CPPFLAGS} -DELF_FIND_BOOT_SECTION"
ELF_COMP="--expect-elf" ELF_COMP="--expect-elf"
POST_LINKER="paxctl +m" POST_LINKER="paxctl +m"
@ -4332,7 +4335,13 @@ case "$host_os" in
;; ;;
linux*) linux*)
MACH_OS=le MACH_OS=le
case "$host_os" in
*linux-android*)
;;
*)
LIBS="${LIBS} -lrt" LIBS="${LIBS} -lrt"
;;
esac
CPPFLAGS="${CPPFLAGS} -DELF_FIND_BOOT_SECTION" CPPFLAGS="${CPPFLAGS} -DELF_FIND_BOOT_SECTION"
ELF_COMP="--expect-elf" ELF_COMP="--expect-elf"
;; ;;
@ -5343,6 +5352,8 @@ if test "${enable_iconv}" = "no" ; then
$as_echo "#define RKTIO_NO_ICONV 1" >>confdefs.h $as_echo "#define RKTIO_NO_ICONV 1" >>confdefs.h
extra_scheme_config_args="${extra_scheme_config_args} --disable-iconv"
add_iconv_lib=
fi fi
if test "${enable_iconv}" = "yes" ; then if test "${enable_iconv}" = "yes" ; then
@ -5373,6 +5384,10 @@ rm -f core conftest.err conftest.$ac_objext \
$as_echo "$have_codeset" >&6; } $as_echo "$have_codeset" >&6; }
fi fi
if test "${add_iconv_lib}" != "" ; then
LIBS="${LIBS} ${add_iconv_lib}"
fi
############### pthread ################### ############### pthread ###################
if test "${enable_pthread}" = "yes" ; then if test "${enable_pthread}" = "yes" ; then

View File

@ -30,6 +30,7 @@ if test "${enable_racket}" = "auto" ; then
fi fi
RUN_LOCAL_RACKET="local/cs/c/racketcs" RUN_LOCAL_RACKET="local/cs/c/racketcs"
CONFIGURE_LOCAL_RACKET=--enable-cs CONFIGURE_LOCAL_RACKET=--enable-cs
LOCAL_RACKET_TARGET=cs
# If BC is the default, then we rely on BC configure-parent # If BC is the default, then we rely on BC configure-parent
# being used instead of this one: # being used instead of this one:
@ -46,6 +47,7 @@ AC_SUBST(RUN_RACKET)
AC_SUBST(MAKE_LOCAL_RACKET) AC_SUBST(MAKE_LOCAL_RACKET)
AC_SUBST(RUN_LOCAL_RACKET) AC_SUBST(RUN_LOCAL_RACKET)
AC_SUBST(CONFIGURE_LOCAL_RACKET) AC_SUBST(CONFIGURE_LOCAL_RACKET)
AC_SUBST(LOCAL_RACKET_TARGET)
makefiles="Makefile" makefiles="Makefile"

View File

@ -220,7 +220,8 @@ case "$host_os" in
MACH_OS=fb MACH_OS=fb
CFLAGS="${CFLAGS} -I/usr/local/include" CFLAGS="${CFLAGS} -I/usr/local/include"
LDFLAGS="${LDFLAGS} -L/usr/local/lib" LDFLAGS="${LDFLAGS} -L/usr/local/lib"
LIBS="${LIBS} -liconv -lm -lpthread" LIBS="${LIBS} -lm -lpthread"
add_iconv_lib="-liconv"
CPPFLAGS="${CPPFLAGS} -DELF_FIND_BOOT_SECTION" CPPFLAGS="${CPPFLAGS} -DELF_FIND_BOOT_SECTION"
ELF_COMP="--expect-elf" ELF_COMP="--expect-elf"
;; ;;
@ -228,7 +229,8 @@ case "$host_os" in
MACH_OS=ob MACH_OS=ob
CFLAGS="${CFLAGS} -I/usr/local/include" CFLAGS="${CFLAGS} -I/usr/local/include"
LDFLAGS="${LDFLAGS} -L/usr/local/lib" LDFLAGS="${LDFLAGS} -L/usr/local/lib"
LIBS="${LIBS} -liconv -lm -lpthread" LIBS="${LIBS} -lm -lpthread"
add_iconv_lib="-liconv"
LDFLAGS="${LDFLAGS} -Wl,-zwxneeded" LDFLAGS="${LDFLAGS} -Wl,-zwxneeded"
CPPFLAGS="${CPPFLAGS} -DELF_FIND_BOOT_SECTION" CPPFLAGS="${CPPFLAGS} -DELF_FIND_BOOT_SECTION"
ELF_COMP="--expect-elf" ELF_COMP="--expect-elf"
@ -239,7 +241,8 @@ case "$host_os" in
;; ;;
netbsd*) netbsd*)
MACH_OS=nb MACH_OS=nb
LIBS="${LIBS} /usr/lib/i18n/libiconv_std.a -lm -lpthread" LIBS="${LIBS} -lm -lpthread"
add_iconv_lib="/usr/lib/i18n/libiconv_std.a"
CPPFLAGS="${CPPFLAGS} -DELF_FIND_BOOT_SECTION" CPPFLAGS="${CPPFLAGS} -DELF_FIND_BOOT_SECTION"
ELF_COMP="--expect-elf" ELF_COMP="--expect-elf"
POST_LINKER="paxctl +m" POST_LINKER="paxctl +m"
@ -248,7 +251,13 @@ case "$host_os" in
;; ;;
linux*) linux*)
MACH_OS=le MACH_OS=le
case "$host_os" in
*linux-android*)
;;
*)
LIBS="${LIBS} -lrt" LIBS="${LIBS} -lrt"
;;
esac
CPPFLAGS="${CPPFLAGS} -DELF_FIND_BOOT_SECTION" CPPFLAGS="${CPPFLAGS} -DELF_FIND_BOOT_SECTION"
ELF_COMP="--expect-elf" ELF_COMP="--expect-elf"
;; ;;
@ -529,6 +538,8 @@ AC_LANG_C
m4_include(../ac/iconv.m4) m4_include(../ac/iconv.m4)
if test "${enable_iconv}" = "no" ; then if test "${enable_iconv}" = "no" ; then
AC_DEFINE(RKTIO_NO_ICONV,1,[Do not use iconv]) AC_DEFINE(RKTIO_NO_ICONV,1,[Do not use iconv])
extra_scheme_config_args="${extra_scheme_config_args} --disable-iconv"
add_iconv_lib=
fi fi
if test "${enable_iconv}" = "yes" ; then if test "${enable_iconv}" = "yes" ; then
@ -541,6 +552,10 @@ if test "${enable_iconv}" = "yes" ; then
AC_MSG_RESULT($have_codeset) AC_MSG_RESULT($have_codeset)
fi fi
if test "${add_iconv_lib}" != "" ; then
LIBS="${LIBS} ${add_iconv_lib}"
fi
############### pthread ################### ############### pthread ###################
if test "${enable_pthread}" = "yes" ; then if test "${enable_pthread}" = "yes" ; then

View File

@ -4231,7 +4231,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
return 0; return 0;
} }
_ACEOF _ACEOF
if ac_fn_c_try_compile "$LINENO"; then : if ac_fn_c_try_link "$LINENO"; then :
$as_echo "#define RKTIO_USE_XLOCALE 1" >>confdefs.h $as_echo "#define RKTIO_USE_XLOCALE 1" >>confdefs.h
@ -4239,7 +4239,8 @@ $as_echo "#define RKTIO_USE_XLOCALE 1" >>confdefs.h
else else
xlocaleon=no xlocaleon=no
fi fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xlocaleon" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xlocaleon" >&5
$as_echo "$xlocaleon" >&6; } $as_echo "$xlocaleon" >&6; }
CFLAGS="$SAVE_CFLAGS" CFLAGS="$SAVE_CFLAGS"

View File

@ -175,7 +175,7 @@ if test "${xlocalehon}" = "yes" ; then
fi fi
[ msg="for xlocale functions" ] [ msg="for xlocale functions" ]
AC_MSG_CHECKING($msg) AC_MSG_CHECKING($msg)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([ AC_LINK_IFELSE([AC_LANG_SOURCE([
#ifdef RKTIO_USE_XLOCALE_HEADER #ifdef RKTIO_USE_XLOCALE_HEADER
# include <xlocale.h> # include <xlocale.h>
#endif #endif

View File

@ -50,6 +50,7 @@
# ifdef __ANDROID__ # ifdef __ANDROID__
# define PROTOENT_IS_INT IPPROTO_TCP # define PROTOENT_IS_INT IPPROTO_TCP
# define NO_PTHREAD_CANCEL
# endif # endif
#endif #endif
@ -342,3 +343,7 @@
standalone Racket. Used only if NO_SLEEP is undefined. */ standalone Racket. Used only if NO_SLEEP is undefined. */
/* NO_STRERROR_AVAILABLE means that strerror() is not available. */ /* NO_STRERROR_AVAILABLE means that strerror() is not available. */
/* NO_PTHREAD_CANCEL means that pthread_setcanceltype() is
not available, which means it can't be used to implement
non-blocking open(). */

View File

@ -360,7 +360,7 @@ void rktio_close_fds_after_fork(int len, int skip1, int skip2, int skip3);
int rktio_system_fd_is_terminal(rktio_t *rktio, intptr_t fd); int rktio_system_fd_is_terminal(rktio_t *rktio, intptr_t fd);
#ifdef RKTIO_USE_PTHREADS #if defined(RKTIO_USE_PTHREADS) && !defined(NO_PTHREAD_CANCEL)
# define RKTIO_USE_PENDING_OPEN # define RKTIO_USE_PENDING_OPEN
#endif #endif