* m4/libgmp.m4 (gl_LIBGMP): Reject GMP 6.1.2 (2016) and earlier,
as these older versions had an inferior primality test and
coreutils factor.c will need Baillie-PSW.  mini-gmp.c already has
Baillie-PSW, so it can serve as a fallback.
---
 ChangeLog    | 8 ++++++++
 m4/libgmp.m4 | 8 ++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 80fbd2b397..b2578a3ca1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-06-14  Paul Eggert  <egg...@cs.ucla.edu>
+
+       libgmp-mpz: require Baillie-PSW primality test
+       * m4/libgmp.m4 (gl_LIBGMP): Reject GMP 6.1.2 (2016) and earlier,
+       as these older versions had an inferior primality test and
+       coreutils factor.c will need Baillie-PSW.  mini-gmp.c already has
+       Baillie-PSW, so it can serve as a fallback.
+
 2025-06-13  Bruno Haible  <br...@clisp.org>
 
        stat: Support the file name "/dev/null" on native Windows.
diff --git a/m4/libgmp.m4 b/m4/libgmp.m4
index baed8ab1a0..abf677949d 100644
--- a/m4/libgmp.m4
+++ b/m4/libgmp.m4
@@ -1,5 +1,5 @@
 # libgmp.m4
-# serial 8
+# serial 9
 # Configure the GMP library or a replacement.
 dnl Copyright 2020-2025 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
@@ -34,7 +34,11 @@ AC_DEFUN([gl_LIBGMP]
               # include <gmp.h>
               #else
               # include <gmp/gmp.h>
-              #endif],
+              #endif
+              #if ! (6 < __GNU_MP_VERSION + (2 <= __GNU_MP_VERSION_MINOR))
+              # error "GMP < 6.2.0, so mpz_probab_prime_p lacks Baillie-PSW"
+              #endif
+              ],
              [static const mp_limb_t x[2] = { 0x73, 0x55 };
               mpz_t tmp;
               mpz_roinit_n (tmp, x, 2);
-- 
2.49.0


Reply via email to