Ticket #2442: 0ad_mozjs24_osx_build_fixes_03102014.patch

File 0ad_mozjs24_osx_build_fixes_03102014.patch, 8.6 KB (added by historic_bruno, 10 years ago)
  • libraries/osx/build-osx-libs.sh

    diff --git a/libraries/osx/build-osx-libs.sh b/libraries/osx/build-osx-libs.sh
    index 16f4a26..7718304 100755
    a b OGG_VERSION="libogg-1.3.0"  
    3838VORBIS_VERSION="libvorbis-1.3.3"
    3939# gloox is necessary for multiplayer lobby
    4040GLOOX_VERSION="gloox-1.0.9"
    41 # NSPR is necessary for threadsafe Spidermonkey
    42 NSPR_VERSION="4.10.3"
     41# NSPR is necessary for threadsafe Spidermonkey
     42NSPR_VERSION="4.10.3"
    4343# --------------------------------------------------------------
    4444# Bundled with the game:
    45 # * SpiderMonkey 24
     45# * SpiderMonkey 24
    4646# * ENet 1.3.3
    4747# * NVTT
    4848# * FCollada
    else  
    520520fi
    521521popd > /dev/null
    522522
    523 # --------------------------------------------------------------
    524 echo -e "Building NSPR..."
    525 
    526 LIB_VERSION="${NSPR_VERSION}"
    527 LIB_ARCHIVE="nspr-$LIB_VERSION.tar.gz"
    528 LIB_DIRECTORY="nspr-$LIB_VERSION"
    529 LIB_URL="https://ftp.mozilla.org/pub/mozilla.org/nspr/releases/v$LIB_VERSION/src/"
    530 
    531 mkdir -p nspr
    532 pushd nspr > /dev/null
    533 
    534 NSPR_DIR="$(pwd)"
    535 
    536 if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
    537 then
    538   rm -f .already-built
    539   download_lib $LIB_URL $LIB_ARCHIVE
    540 
    541   rm -rf $LIB_DIRECTORY bin include lib share
    542   tar -xf $LIB_ARCHIVE
    543   pushd $LIB_DIRECTORY/nspr
    544 
    545   (CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" ./configure --prefix="$NSPR_DIR" && make ${JOBS} && make install) || die "NSPR build failed"
    546   popd
    547   # TODO: how can we not build the dylibs?
    548   rm -f lib/*.dylib
    549   touch .already-built
    550 else
    551   already_built
    552 fi
    553 popd > /dev/null
    554 
     523# --------------------------------------------------------------
     524echo -e "Building NSPR..."
     525
     526LIB_VERSION="${NSPR_VERSION}"
     527LIB_ARCHIVE="nspr-$LIB_VERSION.tar.gz"
     528LIB_DIRECTORY="nspr-$LIB_VERSION"
     529LIB_URL="https://ftp.mozilla.org/pub/mozilla.org/nspr/releases/v$LIB_VERSION/src/"
     530
     531mkdir -p nspr
     532pushd nspr > /dev/null
     533
     534NSPR_DIR="$(pwd)"
     535
     536if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
     537then
     538  rm -f .already-built
     539  download_lib $LIB_URL $LIB_ARCHIVE
     540
     541  rm -rf $LIB_DIRECTORY bin include lib share
     542  tar -xf $LIB_ARCHIVE
     543  pushd $LIB_DIRECTORY/nspr
     544
     545  (CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" ./configure --prefix="$NSPR_DIR" && make ${JOBS} && make install) || die "NSPR build failed"
     546  popd
     547  # TODO: how can we not build the dylibs?
     548  rm -f lib/*.dylib
     549  touch .already-built
     550else
     551  already_built
     552fi
     553popd > /dev/null
     554
    555555# --------------------------------------------------------------------
    556556# The following libraries are shared on different OSes and may
    557557# be customzied, so we build and install them from bundled sources
    558558# --------------------------------------------------------------------
    559559echo -e "Building Spidermonkey..."
    560560
    561 LIB_VERSION="mozjs-24.2.0"
    562 LIB_ARCHIVE="$LIB_VERSION.tar.bz2"
    563 LIB_DIRECTORY="mozjs24"
     561LIB_VERSION="mozjs-24.2.0"
     562LIB_ARCHIVE="$LIB_VERSION.tar.bz2"
     563LIB_DIRECTORY="mozjs24"
    564564
    565565pushd ../source/spidermonkey/ > /dev/null
    566566
    567567if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]]
    568568then
    569569  INSTALL_DIR="$(pwd)"
    570   INCLUDE_DIR_DEBUG=$INSTALL_DIR/include-unix-debug
    571   INCLUDE_DIR_RELEASE=$INSTALL_DIR/include-unix-release
     570  INCLUDE_DIR_DEBUG=$INSTALL_DIR/include-unix-debug
     571  INCLUDE_DIR_RELEASE=$INSTALL_DIR/include-unix-release
    572572
    573573  rm -f .already-built
    574574  rm -f lib/*.a
    575   rm -rf $LIB_DIRECTORY $INCLUDE_DIR_DEBUG $INCLUDE_DIR_RELEASE
     575  rm -rf $LIB_DIRECTORY $INCLUDE_DIR_DEBUG $INCLUDE_DIR_RELEASE
    576576  tar -xf $LIB_ARCHIVE
    577   # rename the extracted directory to something shorter
    578   mv $LIB_VERSION $LIB_DIRECTORY 
     577  # rename the extracted directory to something shorter
     578  mv $LIB_VERSION $LIB_DIRECTORY
    579579  pushd $LIB_DIRECTORY/js/src
    580580
    581   NSPR_INCLUDES="`${NSPR_DIR}/bin/nspr-config --cflags`"
    582   NSPR_LIBS="`${NSPR_DIR}/bin/nspr-config --libs`"
    583 
    584581  # We want separate debug/release versions of the library, so change their install name in the Makefile
    585   perl -i.bak -pe 's/(^STATIC_LIBRARY_NAME\s+=).*/$1mozjs24-ps-debug/' Makefile.in
    586   perl -i.bak -pe 's/js_static/mozjs24-ps-debug/g' shell/Makefile.in
     582  perl -i.bak -pe 's/(^STATIC_LIBRARY_NAME\s+=).*/$1mozjs24-ps-debug/' Makefile.in
     583  perl -i.bak -pe 's/js_static/mozjs24-ps-debug/g' shell/Makefile.in
    587584
    588   CONF_OPTS="--prefix=${INSTALL_DIR} --enable-threadsafe --disable-tests --disable-shared-js" # --enable-trace-logging"
     585  CONF_OPTS="--target=$ARCH-apple-darwin --prefix=${INSTALL_DIR} --with-system-nspr --with-nspr-prefix=${NSPR_DIR} --with-system-zlib=${ZLIB_DIR} --enable-threadsafe --disable-tests --disable-shared-js" # --enable-trace-logging"
    589586  # Uncomment this line for 32-bit 10.5 cross compile:
    590587  #CONF_OPTS="$CONF_OPTS --target=i386-apple-darwin9.0.0"
    591588  if [[ $MIN_OSX_VERSION && ${MIN_OSX_VERSION-_} ]]; then
    then  
    595592    CONF_OPTS="$CONF_OPTS --with-macosx-sdk=$SYSROOT"
    596593  fi
    597594
     595  # apply patch to fix clang build on Mavericks (see https://bugzilla.mozilla.org/show_bug.cgi?id=917526)
     596  patch -p0 -d ../../ -i ../../../osx/patches/sm-mavericks-clang-fix.diff || die "Spidermonkey build failed"
     597
    598598  mkdir -p build-debug
    599599  pushd build-debug
    600   (CC="clang -arch $ARCH" CXX="clang++ -arch $ARCH" AR=ar CROSS_COMPILE=1 ../configure $CONF_OPTS --enable-debug --disable-optimize --enable-js-diagnostics --enable-gczeal --with-nspr-libs="$NSPR_LIBS" --with-nspr-cflags="$NSPR_INCLUDES" && make ${JOBS}) || die "Spidermonkey build failed"
    601   # js-config.h is different for debug and release builds, so we need different include directories for both
    602   mkdir -p $INCLUDE_DIR_DEBUG
    603   cp -R -L dist/include/* $INCLUDE_DIR_DEBUG/
    604   cp *.a $INSTALL_DIR/lib
     600  (CC="clang" CXX="clang++" AR=ar CROSS_COMPILE=1 ../configure $CONF_OPTS --enable-debug --disable-optimize --enable-js-diagnostics --enable-gczeal && make ${JOBS}) || die "Spidermonkey build failed"
     601  # js-config.h is different for debug and release builds, so we need different include directories for both
     602  mkdir -p $INCLUDE_DIR_DEBUG
     603  cp -R -L dist/include/* $INCLUDE_DIR_DEBUG/
     604  cp *.a $INSTALL_DIR/lib
    605605  popd
    606606  mv Makefile.in.bak Makefile.in
    607   mv shell/Makefile.in.bak shell/Makefile.in
     607  mv shell/Makefile.in.bak shell/Makefile.in
    608608
    609   perl -i.bak -pe 's/(^STATIC_LIBRARY_NAME\s+=).*/$1mozjs24-ps-release/' Makefile.in
    610   perl -i.bak -pe 's/js_static/mozjs24-ps-release/g' shell/Makefile.in
     609  perl -i.bak -pe 's/(^STATIC_LIBRARY_NAME\s+=).*/$1mozjs24-ps-release/' Makefile.in
     610  perl -i.bak -pe 's/js_static/mozjs24-ps-release/g' shell/Makefile.in
    611611  mkdir -p build-release
    612612  pushd build-release
    613   (CC="clang -arch $ARCH" CXX="clang++ -arch $ARCH" AR=ar CROSS_COMPILE=1 ../configure $CONF_OPTS --enable-optimize --with-nspr-libs="$NSPR_LIBS" --with-nspr-cflags="$NSPR_INCLUDES" && make ${JOBS}) || die "Spidermonkey build failed"
    614   # js-config.h is different for debug and release builds, so we need different include directories for both
    615   mkdir -p $INCLUDE_DIR_RELEASE
    616   cp -R -L dist/include/* $INCLUDE_DIR_RELEASE/
    617   cp *.a $INSTALL_DIR/lib
     613  (CC="clang" CXX="clang++" AR=ar CROSS_COMPILE=1 ../configure $CONF_OPTS --enable-optimize && make ${JOBS}) || die "Spidermonkey build failed"
     614  # js-config.h is different for debug and release builds, so we need different include directories for both
     615  mkdir -p $INCLUDE_DIR_RELEASE
     616  cp -R -L dist/include/* $INCLUDE_DIR_RELEASE/
     617  cp *.a $INSTALL_DIR/lib
    618618  popd
    619619  mv Makefile.in.bak Makefile.in
    620   mv shell/Makefile.in.bak shell/Makefile.in
     620  mv shell/Makefile.in.bak shell/Makefile.in
    621621 
    622622  popd
    623623  touch .already-built
  • new file libraries/osx/patches/sm-mavericks-clang-fix.diff

    diff --git a/libraries/osx/patches/sm-mavericks-clang-fix.diff b/libraries/osx/patches/sm-mavericks-clang-fix.diff
    new file mode 100644
    index 0000000..44b0d68
    - +  
     1--- js/src/configure    2013-12-11 14:23:20.000000000 -0800
     2+++ js/src/configure    2014-03-10 19:12:35.000000000 -0700
     3@@ -6229,7 +6229,12 @@
     4 if test "$GNU_CC"; then
     5     # Per bug 719659 comment 2, some of the headers on ancient build machines
     6     # may require gnu89 inline semantics.  But otherwise, we use C99.
     7-    CFLAGS="$CFLAGS -std=gnu99 -fgnu89-inline"
     8+    # But on OS X we just use C99 plus GNU extensions, in order to fix
     9+    # bug 917526.
     10+    CFLAGS="$CFLAGS -std=gnu99"
     11+    if test "${OS_ARCH}" != Darwin; then
     12+        CFLAGS="$CFLAGS -fgnu89-inline"
     13+    fi
     14     MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(notdir $@) -o $@'
     15     MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(notdir $@) -o $@'
     16     DSO_LDOPTS='-shared'
     17 No newline at end of file