[SM52 1/2] Upgrade Spidermonkey build system and binaries to 52.9.1

Of note is the change to static linking on *nix (MacOS already used it).
The logic is that we can only use one single version of SM, so that
advantage of dynamic linking is lost regardless. We might also see
performance gains in the future with LTO enabled. It is also slightly
easier to distribute the program as a result. Expect a negligible size
increase in the binary size (offset somewhat by no longer needing to
distribute .so files). Finally, it streamlines the build script.

Also noteworthy in this commit:
- The MacOS build script is folded back into the general build script.
- the perl/sed command is replaced by patching the configuration file,
which at least warns if it starts failing in the future.

Binaries for windows provided by @Itms
The bulk of the patching was also done by @Itms.

Tested by: Stan, Freagarach
Refs #4893

Differential Revision: https://code.wildfiregames.com/D3094
This was SVN commit r24202.
This commit is contained in:
wraitii 2020-11-18 14:34:17 +00:00
parent 935af751b9
commit 6bb08fb424
5 changed files with 23 additions and 94 deletions

View File

@ -533,9 +533,9 @@ extern_lib_defs = {
},
spidermonkey = {
compile_settings = function()
if _OPTIONS["with-system-mozjs45"] then
if _OPTIONS["with-system-mozjs52"] then
if not _OPTIONS["android"] then
pkgconfig.add_includes("mozjs-45")
pkgconfig.add_includes("mozjs-52")
end
else
if os.istarget("windows") then
@ -553,21 +553,21 @@ extern_lib_defs = {
end
end,
link_settings = function()
if _OPTIONS["with-system-mozjs45"] then
if _OPTIONS["with-system-mozjs52"] then
if _OPTIONS["android"] then
links { "mozjs-45" }
links { "mozjs-52" }
else
pkgconfig.add_links("mozjs-45")
pkgconfig.add_links("mozjs-52")
end
else
filter { "Debug", "action:vs2015" }
links { "mozjs45-ps-debug-vc140" }
links { "mozjs52-ps-debug-vc140" }
filter { "Release", "action:vs2015" }
links { "mozjs45-ps-release-vc140" }
links { "mozjs52-ps-release-vc140" }
filter { "Debug", "action:not vs*" }
links { "mozjs45-ps-debug" }
links { "mozjs52-ps-debug" }
filter { "Release", "action:not vs*" }
links { "mozjs45-ps-release" }
links { "mozjs52-ps-release" }
filter { }
add_source_lib_paths("spidermonkey")
end

View File

@ -6,7 +6,7 @@ newoption { trigger = "icc", description = "Use Intel C++ Compiler (Linux only;
newoption { trigger = "jenkins-tests", description = "Configure CxxTest to use the XmlPrinter runner which produces Jenkins-compatible output" }
newoption { trigger = "minimal-flags", description = "Only set compiler/linker flags that are really needed. Has no effect on Windows builds" }
newoption { trigger = "outpath", description = "Location for generated project files" }
newoption { trigger = "with-system-mozjs45", description = "Search standard paths for libmozjs45, instead of using bundled copy" }
newoption { trigger = "with-system-mozjs52", description = "Search standard paths for libmozjs52, instead of using bundled copy" }
newoption { trigger = "with-system-nvtt", description = "Search standard paths for nvidia-texture-tools library, instead of using bundled copy" }
newoption { trigger = "without-audio", description = "Disable use of OpenAL/Ogg/Vorbis APIs" }
newoption { trigger = "without-lobby", description = "Disable the use of gloox and the multiplayer lobby" }

View File

@ -48,12 +48,11 @@ MINIUPNPC_VERSION="miniupnpc-2.0.20180222"
SODIUM_VERSION="libsodium-1.0.18"
# --------------------------------------------------------------
# Bundled with the game:
# * SpiderMonkey 45
# * SpiderMonkey
# * NVTT
# * FCollada
# --------------------------------------------------------------
# We use suffixes here in order to force rebuilding when patching these libs
SPIDERMONKEY_VERSION="mozjs-45.0.2+wildfiregames.2"
NVTT_VERSION="nvtt-2.1.1+wildfiregames.1"
FCOLLADA_VERSION="fcollada-3.05+wildfiregames.1"
# --------------------------------------------------------------
@ -911,88 +910,16 @@ popd > /dev/null
# be customized, so we build and install them from bundled sources
# --------------------------------------------------------------------
# SpiderMonkey - bundled, no download
echo -e "Building SpiderMonkey..."
LIB_VERSION="${SPIDERMONKEY_VERSION}"
LIB_DIRECTORY="mozjs-45.0.2"
LIB_ARCHIVE="$LIB_DIRECTORY.tar.bz2"
pushd ../source/spidermonkey/ > /dev/null
if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ "$(<.already-built)" != "$LIB_VERSION" ]]
if [[ "$force_rebuild" = "true" ]]
then
INSTALL_DIR="$(pwd)"
INCLUDE_DIR_DEBUG=$INSTALL_DIR/include-unix-debug
INCLUDE_DIR_RELEASE=$INSTALL_DIR/include-unix-release
rm -f .already-built
rm -f lib/*.a
rm -rf $LIB_DIRECTORY $INCLUDE_DIR_DEBUG $INCLUDE_DIR_RELEASE
tar -xf $LIB_ARCHIVE
# Apply patches
pushd $LIB_DIRECTORY
. ../patch.sh
popd
pushd $LIB_DIRECTORY/js/src
CONF_OPTS="--target=$ARCH-apple-darwin
--prefix=${INSTALL_DIR}
--enable-posix-nspr-emulation
--with-system-zlib=${ZLIB_DIR}
--disable-tests
--disable-shared-js
--disable-jemalloc
--without-intl-api"
# Change the default location where the tracelogger should store its output, which is /tmp/ on OSX.
TLCXXFLAGS='-DTRACE_LOG_DIR="\"../../source/tools/tracelogger/\""'
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
# We want separate debug/release versions of the library, so change their install name in the Makefile
perl -i.bak -pe 's/(^STATIC_LIBRARY_NAME\s+=).*/$1'\''mozjs45-ps-debug'\''/' moz.build
mkdir -p build-debug
pushd build-debug
(CC="clang" CXX="clang++" CXXFLAGS="${TLCXXFLAGS}" AR=ar CROSS_COMPILE=1 \
../configure $CONF_OPTS \
--enable-debug \
--disable-optimize \
--enable-js-diagnostics \
--enable-gczeal \
&& make ${JOBS}) || die "SpiderMonkey build failed"
# js-config.h is different for debug and release builds, so we need different include directories for both
mkdir -p $INCLUDE_DIR_DEBUG
cp -R -L dist/include/* $INCLUDE_DIR_DEBUG/
cp dist/sdk/lib/*.a $INSTALL_DIR/lib
cp js/src/*.a $INSTALL_DIR/lib
popd
mv moz.build.bak moz.build
perl -i.bak -pe 's/(^STATIC_LIBRARY_NAME\s+=).*/$1'\''mozjs45-ps-release'\''/' moz.build
mkdir -p build-release
pushd build-release
(CC="clang" CXX="clang++" CXXFLAGS="${TLCXXFLAGS}" AR=ar CROSS_COMPILE=1 \
../configure $CONF_OPTS \
--enable-optimize \
&& make ${JOBS}) || die "SpiderMonkey build failed"
# js-config.h is different for debug and release builds, so we need different include directories for both
mkdir -p $INCLUDE_DIR_RELEASE
cp -R -L dist/include/* $INCLUDE_DIR_RELEASE/
cp dist/sdk/lib/*.a $INSTALL_DIR/lib
cp js/src/*.a $INSTALL_DIR/lib
popd
mv moz.build.bak moz.build
popd
echo "$LIB_VERSION" > .already-built
else
already_built
fi
# Use the regular build script for SM.
JOBS="$JOBS" ZLIB_DIR="$ZLIB_DIR" ./build.sh
popd > /dev/null
# --------------------------------------------------------------

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2016 Wildfire Games.
/* Copyright (C) 2020 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -71,7 +71,7 @@
# pragma GCC diagnostic pop
#endif
#if MOZJS_MAJOR_VERSION != 45
#if MOZJS_MAJOR_VERSION != 52
#error Your compiler is trying to use an incorrect major version of the \
SpiderMonkey library. The only version that works is the one in the \
libraries/spidermonkey/ directory, and it will not work with a typical \
@ -79,7 +79,7 @@ system-installed version. Make sure you have got all the right files and \
include paths.
#endif
#if MOZJS_MINOR_VERSION != 0
#if MOZJS_MINOR_VERSION != 9
#error Your compiler is trying to use an untested minor version of the \
SpiderMonkey library. If you are a package maintainer, please make sure \
to check very carefully that this version does not change the behaviour \

View File

@ -9,13 +9,15 @@
# The last tested version of the tool is 1c67e97e794b5039d0cae95f72ea0c76e4aa4696,
# it can be used if more recent versions cause trouble.
export TLDIR="$(dirname $(realpath $0))"
# Use semicolons to separate values on Windows.
# If that produces bogus output, you can try with commas instead.
if [ "${OS}" = "Windows_NT" ]
then
export TLLOG="Defaults;IonCompiler"
export TLLOG="Default;IonCompiler"
export TLOPTIONS="EnableMainThread;EnableOffThread;EnableGraph"
else
export TLLOG=Defaults,IonCompiler
export TLLOG=Default,IonCompiler
export TLOPTIONS=EnableMainThread,EnableOffThread,EnableGraph
fi