Changeset View
Standalone View
libraries/source/spidermonkey/build.sh
#!/bin/sh | #!/bin/sh | |||||||||||
Freagarach: For the `[[` to work you need bash, so preferably work around the `[[` and use `sh`. | ||||||||||||
# This script is called by update-workspaces.sh / build-osx-libraries.sh | ||||||||||||
set -e | set -e | |||||||||||
# This should match the version in config/milestone.txt | ||||||||||||
FOLDER="mozjs-52.9.1pre1" | ||||||||||||
# If same-version changes are needed, increment this. | ||||||||||||
LIB_VERSION="52.9.1pre1+0" | ||||||||||||
LIB_NAME="mozjs52-ps" | ||||||||||||
# Since this script is called by update-workspaces.sh, we want to quickly | # Since this script is called by update-workspaces.sh, we want to quickly | |||||||||||
# avoid doing any work if SpiderMonkey is already built and up-to-date. | # avoid doing any work if SpiderMonkey is already built and up-to-date. | |||||||||||
# Running SM's Makefile is a bit slow and noisy, so instead we'll make a | # Running SM's Makefile is a bit slow and noisy, so instead we'll make a | |||||||||||
# special file and only rebuild if it's older than SVN. | # special file and only rebuild if the build.sh version differs. | |||||||||||
# README.txt should be updated whenever we update SM, so use that as | if [ -e .already-built ] && [ "$(cat .already-built)" = "${LIB_VERSION}" ] | |||||||||||
Not Done Inline Actions./build.sh: 16: [: unexpected operator Freagarach: `./build.sh: 16: [: unexpected operator` | ||||||||||||
# a time comparison. | ||||||||||||
if [ -e .already-built -a .already-built -nt README.txt ] | ||||||||||||
then | then | |||||||||||
echo "SpiderMonkey is already up to date" | echo "SpiderMonkey is already up to date" | |||||||||||
exit | exit | |||||||||||
fi | fi | |||||||||||
echo "Building SpiderMonkey..." | echo "Building SpiderMonkey..." | |||||||||||
echo | echo | |||||||||||
# Use Mozilla make on Windows | # Use Mozilla make on Windows | |||||||||||
if [ "${OS}" = "Windows_NT" ] | if [ "${OS}" = "Windows_NT" ] | |||||||||||
then | then | |||||||||||
MAKE="mozmake" | MAKE="mozmake" | |||||||||||
else | else | |||||||||||
MAKE=${MAKE:="make"} | MAKE=${MAKE:="make"} | |||||||||||
fi | fi | |||||||||||
MAKE_OPTS="${JOBS}" | MAKE_OPTS="${JOBS}" | |||||||||||
# jemalloc is outdated on SM45, do not use it | # Standalone SpiderMonkey can not use jemalloc (see https://bugzilla.mozilla.org/show_bug.cgi?id=1465038) | |||||||||||
CONF_OPTS="--disable-tests --disable-jemalloc --enable-shared-js --without-intl-api" | CONF_OPTS="--disable-tests | |||||||||||
--disable-jemalloc | ||||||||||||
# Bug 1269319 | --disable-js-shell | |||||||||||
# When compiled with GCC 6 (or later), SpiderMonkey 45 (and versions up to 49) is | --without-intl-api | |||||||||||
# subject to segfaults. Disabling a few optimizations fixes that. | --enable-shared-js" # We're linking statically but JS has quirks with static-only compilation. | |||||||||||
# See also #4053 | ||||||||||||
if [ "${OS}" != "Windows_NT" ] | ||||||||||||
then | ||||||||||||
if [ "`${CXX:=g++} -dumpversion | cut -f1 -d.`" -ge "6" ] | ||||||||||||
then | ||||||||||||
CXXFLAGS="${CXXFLAGS} -fno-schedule-insns2 -fno-delete-null-pointer-checks" | ||||||||||||
fi | ||||||||||||
fi | ||||||||||||
# Change the default location where the tracelogger should store its output. | ||||||||||||
# The default location is . on Windows and /tmp/ on *nix. | ||||||||||||
TLCXXFLAGS='-DTRACE_LOG_DIR="\"../../source/tools/tracelogger/\""' | ||||||||||||
# NSPR is needed on Windows for POSIX emulation. | # NSPR is needed on Windows for POSIX emulation. | |||||||||||
# If you want to build on Windows, check README.txt and edit the absolute paths | # If you want to build on Windows, check README.txt and edit the absolute paths | |||||||||||
# to match your environment. | # to match your environment. | |||||||||||
if [ "${OS}" = "Windows_NT" ] | if [ "${OS}" = "Windows_NT" ] | |||||||||||
then | then | |||||||||||
NSPR_INCLUDES="-ID:/nspr-4.12/nspr/dist/include/nspr" | CONF_OPTS="${CONF_OPTS} --with-nspr-prefix="D:/nspr-4.21/nspr/"" | |||||||||||
Not Done Inline ActionsExtra "? Stan: Extra "? | ||||||||||||
NSPR_LIBS=" \ | ||||||||||||
D:/nspr-4.12/nspr/dist/lib/nspr4 \ | ||||||||||||
D:/nspr-4.12/nspr/dist/lib/plds4 \ | ||||||||||||
D:/nspr-4.12/nspr/dist/lib/plc4" | ||||||||||||
else | else | |||||||||||
CONF_OPTS="${CONF_OPTS} --enable-posix-nspr-emulation" | CONF_OPTS="${CONF_OPTS} --enable-posix-nspr-emulation" | |||||||||||
fi | fi | |||||||||||
if [ "`uname -s`" = "Darwin" ] | ||||||||||||
then | ||||||||||||
Not Done Inline Actions./build.sh: 52: [: unexpected operator Freagarach: `./build.sh: 52: [: unexpected operator` | ||||||||||||
# Link to custom-built zlib | ||||||||||||
CONF_OPTS="${CONF_OPTS} --with-system-zlib=${ZLIB_DIR}" | ||||||||||||
# Specify target versions and SDK | ||||||||||||
if [ "${MIN_OSX_VERSION}" ] && [ "${MIN_OSX_VERSION-_}" ]; then | ||||||||||||
CONF_OPTS="${CONF_OPTS} --enable-macos-target=$MIN_OSX_VERSION" | ||||||||||||
fi | ||||||||||||
if [ "${SYSROOT}" ] && [ "${SYSROOT-_}" ]; then | ||||||||||||
CONF_OPTS="${CONF_OPTS} --with-macosx-sdk=${SYSROOT}" | ||||||||||||
fi | ||||||||||||
fi | ||||||||||||
# If Valgrind looks like it's installed, then set up SM to support it | # If Valgrind looks like it's installed, then set up SM to support it | |||||||||||
# (else the JITs will interact poorly with it) | # (else the JITs will interact poorly with it) | |||||||||||
if [ -e /usr/include/valgrind/valgrind.h ] | if [ -e /usr/include/valgrind/valgrind.h ] | |||||||||||
then | then | |||||||||||
CONF_OPTS="${CONF_OPTS} --enable-valgrind" | CONF_OPTS="${CONF_OPTS} --enable-valgrind" | |||||||||||
fi | fi | |||||||||||
# We need to be able to override CHOST in case it is 32bit userland on 64bit kernel | # We need to be able to override CHOST in case it is 32bit userland on 64bit kernel | |||||||||||
CONF_OPTS="${CONF_OPTS} \ | CONF_OPTS="${CONF_OPTS} \ | |||||||||||
${CBUILD:+--build=${CBUILD}} \ | ${CBUILD:+--build=${CBUILD}} \ | |||||||||||
${CHOST:+--host=${CHOST}} \ | ${CHOST:+--host=${CHOST}} \ | |||||||||||
${CTARGET:+--target=${CTARGET}}" | ${CTARGET:+--target=${CTARGET}}" | |||||||||||
echo "SpiderMonkey build options: ${CONF_OPTS}" | echo "SpiderMonkey build options: ${CONF_OPTS}" | |||||||||||
echo ${CONF_OPTS} | ||||||||||||
FOLDER=mozjs-45.0.2 | ||||||||||||
# It can occasionally be useful to not rebuild everything, but don't do this by default. | ||||||||||||
REBUILD=true | ||||||||||||
if $REBUILD = true; | ||||||||||||
then | ||||||||||||
# Delete the existing directory to avoid conflicts and extract the tarball | # Delete the existing directory to avoid conflicts and extract the tarball | |||||||||||
rm -rf $FOLDER | rm -rf "$FOLDER" | |||||||||||
Not Done Inline ActionsWhat it echoes. Freagarach: What it echoes. | ||||||||||||
tar xjf mozjs-45.0.2.tar.bz2 | if [ ! -e "${FOLDER}.tar.bz2" ]; | |||||||||||
then | ||||||||||||
# The tarball is committed to svn, but it's useful to let jenkins download it (when testing upgrade scripts). | ||||||||||||
comm="$(command -v wget && echo wget || echo "curl -L")" | ||||||||||||
Not Done Inline ActionsOne could also use wget since curl is not always present in light images? Not sure what pro's and cons of curl vs wget are. Freagarach: One could also use wget since curl is not always present in light images? Not sure what pro's… | ||||||||||||
Not Done Inline ActionsNo wget on mac IIRC. Stan: No wget on mac IIRC. | ||||||||||||
Not Done Inline ActionsMy linux doesn't like this, it complains that is misses a fi. Also the link is dead ;( Freagarach: My linux doesn't like this, it complains that is misses a `fi`. Also the link is dead ;( | ||||||||||||
$comm "https://github.com/wraitii/spidermonkey-tarballs/releases/download/v52.9.1/${FOLDER}.tar.bz2" -o "${FOLDER}.tar.bz2" | ||||||||||||
Not Done Inline Actionswget -o does not do what you'd expect ^^' Freagarach: wget -o does not do what you'd expect ^^' | ||||||||||||
Not Done Inline Actions
? Freagarach: ? | ||||||||||||
Not Done Inline ActionsRemove this ? Stan: Remove this ? | ||||||||||||
fi | ||||||||||||
tar xjf "${FOLDER}.tar.bz2" | ||||||||||||
# Clean up header files that may be left over by earlier versions of SpiderMonkey | # Clean up header files that may be left over by earlier versions of SpiderMonkey | |||||||||||
rm -rf include-unix-* | rm -rf include-unix-debug | |||||||||||
rm -rf include-unix-release | ||||||||||||
Not Done Inline ActionsWhy do you need to be specific? Stan: Why do you need to be specific? | ||||||||||||
Done Inline Actionsbecause I've set it up locally to have include-unix-debug-sm45/52/60/68/78 folders, and less precise would delete everything. wraitii: because I've set it up locally to have include-unix-debug-sm45/52/60/68/78 folders, and less… | ||||||||||||
Not Done Inline ActionsProbably something that shouldn't be commited? Stan: Probably something that shouldn't be commited? | ||||||||||||
cd $FOLDER | ||||||||||||
# Apply patches | # Apply patches | |||||||||||
cd "$FOLDER" | ||||||||||||
Not Done Inline ActionsUnrelated to comment. Stan: Unrelated to comment. | ||||||||||||
. ../patch.sh | . ../patch.sh | |||||||||||
# Prevent complaining that configure is outdated. | ||||||||||||
touch ./js/src/configure | ||||||||||||
else | ||||||||||||
cd "$FOLDER" | ||||||||||||
fi | ||||||||||||
cd js/src | ||||||||||||
# Clean up data generated by previous builds that could cause problems | ||||||||||||
rm -rf build-debug | ||||||||||||
rm -rf build-release | ||||||||||||
# We want separate debug/release versions of the library, so we have to change | ||||||||||||
# the LIBRARY_NAME for each build. | ||||||||||||
# (We use perl instead of sed so that it works with MozillaBuild on Windows, | ||||||||||||
# which has an ancient sed.) | ||||||||||||
perl -i.bak -pe 's/(SHARED_LIBRARY_NAME\s+=).*/$1 '\''mozjs45-ps-debug'\''/' moz.build | ||||||||||||
mkdir -p build-debug | mkdir -p build-debug | |||||||||||
Not Done Inline Actions
Freagarach: | ||||||||||||
cd build-debug | cd build-debug | |||||||||||
if [ "${OS}" = "Windows_NT" ] | # SM build scripts check for autoconf, but it isn't actually needed, so just pass something. | |||||||||||
then | CXXFLAGS="${CXXFLAGS}" ../js/src/configure AUTOCONF="false" ${CONF_OPTS} \ | |||||||||||
CXXFLAGS="${CXXFLAGS} ${TLCXXFLAGS}" ../configure ${CONF_OPTS} \ | ||||||||||||
--with-nspr-cflags="${NSPR_INCLUDES}" --with-nspr-libs="${NSPR_LIBS}" \ | ||||||||||||
--enable-debug \ | --enable-debug \ | |||||||||||
--disable-optimize \ | --disable-optimize \ | |||||||||||
--enable-js-diagnostics \ | ||||||||||||
--enable-gczeal | --enable-gczeal | |||||||||||
else | ||||||||||||
CXXFLAGS="${CXXFLAGS} ${TLCXXFLAGS}" ../configure ${CONF_OPTS} \ | ||||||||||||
--enable-debug \ | ||||||||||||
--disable-optimize \ | ||||||||||||
--enable-js-diagnostics \ | ||||||||||||
--enable-gczeal | ||||||||||||
fi | ||||||||||||
${MAKE} ${MAKE_OPTS} | ${MAKE} ${MAKE_OPTS} | |||||||||||
cd .. | cd .. | |||||||||||
perl -i.bak -pe 's/(SHARED_LIBRARY_NAME\s+=).*/$1 '\''mozjs45-ps-release'\''/' moz.build | ||||||||||||
mkdir -p build-release | mkdir -p build-release | |||||||||||
cd build-release | cd build-release | |||||||||||
if [ "${OS}" = "Windows_NT" ] | CXXFLAGS="${CXXFLAGS}" ../js/src/configure AUTOCONF="false" ${CONF_OPTS} \ | |||||||||||
then | --enable-optimize | |||||||||||
CXXFLAGS="${CXXFLAGS} ${TLCXXFLAGS}" ../configure ${CONF_OPTS} \ | ||||||||||||
--with-nspr-cflags="${NSPR_INCLUDES}" --with-nspr-libs="${NSPR_LIBS}" \ | ||||||||||||
--enable-optimize \ | ||||||||||||
#--enable-gczeal \ | ||||||||||||
#--enable-debug-symbols | ||||||||||||
else | ||||||||||||
CXXFLAGS="${CXXFLAGS} ${TLCXXFLAGS}" ../configure ${CONF_OPTS} \ | ||||||||||||
--enable-optimize \ | ||||||||||||
#--enable-gczeal \ | ||||||||||||
#--enable-debug-symbols | ||||||||||||
fi | ||||||||||||
${MAKE} ${MAKE_OPTS} | ${MAKE} ${MAKE_OPTS} | |||||||||||
cd .. | cd ../ | |||||||||||
cd ../../.. | cd ../ | |||||||||||
Not Done Inline ActionsInline? Stan: Inline? | ||||||||||||
Not Done Inline Actions? Stan: ? | ||||||||||||
Done Inline ActionsI didn't inline these two because:
wraitii: I didn't inline these two because:
- that makes the debug symmetrical with the release (and… | ||||||||||||
if [ "${OS}" = "Windows_NT" ] | if [ "${OS}" = "Windows_NT" ] | |||||||||||
then | then | |||||||||||
INCLUDE_DIR_DEBUG=include-win32-debug | INCLUDE_DIR_DEBUG=include-win32-debug | |||||||||||
INCLUDE_DIR_RELEASE=include-win32-release | INCLUDE_DIR_RELEASE=include-win32-release | |||||||||||
DLL_SRC_SUFFIX=.dll | ||||||||||||
DLL_DST_SUFFIX=.dll | ||||||||||||
Not Done Inline ActionsWe still use those on Windows. Stan: We still use those on Windows. | ||||||||||||
Not Done Inline ActionsDo you still plan to statically link it for this version? If not you should continue to copy the dlls. Stan: Do you still plan to statically link it for this version? If not you should continue to copy… | ||||||||||||
Done Inline ActionsNot the latest version, I'm linking dynamically. wraitii: Not the latest version, I'm linking dynamically. | ||||||||||||
Done Inline ActionsOkay, cause you said it was too big :) . Stan: Okay, cause you said it was too big :) . | ||||||||||||
LIB_PREFIX= | LIB_PREFIX= | |||||||||||
LIB_SRC_SUFFIX=.lib | LIB_SUFFIX=.lib | |||||||||||
LIB_DST_SUFFIX=.lib | ||||||||||||
else | else | |||||||||||
INCLUDE_DIR_DEBUG=include-unix-debug | INCLUDE_DIR_DEBUG=include-unix-debug | |||||||||||
INCLUDE_DIR_RELEASE=include-unix-release | INCLUDE_DIR_RELEASE=include-unix-release | |||||||||||
DLL_SRC_SUFFIX=.so | ||||||||||||
DLL_DST_SUFFIX=.so | ||||||||||||
LIB_PREFIX=lib | LIB_PREFIX=lib | |||||||||||
LIB_SRC_SUFFIX=.so | LIB_SUFFIX=.a | |||||||||||
LIB_DST_SUFFIX=.so | ||||||||||||
if [ "`uname -s`" = "OpenBSD" ] | ||||||||||||
then | ||||||||||||
DLL_SRC_SUFFIX=.so.1.0 | ||||||||||||
DLL_DST_SUFFIX=.so.1.0 | ||||||||||||
LIB_SRC_SUFFIX=.so.1.0 | ||||||||||||
LIB_DST_SUFFIX=:so.1.0 | ||||||||||||
fi | ||||||||||||
fi | fi | |||||||||||
if [ "${OS}" = "Windows_NT" ] | if [ "${OS}" = "Windows_NT" ] | |||||||||||
then | then | |||||||||||
# Bug #776126 | # Bug #776126 | |||||||||||
# SpiderMonkey uses a tweaked zlib when building, and it wrongly copies its own files to include dirs | # SpiderMonkey uses a tweaked zlib when building, and it wrongly copies its own files to include dirs | |||||||||||
# afterwards, so we have to remove them to not have them conflicting with the regular zlib | # afterwards, so we have to remove them to not have them conflicting with the regular zlib | |||||||||||
pushd ${FOLDER}/js/src/build-release/dist/include | pushd "${FOLDER}/build-release/dist/include" | |||||||||||
rm mozzconf.h zconf.h zlib.h | rm mozzconf.h zconf.h zlib.h | |||||||||||
popd | popd | |||||||||||
pushd ${FOLDER}/js/src/build-debug/dist/include | pushd "${FOLDER}/build-debug/dist/include" | |||||||||||
rm mozzconf.h zconf.h zlib.h | rm mozzconf.h zconf.h zlib.h | |||||||||||
popd | popd | |||||||||||
fi | fi | |||||||||||
# Copy files into the necessary locations for building and running the game | # Copy files into the necessary locations for building and running the game | |||||||||||
# js-config.h is different for debug and release builds, so we need different include directories for both | # js-config.h is different for debug and release builds, so we need different include directories for both | |||||||||||
mkdir -p ${INCLUDE_DIR_DEBUG} | mkdir -p "${INCLUDE_DIR_DEBUG}" | |||||||||||
mkdir -p ${INCLUDE_DIR_RELEASE} | mkdir -p "${INCLUDE_DIR_RELEASE}" | |||||||||||
cp -R -L ${FOLDER}/js/src/build-release/dist/include/* ${INCLUDE_DIR_RELEASE}/ | cp -R -L "${FOLDER}"/build-release/dist/include/* "${INCLUDE_DIR_RELEASE}/" | |||||||||||
cp -R -L ${FOLDER}/js/src/build-debug/dist/include/* ${INCLUDE_DIR_DEBUG}/ | cp -R -L "${FOLDER}"/build-debug/dist/include/* "${INCLUDE_DIR_DEBUG}/" | |||||||||||
Not Done Inline Actions
Something like this should work. Freagarach: Something like this should work. | ||||||||||||
mkdir -p lib/ | mkdir -p lib/ | |||||||||||
cp -L ${FOLDER}/js/src/build-debug/dist/sdk/lib/${LIB_PREFIX}mozjs45-ps-debug${LIB_SRC_SUFFIX} lib/${LIB_PREFIX}mozjs45-ps-debug${LIB_DST_SUFFIX} | cp -L "${FOLDER}/build-debug/js/src/${LIB_PREFIX}js_static${LIB_SUFFIX}" "lib/${LIB_PREFIX}${LIB_NAME}-debug${LIB_SUFFIX}" | |||||||||||
cp -L ${FOLDER}/js/src/build-release/dist/sdk/lib/${LIB_PREFIX}mozjs45-ps-release${LIB_SRC_SUFFIX} lib/${LIB_PREFIX}mozjs45-ps-release${LIB_DST_SUFFIX} | cp -L "${FOLDER}/build-release/js/src/${LIB_PREFIX}js_static${LIB_SUFFIX}" "lib/${LIB_PREFIX}${LIB_NAME}-release${LIB_SUFFIX}" | |||||||||||
Not Done Inline ActionsWhat's this for? Stan: What's this for? | ||||||||||||
cp -L ${FOLDER}/js/src/build-debug/dist/bin/${LIB_PREFIX}mozjs45-ps-debug${DLL_SRC_SUFFIX} ../../../binaries/system/${LIB_PREFIX}mozjs45-ps-debug${DLL_DST_SUFFIX} | ||||||||||||
cp -L ${FOLDER}/js/src/build-release/dist/bin/${LIB_PREFIX}mozjs45-ps-release${DLL_SRC_SUFFIX} ../../../binaries/system/${LIB_PREFIX}mozjs45-ps-release${DLL_DST_SUFFIX} | ||||||||||||
# On Windows, also copy debugging symbols files | # On Windows, also copy debugging symbols files | |||||||||||
if [ "${OS}" = "Windows_NT" ] | if [ "${OS}" = "Windows_NT" ] | |||||||||||
then | then | |||||||||||
cp -L ${FOLDER}/js/src/build-debug/js/src/${LIB_PREFIX}mozjs45-ps-debug-vc140.pdb ../../../binaries/system/${LIB_PREFIX}mozjs45-ps-debug-vc140.pdb | cp -L "${FOLDER}/js/src/build-debug/js/src/${LIB_PREFIX}mozjs-${VERSION}.pdb" "binaries/system/${LIB_PREFIX}${LIB_NAME}-debug.pdb" | |||||||||||
cp -L ${FOLDER}/js/src/build-release/js/src/${LIB_PREFIX}mozjs45-ps-release-vc140.pdb ../../../binaries/system/${LIB_PREFIX}mozjs45-ps-release-vc140.pdb | cp -L "${FOLDER}/js/src/build-release/js/src/${LIB_PREFIX}mozjs-${VERSION}.pdb" "binaries/system/${LIB_PREFIX}${LIB_NAME}-release.pdb" | |||||||||||
fi | fi | |||||||||||
# Flag that it's already been built successfully so we can skip it next time | # Flag that it's already been built successfully so we can skip it next time | |||||||||||
touch .already-built | echo "${LIB_VERSION}" > .already-built |
For the [[ to work you need bash, so preferably work around the [[ and use sh.