kumquat-buildroot/package/spidermonkey/0004-fix-building-with-musl.patch
Adam Duskett 335c0bc610 package/spidermonkey: new package
Spidermonkey is Mozilla's JavaScript engine written in C and C++. It is used in
various Mozilla products, including Firefox, and is available under the MPL2.

There are 10 patches currently required to properly cross-compile spidermonkey:

1) allow-newer-autoconf-versions
  - Spidermonkey is hardcoded to use Autoconf 2.13, which is from 1999!
    The reasoning behind using 2.13 is because newer versions of Autoconf do not
    work correctly with the custom m4 macros in the source code.

    However: Because we are building just the Spidermonkey engine instead of the
    entire Firefox package, newer versions of Autoconf work without issue.
    See: See: https://bugzilla.mozilla.org/show_bug.cgi?id=104642
    for further explanation.

2) allow-building-in-tree
  - By default, spidermonkey must be configured and built out-of-tree, otherwise
    the following error occurs:

    FATAL ERROR PROCESSING MOZBUILD FILE
    ==============================

    The error occurred while processing the following file or one of the files
    it includes:
      js/src/shell/moz.build

    The error occurred when validating the result of the execution. The reported
    error is:
        The path specified in LOCAL_INCLUDES is not allowed:
        .. (resolved to js/src)
    Remove this check, as spidermonkey builds without issue in-tree.

3) allow-unknown-configuration-options
  - By default, if an unknown parameter is passed to configure, an error is
    raised. Replace the raise with a pass and continue.
    Fixes: https://bugzilla.mozilla.org/show_bug.cgi?id=1379540

4) fix-building-with-musl
  - The MIPS specific header <sgidefs.h> is not provided by musl.
    The Linux kernel headers <asm/sgidefs.h> provide the same definitions.

5) add-riscv-support
  - Submitted upstream:
    See: https://bugzilla.mozilla.org/show_bug.cgi?id=1318905

6) copy-headers-on-install-instead-of-symlinking
  - When installing, instead of linking the headers to the source directory,
    copy them.

7) ensure-proper-running-on-64-bit-and-32-bit-be-platforms
  - Taken from the Fedora RPM
    Applied upstream.
    Fixes: https://bugzilla.mozilla.org/show_bug.cgi?id=1488552

8) 0008-save-and-restore-non-volatile-x28-on-ARM64-for-generated-unboxed-obje
  - Taken from the Fedora RPM:
    Applied upstream.
    Fixes: https://bugzilla.mozilla.org/show_bug.cgi?id=1375074

9) save-x28-before-clobbering-it-in-the-regex-compiler
  - Taken from the Fedora RPM:
    Applied upstream.
    Fixes: https://bugzilla.mozilla.org/show_bug.cgi?id=1445907

10) always-use-the-equivalent-year-to-determine-the-time-zone
  - Taken from the Fedora RPM:
    Applied upstream.
    Fixes: https://bugzilla.mozilla.org/show_bug.cgi?id=1415202

Typically, The Firefox source tarball is used to build spidermonkey; however,
this has two disadvantages:
  - It's large. The Firefox source tarball is over 250M.
  - It requires Autoconf 2.13
Instead, use a tarball with only the Spidermonkey source code in it with a
pre-setup configure file. This tarball reduces the size to 31M and prevents the
Autoconf 2.13 requirement.

Signed-off-by: Adam Duskett <aduskett@greenlots.com>
[Thomas: adjust how the libnspr arch dependency is handled]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-11-25 21:18:37 +01:00

134 lines
4.6 KiB
Diff

From 0c9e8f586ba52a9aef5ed298e8315b2598b8fb72 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sat, 25 May 2019 16:54:45 -0700
Subject: [PATCH] fix building with musl
The MIPS specific header <sgidefs.h> is not provided by musl
linux kernel headers provide <asm/sgidefs.h> which has same definitions
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Adam Duskett <aduskett@gmail.com>
---
---
js/src/jsmath.cpp | 2 +-
memory/build/Mutex.h | 4 ++--
mozglue/misc/TimeStamp_darwin.cpp | 1 -
mozglue/misc/TimeStamp_posix.cpp | 1 -
nsprpub/pr/src/misc/prsystem.c | 1 -
third_party/python/psutil/psutil/_psutil_bsd.c | 1 -
third_party/python/psutil/psutil/_psutil_osx.c | 1 -
third_party/python/psutil/psutil/arch/osx/process_info.c | 1 -
8 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/js/src/jsmath.cpp b/js/src/jsmath.cpp
index a28968be..8facaa81 100644
--- a/js/src/jsmath.cpp
+++ b/js/src/jsmath.cpp
@@ -71,7 +71,7 @@
#elif defined(__s390__)
#define GETRANDOM_NR 349
#elif defined(__mips__)
-#include <sgidefs.h>
+#include <asm/sgidefs.h>
#if _MIPS_SIM == _MIPS_SIM_ABI32
#define GETRANDOM_NR 4353
#elif _MIPS_SIM == _MIPS_SIM_ABI64
diff --git a/memory/build/Mutex.h b/memory/build/Mutex.h
index cb8b1e7d..7b9eb1de 100644
--- a/memory/build/Mutex.h
+++ b/memory/build/Mutex.h
@@ -42,7 +42,7 @@ struct Mutex {
if (pthread_mutexattr_init(&attr) != 0) {
return false;
}
- pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP);
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_STALLED);
if (pthread_mutex_init(&mMutex, &attr) != 0) {
pthread_mutexattr_destroy(&attr);
return false;
@@ -102,7 +102,7 @@ typedef Mutex StaticMutex;
#if defined(XP_DARWIN)
#define STATIC_MUTEX_INIT OS_SPINLOCK_INIT
-#elif defined(XP_LINUX) && !defined(ANDROID)
+#elif defined(XP_LINUX) && !defined(ANDROID) && defined(__GLIBC__)
#define STATIC_MUTEX_INIT PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
#else
#define STATIC_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
diff --git a/mozglue/misc/TimeStamp_darwin.cpp b/mozglue/misc/TimeStamp_darwin.cpp
index d2abe9a5..d065649c 100644
--- a/mozglue/misc/TimeStamp_darwin.cpp
+++ b/mozglue/misc/TimeStamp_darwin.cpp
@@ -19,7 +19,6 @@
#include <mach/mach_time.h>
#include <sys/time.h>
-#include <sys/sysctl.h>
#include <time.h>
#include <unistd.h>
diff --git a/mozglue/misc/TimeStamp_posix.cpp b/mozglue/misc/TimeStamp_posix.cpp
index 86c7609a..a37bd93a 100644
--- a/mozglue/misc/TimeStamp_posix.cpp
+++ b/mozglue/misc/TimeStamp_posix.cpp
@@ -21,7 +21,6 @@
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
defined(__OpenBSD__)
#include <sys/param.h>
-#include <sys/sysctl.h>
#endif
#if defined(__DragonFly__) || defined(__FreeBSD__)
diff --git a/nsprpub/pr/src/misc/prsystem.c b/nsprpub/pr/src/misc/prsystem.c
index eba85fb0..54b57bb9 100644
--- a/nsprpub/pr/src/misc/prsystem.c
+++ b/nsprpub/pr/src/misc/prsystem.c
@@ -27,7 +27,6 @@
|| defined(OPENBSD) || defined(DRAGONFLY) || defined(DARWIN)
#define _PR_HAVE_SYSCTL
#include <sys/param.h>
-#include <sys/sysctl.h>
#endif
#if defined(DARWIN)
diff --git a/third_party/python/psutil/psutil/_psutil_bsd.c b/third_party/python/psutil/psutil/_psutil_bsd.c
index 9a2ed04b..9e0d34cb 100644
--- a/third_party/python/psutil/psutil/_psutil_bsd.c
+++ b/third_party/python/psutil/psutil/_psutil_bsd.c
@@ -29,7 +29,6 @@
#include <paths.h>
#include <sys/types.h>
#include <sys/param.h>
-#include <sys/sysctl.h>
#include <sys/user.h>
#include <sys/proc.h>
#include <sys/file.h>
diff --git a/third_party/python/psutil/psutil/_psutil_osx.c b/third_party/python/psutil/psutil/_psutil_osx.c
index 55dd64ca..ec356339 100644
--- a/third_party/python/psutil/psutil/_psutil_osx.c
+++ b/third_party/python/psutil/psutil/_psutil_osx.c
@@ -13,7 +13,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <utmpx.h>
-#include <sys/sysctl.h>
#include <sys/vmmeter.h>
#include <libproc.h>
#include <sys/proc_info.h>
diff --git a/third_party/python/psutil/psutil/arch/osx/process_info.c b/third_party/python/psutil/psutil/arch/osx/process_info.c
index 40c79a2c..8de0dcbd 100644
--- a/third_party/python/psutil/psutil/arch/osx/process_info.c
+++ b/third_party/python/psutil/psutil/arch/osx/process_info.c
@@ -16,7 +16,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
-#include <sys/sysctl.h>
#include <libproc.h>
#include "process_info.h"
--
2.23.0