Skip to content
Snippets Groups Projects
Commit 0e68c5bf authored by Ben Gamari's avatar Ben Gamari :turtle:
Browse files

Merge branch 'wasm32-wasi' into 'master'

Wasm32 specific patch

See merge request !1
parents 31f99096 639d5c6c
No related branches found
No related tags found
1 merge request!1Wasm32 specific patch
From df70b7d9c1d1d1e8985060a1d56862a8f2e55d3f Mon Sep 17 00:00:00 2001
From: Cheng Shao <astrohavoc@gmail.com>
Date: Thu, 3 Nov 2022 13:58:46 +0000
Subject: [PATCH] Enable building for wasm32-wasi
This patch enables gmp-6.2.1 to build for wasm32-wasi, which lacks
signals and raise.h.
---
errno.c | 2 ++
invalid.c | 9 ++++++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/errno.c b/errno.c
index b4be555..7c0f1db 100644
--- a/errno.c
+++ b/errno.c
@@ -34,7 +34,9 @@ see https://www.gnu.org/licenses/. */
#include <stdlib.h>
+#ifdef HAVE_RAISE
#include <signal.h>
+#endif
#include "gmp-impl.h"
diff --git a/invalid.c b/invalid.c
index e09eab2..71cf7d5 100644
--- a/invalid.c
+++ b/invalid.c
@@ -34,7 +34,10 @@ see https://www.gnu.org/licenses/. */
#include "config.h"
+#ifdef HAVE_RAISE
#include <signal.h>
+#endif
+
#include <stdlib.h>
#if HAVE_UNISTD_H
@@ -47,7 +50,7 @@ see https://www.gnu.org/licenses/. */
/* Incidentally, kill is not available on mingw, but that's ok, it has raise
and we'll be using that. */
#if ! HAVE_RAISE
-#define raise(sig) kill (getpid(), sig)
+#define raise(sig) exit(sig)
#endif
@@ -77,6 +80,10 @@ see https://www.gnu.org/licenses/. */
void
__gmp_invalid_operation (void)
{
+#ifdef SIGFPE
raise (SIGFPE);
+#else
+ __gmp_junk = 10 / __gmp_0;
+#endif
abort ();
}
--
2.38.1
......@@ -12,14 +12,19 @@ GMP_DOWNLOAD_SIGNATURE=https://gmplib.org/download/gmp/${GMP_SIGNATURE}
wget "$GMP_DOWNLOAD_TARBALL"
wget "$GMP_DOWNLOAD_SIGNATURE"
gpg --keyserver keys.gnupg.net --recv-keys 0x28C67298
gpg --keyserver keyserver.ubuntu.com --recv-keys 343C2FF0FBEE5EC2EDBEF399F3599FF828C67298
gpg --verify "$GMP_SIGNATURE" "$GMP_TARBALL"
# Fingerprint is okay
rm "$GMP_SIGNATURE"
bunzip2 "$GMP_TARBALL"
tar -xjf "$GMP_TARBALL"
cd gmp-${GMP_VERSION}
rm -r doc
patch -p1 < ../0001-Enable-building-for-wasm32-wasi.patch
cd ..
UNCOMPRESSED_TARBALL=${GMP_TARBALL%.bz2}
tar --delete --file="$UNCOMPRESSED_TARBALL" gmp-${GMP_VERSION}/doc
tar -c --sort=name --mtime=0 --owner=0 --group=0 --numeric-owner -f ${UNCOMPRESSED_TARBALL} gmp-${GMP_VERSION}
rm -r gmp-${GMP_VERSION}
mv ${UNCOMPRESSED_TARBALL} out-${UNCOMPRESSED_TARBALL}
bzip2 out-"$UNCOMPRESSED_TARBALL"
echo "Output tarball is in out-$GMP_TARBALL"
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment