From 2e32636a538ebbe9ea50dfc55fa1f0849b0814ab Mon Sep 17 00:00:00 2001 From: Itms Date: Sun, 13 Oct 2024 14:25:24 +0200 Subject: [PATCH] Use Mozilla's mach to build SpiderMonkey This removes the need for many customizations in the build script. --- .gitignore | 1 + .../dockerfiles/bullseye-base.Dockerfile | 1 + .../dockerfiles/buster-base.Dockerfile | 1 + libraries/source/spidermonkey/build.sh | 56 +++++-------------- libraries/source/spidermonkey/mozconfig | 7 +++ 5 files changed, 24 insertions(+), 42 deletions(-) create mode 100644 libraries/source/spidermonkey/mozconfig diff --git a/.gitignore b/.gitignore index 19062a0d16..3654cea35d 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ libraries/source/fcollada/* libraries/source/nvtt/* libraries/source/premake-core/* libraries/source/spidermonkey/* +!libraries/source/spidermonkey/mozconfig libraries/source/spirv-reflect/* !libraries/source/**/build.sh !libraries/source/**/patches/ diff --git a/build/jenkins/dockerfiles/bullseye-base.Dockerfile b/build/jenkins/dockerfiles/bullseye-base.Dockerfile index 95d254c880..b24d2544ae 100644 --- a/build/jenkins/dockerfiles/bullseye-base.Dockerfile +++ b/build/jenkins/dockerfiles/bullseye-base.Dockerfile @@ -27,6 +27,7 @@ RUN apt-get -qqy update && apt-get install -qqy --no-install-recommends \ libvorbis-dev \ libwxgtk3.0-gtk3-dev \ libxml2-dev \ + llvm \ make \ m4 \ patch \ diff --git a/build/jenkins/dockerfiles/buster-base.Dockerfile b/build/jenkins/dockerfiles/buster-base.Dockerfile index 757a664950..08d15ab021 100644 --- a/build/jenkins/dockerfiles/buster-base.Dockerfile +++ b/build/jenkins/dockerfiles/buster-base.Dockerfile @@ -27,6 +27,7 @@ RUN apt-get -qqy update && apt-get install -qqy --no-install-recommends \ libvorbis-dev \ libwxgtk3.0-dev \ libxml2-dev \ + llvm \ make \ m4 \ patch \ diff --git a/libraries/source/spidermonkey/build.sh b/libraries/source/spidermonkey/build.sh index f35036c7a2..1a70f7c6b3 100755 --- a/libraries/source/spidermonkey/build.sh +++ b/libraries/source/spidermonkey/build.sh @@ -50,15 +50,6 @@ tar xfJ "${FOLDER}.tar.xz" # user-installed python packages. PYTHONNOUSERSITE=true - # Use Mozilla make on Windows - if [ "${OS}" = "Windows_NT" ]; then - MAKE="mozmake" - else - MAKE=${MAKE:="make"} - fi - - MAKE_OPTS="${JOBS}" - # Standalone SpiderMonkey can not use jemalloc (see https://bugzilla.mozilla.org/show_bug.cgi?id=1465038) # Jitspew doesn't compile on VS17 in the zydis disassembler - since we don't use it, deactivate it. # Trace-logging doesn't compile for now. @@ -101,15 +92,6 @@ tar xfJ "${FOLDER}.tar.xz" fi fi - LLVM_OBJDUMP=${LLVM_OBJDUMP:=$(command -v llvm-objdump || command -v objdump)} - - # Quick sanity check to print explicit error messages - # (Don't run this on windows as it would likely fail spuriously) - if [ "${OS}" != "Windows_NT" ]; then - [ -n "$(command -v rustc)" ] || (echo "Error: rustc is not available. Install the rust toolchain (rust + cargo) before proceeding." && exit 1) - [ -n "${LLVM_OBJDUMP}" ] || (echo "Error: LLVM objdump is not available. Install it (likely via LLVM-clang) before proceeding." && exit 1) - fi - # If Valgrind looks like it's installed, then set up SM to support it # (else the JITs will interact poorly with it) if [ -e /usr/include/valgrind/valgrind.h ]; then @@ -122,35 +104,25 @@ tar xfJ "${FOLDER}.tar.xz" ${CHOST:+--host=${CHOST}} \ ${CTARGET:+--target=${CTARGET}}" - echo "SpiderMonkey build options: ${CONF_OPTS}" - # Build + ./mach create-mach-environment + # Debug (broken on FreeBSD) if [ "${OS}" != "FreeBSD" ]; then - mkdir -p build-debug - ( - cd build-debug - # llvm-objdump is searched for with the complete name, not simply 'objdump', account for that. - CXXFLAGS="${CXXFLAGS}" ../js/src/configure \ - LLVM_OBJDUMP="${LLVM_OBJDUMP}" \ - ${CONF_OPTS} \ - --enable-debug \ - --disable-optimize \ - --enable-gczeal - ${MAKE} ${MAKE_OPTS} - ) + MOZCONFIG="$(pwd)/../mozconfig" \ + OPTIONS="${CONF_OPTS} \ + --enable-debug \ + --disable-optimize \ + --enable-gczeal" \ + BUILD_DIR="build-debug" \ + ./mach build "${JOBS}" fi # Release - mkdir -p build-release - ( - cd build-release - CXXFLAGS="${CXXFLAGS}" ../js/src/configure \ - LLVM_OBJDUMP="${LLVM_OBJDUMP}" \ - ${CONF_OPTS} \ - --enable-optimize - ${MAKE} ${MAKE_OPTS} - ) - + MOZCONFIG="$(pwd)/../mozconfig" \ + OPTIONS="${CONF_OPTS} \ + --enable-optimize" \ + BUILD_DIR="build-release" \ + ./mach build "${JOBS}" ) # install diff --git a/libraries/source/spidermonkey/mozconfig b/libraries/source/spidermonkey/mozconfig new file mode 100644 index 0000000000..f8b221dd23 --- /dev/null +++ b/libraries/source/spidermonkey/mozconfig @@ -0,0 +1,7 @@ +# Pass options to configure +for option in ${OPTIONS}; do + ac_add_options "$option" +done + +# Setup output dir +mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/${BUILD_DIR}