emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] Require full GMP when building module support.


From: Philipp Stephani
Subject: [PATCH 1/2] Require full GMP when building module support.
Date: Thu, 25 Apr 2019 15:46:08 +0200

This allows mini-gmp to not stay binary-compatible with full GMP.

* configure.ac (HAVE_MODULES): Disable if full GMP is unavailable.
Move check below GMP check.

* src/emacs-module.h.in: Don’t check EMACS_MODULE_HAVE_MPZ_T macro.

* src/emacs-module.c:
* test/data/emacs-module/mod-test.c: Error out if full GMP is
unavailable.
---
 configure.ac                      | 109 ++++++++++++++++--------------
 src/emacs-module.c                |   6 +-
 src/emacs-module.h.in             |   2 +-
 test/data/emacs-module/mod-test.c |   3 +-
 4 files changed, 63 insertions(+), 57 deletions(-)

diff --git a/configure.ac b/configure.ac
index 810c3219e4..1f87fe0383 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3646,58 +3646,6 @@ AC_DEFUN
 fi
 AC_SUBST(LIBZ)
 
-### Dynamic modules support
-LIBMODULES=
-HAVE_MODULES=no
-MODULES_OBJ=
-case $opsys in
-  cygwin|mingw32) MODULES_SUFFIX=".dll" ;;
-  *) MODULES_SUFFIX=".so" ;;
-esac
-if test "${with_modules}" != "no"; then
-  case $opsys in
-    gnu|gnu-linux)
-      LIBMODULES="-ldl"
-      HAVE_MODULES=yes
-      ;;
-    cygwin|mingw32|darwin)
-      HAVE_MODULES=yes
-      ;;
-    *)
-      # BSD systems have dlopen in libc.
-      AC_CHECK_FUNC([dlopen], [HAVE_MODULES=yes])
-      ;;
-  esac
-
-  if test "${HAVE_MODULES}" = no; then
-    AC_MSG_ERROR([Dynamic modules are not supported on your system])
-  else
-    SAVE_LIBS=$LIBS
-    LIBS="$LIBS $LIBMODULES"
-    AC_CHECK_FUNCS([dladdr dlfunc])
-    LIBS=$SAVE_LIBS
-  fi
-fi
-
-if test "${HAVE_MODULES}" = yes; then
-   MODULES_OBJ="dynlib.o emacs-module.o"
-   AC_DEFINE(HAVE_MODULES, 1, [Define to 1 if dynamic modules are enabled])
-   AC_DEFINE_UNQUOTED(MODULES_SUFFIX, "$MODULES_SUFFIX",
-     [System extension for dynamic libraries])
-fi
-AC_SUBST(MODULES_OBJ)
-AC_SUBST(LIBMODULES)
-AC_SUBST(HAVE_MODULES)
-AC_SUBST(MODULES_SUFFIX)
-
-AC_CONFIG_FILES([src/emacs-module.h])
-AC_SUBST_FILE([module_env_snippet_25])
-AC_SUBST_FILE([module_env_snippet_26])
-AC_SUBST_FILE([module_env_snippet_27])
-module_env_snippet_25="$srcdir/src/module-env-25.h"
-module_env_snippet_26="$srcdir/src/module-env-26.h"
-module_env_snippet_27="$srcdir/src/module-env-27.h"
-
 ### Use -lpng if available, unless '--with-png=no'.
 HAVE_PNG=no
 LIBPNG=
@@ -4473,6 +4421,63 @@ AC_DEFUN
 AC_SUBST([GMP_LIB])
 AC_SUBST([GMP_OBJ])
 
+### Dynamic modules support
+LIBMODULES=
+HAVE_MODULES=no
+MODULES_OBJ=
+case $opsys in
+  cygwin|mingw32) MODULES_SUFFIX=".dll" ;;
+  *) MODULES_SUFFIX=".so" ;;
+esac
+if test "${with_modules}" != "no"; then
+  case $opsys in
+    gnu|gnu-linux)
+      LIBMODULES="-ldl"
+      HAVE_MODULES=yes
+      ;;
+    cygwin|mingw32|darwin)
+      HAVE_MODULES=yes
+      ;;
+    *)
+      # BSD systems have dlopen in libc.
+      AC_CHECK_FUNC([dlopen], [HAVE_MODULES=yes])
+      ;;
+  esac
+
+  if test "${HAVE_GMP}" != yes; then
+    # Modules require full GMP support.
+    HAVE_MODULES=no
+  fi
+
+  if test "${HAVE_MODULES}" = no; then
+    AC_MSG_ERROR([Dynamic modules are not supported on your system])
+  else
+    SAVE_LIBS=$LIBS
+    LIBS="$LIBS $LIBMODULES"
+    AC_CHECK_FUNCS([dladdr dlfunc])
+    LIBS=$SAVE_LIBS
+  fi
+fi
+
+if test "${HAVE_MODULES}" = yes; then
+   MODULES_OBJ="dynlib.o emacs-module.o"
+   AC_DEFINE(HAVE_MODULES, 1, [Define to 1 if dynamic modules are enabled])
+   AC_DEFINE_UNQUOTED(MODULES_SUFFIX, "$MODULES_SUFFIX",
+     [System extension for dynamic libraries])
+fi
+AC_SUBST(MODULES_OBJ)
+AC_SUBST(LIBMODULES)
+AC_SUBST(HAVE_MODULES)
+AC_SUBST(MODULES_SUFFIX)
+
+AC_CONFIG_FILES([src/emacs-module.h])
+AC_SUBST_FILE([module_env_snippet_25])
+AC_SUBST_FILE([module_env_snippet_26])
+AC_SUBST_FILE([module_env_snippet_27])
+module_env_snippet_25="$srcdir/src/module-env-25.h"
+module_env_snippet_26="$srcdir/src/module-env-26.h"
+module_env_snippet_27="$srcdir/src/module-env-27.h"
+
 AC_CHECK_HEADERS(valgrind/valgrind.h)
 
 AC_CHECK_MEMBERS([struct unipair.unicode], [], [], [[#include <linux/kd.h>]])
diff --git a/src/emacs-module.c b/src/emacs-module.c
index 0b7b3d6ffb..f60495844b 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -70,9 +70,11 @@ To add a new module function, proceed as follows:
 
 #include <config.h>
 
+/* We don't support mini-gmp for modules because it might not stay
+   binary-compatible with GMP proper.  */
+
 #ifndef HAVE_GMP
-#include "mini-gmp.h"
-#define EMACS_MODULE_HAVE_MPZ_T
+# error "Modules require full GMP support"
 #endif
 
 #define EMACS_MODULE_GMP
diff --git a/src/emacs-module.h.in b/src/emacs-module.h.in
index fbc62a61ef..e61aadfc3a 100644
--- a/src/emacs-module.h.in
+++ b/src/emacs-module.h.in
@@ -28,7 +28,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include <stdbool.h>
 #endif
 
-#if defined EMACS_MODULE_GMP && !defined EMACS_MODULE_HAVE_MPZ_T
+#ifdef EMACS_MODULE_GMP
 #include <gmp.h>
 #endif
 
diff --git a/test/data/emacs-module/mod-test.c 
b/test/data/emacs-module/mod-test.c
index b7007bd80f..73c8c52f7c 100644
--- a/test/data/emacs-module/mod-test.c
+++ b/test/data/emacs-module/mod-test.c
@@ -30,8 +30,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #ifdef HAVE_GMP
 #include <gmp.h>
 #else
-#include "mini-gmp.h"
-#define EMACS_MODULE_HAVE_MPZ_T
+# error "Modules require full GMP support"
 #endif
 
 #define EMACS_MODULE_GMP
-- 
2.20.1 (Apple Git-117)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]