[racket-dev] mac builds with 64-bit kernel

From: Matthew Blakley (zarcher at gmail.com)
Date: Tue Feb 8 03:15:37 EST 2011

I've been trying to duplicate the macintel builds from the meta/build system on mac 10.6 system with 64-bit kernel (uname -m => x86_64).

So in a git plt tree...

    ../src/configure --enable-sdk=/Developer/SDKs/MacOSX10.4u.sdk
    make both

fails with...

libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../../src/foreign/libffi -I. -I../../../src/foreign/libffi/include -Iinclude -I../../../src/foreign/libffi/src -Wall -g -fexceptions -g -O2 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -DEXTRA_EXCEPTION_STUBS -MT src/x86/ffi64.lo -MD -MP -MF src/x86/.deps/ffi64.Tpo -c ../../../src/foreign/libffi/src/x86/ffi64.c  -fno-common -DPIC -o src/x86/.libs/ffi64.o
In file included from ../../../src/foreign/libffi/src/x86/ffi64.c:32:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
../../../src/foreign/libffi/src/x86/ffi64.c: In function ‘ffi_call’:
../../../src/foreign/libffi/src/x86/ffi64.c:452: warning: implicit declaration of function ‘memcpy’
../../../src/foreign/libffi/src/x86/ffi64.c:452: warning: incompatible implicit declaration of built-in function ‘memcpy’
../../../src/foreign/libffi/src/x86/ffi64.c:468: warning: incompatible implicit declaration of built-in function ‘memcpy’
../../../src/foreign/libffi/src/x86/ffi64.c: In function ‘ffi_closure_unix64_inner’:
../../../src/foreign/libffi/src/x86/ffi64.c:613: warning: incompatible implicit declaration of built-in function ‘memcpy’
make[8]: *** [src/x86/ffi64.lo] Error 1
make[7]: *** [libffi/libffi.la] Error 2
make[6]: *** [all] Error 2
make[5]: *** [foreign-stuff] Error 2
make[4]: *** [common] Error 2
make[3]: *** [cgc] Error 2
make[2]: *** [cgc] Error 2
make[1]: *** [both] Error 2

It appears that the problem centers around the 

  if test `${UNAME} -m` = "i386" ; then

in the configure script and hacking out this test allows for the build to complete.

diff --git a/src/configure b/src/configure
index 29d69a8..68d7155 100755
--- a/src/configure
+++ b/src/configure
@@ -5327,7 +5327,6 @@ case $OS in
     # Force 32-bit build unless mac64 is enabled:
     if test "${enable_mac64}" != "yes" ; then
-      if test `${UNAME} -m` = "i386" ; then
         if test "${ORIG_CC}" = "" ; then
            PREFLAGS="${PREFLAGS} -m32"
            CPPFLAGS="${CPPFLAGS} -m32"
@@ -5336,7 +5335,6 @@ case $OS in
            # instead of CFLAGS:
            SUB_CONFIGURE_EXTRAS="${SUB_CONFIGURE_EXTRAS} CC="'"'"${CC}"' -m32"'
-      fi
     if test "${enable_quartz}" = "yes" ; then

This is only meant to be illustrative since the real fix needs to be in configure.ac and likely there was a reason for this check so removal may not be an option.

Even with this change though, note that

    ../src/configure --enable-mac64 --enable-sdk=/Developer/SDKs/MacOSX10.4u.sdk

also doesn't work because the CC=gcc-4.0 SUB_CONFIGURE_EXTRAS never gets set for libffi. Hm, also just noticed that enable_futures_by_default=yes also appears like it won't be set properly since it is with a uname -m == i386 check as well. I suspect these i386 checks are to distinguish from ppc, so maybe they should just change to uname -m != ppc in the darwin/mac sections.

Posted on the dev mailing list.