summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2021-11-13 12:56:16 (GMT)
committerGitHub <noreply@github.com>2021-11-13 12:56:16 (GMT)
commit0486570f7b2b5a75812e5a01a8dca58bfadc2437 (patch)
tree3decd2be9bf1be998e4843ccbf36e5578aaa01d0 /configure.ac
parent4c792f39e688b11c7c19e411ed4f76a7baa44638 (diff)
downloadcpython-0486570f7b2b5a75812e5a01a8dca58bfadc2437.zip
cpython-0486570f7b2b5a75812e5a01a8dca58bfadc2437.tar.gz
cpython-0486570f7b2b5a75812e5a01a8dca58bfadc2437.tar.bz2
bpo-45798: Move _decimal build setup into configure (GH-29541)
Settings for :mod:`decimal` internal C extension are now detected by :program:`configure`. The bundled `libmpdec` library is built in ``Makefile``. Signed-off-by: Christian Heimes <christian@python.org>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac78
1 files changed, 77 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 5a1ed51..c3b52e3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3057,9 +3057,22 @@ AC_ARG_WITH(system_libmpdec,
AS_HELP_STRING([--with-system-libmpdec], [build _decimal module using an installed libmpdec library, see Doc/library/decimal.rst (default is no)]),
[],
[with_system_libmpdec="no"])
-
AC_MSG_RESULT($with_system_libmpdec)
+AS_VAR_IF([with_system_libmpdec], [yes], [
+ LIBMPDEC_CFLAGS=""
+ LIBMPDEC_LDFLAGS="-lmpdec"
+ LIBMPDEC_INTERNAL=
+], [
+ LIBMPDEC_CFLAGS="-I\$(srcdir)/Modules/_decimal/libmpdec"
+ LIBMPDEC_LDFLAGS="-lm \$(LIBMPDEC_A)"
+ LIBMPDEC_INTERNAL="\$(LIBMPDEC_A)"
+])
+
+AC_SUBST([LIBMPDEC_CFLAGS])
+AC_SUBST([LIBMPDEC_LDFLAGS])
+AC_SUBST([LIBMPDEC_INTERNAL])
+
# Check whether _decimal should use a coroutine-local or thread-local context
AC_MSG_CHECKING(for --with-decimal-contextvar)
AC_ARG_WITH(decimal_contextvar,
@@ -3075,6 +3088,69 @@ fi
AC_MSG_RESULT($with_decimal_contextvar)
+# Check for libmpdec machine flavor
+AC_MSG_CHECKING(for decimal libmpdec machine)
+AS_CASE([$ac_sys_system],
+ [Darwin*], [libmpdec_system=Darwin],
+ [SunOS*], [libmpdec_system=sunos],
+ [libmpdec_system=other]
+)
+
+libmpdec_machine=unknown
+if test "$libmpdec_system" = Darwin; then
+ AS_CASE([$MACOSX_DEFAULT_ARCH],
+ [i386], [libmpdec_machine=ansi32],
+ [ppc], [libmpdec_machine=ansi32],
+ [x86_64], [libmpdec_machine=x64],
+ [ppc64], [libmpdec_machine=ansi64],
+ [arm64], [libmpdec_machine=ansi64],
+ [libmpdec_machine=universal]
+ )
+elif test $ac_cv_sizeof_size_t -eq 8; then
+ if test "$ac_cv_gcc_asm_for_x64" = yes; then
+ libmpdec_machine=x64
+ elif test "$ac_cv_type___uint128_t" = yes; then
+ libmpdec_machine=uint128
+ else
+ libmpdec_machine=ansi64
+ fi
+elif test $ac_cv_sizeof_size_t -eq 4; then
+ if test "$ac_cv_gcc_asm_for_x87" = yes -a "$libmpdec_system" != sunos; then
+ AS_CASE([$CC],
+ [*gcc*], [libmpdec_machine=ppro],
+ [*clang*], [libmpdec_machine=ppro],
+ [libmpdec_machine=ansi32]
+ )
+ else
+ libmpdec_machine=ansi32
+ fi
+fi
+AC_MSG_RESULT([$libmpdec_machine])
+
+AS_CASE([$libmpdec_machine],
+ [x64], [AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DCONFIG_64=1 -DASM=1"])],
+ [uint128], [AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DCONFIG_64=1 -DANSI=1 -DHAVE_UINT128_T=1"])],
+ [ansi64], [AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DCONFIG_64=1 -DANSI=1"])],
+ [ppro], [AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DCONFIG_32=1 -DANSI=1 -DASM=1 -Wno-unknown-pragmas"])],
+ [ansi32], [AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DCONFIG_32=1 -DANSI=1"])],
+ [ansi-legacy], [AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DCONFIG_32=1 -DANSI=1 -DLEGACY_COMPILER=1"])],
+ [universal], [AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -DUNIVERSAL=1"])],
+ [AC_MSG_ERROR([_decimal: unsupported architecture])]
+)
+
+if test "$have_ipa_pure_const_bug" = yes; then
+ # Some versions of gcc miscompile inline asm:
+ # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491
+ # https://gcc.gnu.org/ml/gcc/2010-11/msg00366.html
+ AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -fno-ipa-pure-const"])
+fi
+
+if test "$have_glibc_memmove_bug" = yes; then
+ # _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect:
+ # https://sourceware.org/ml/libc-alpha/2010-12/msg00009.html
+ AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -U_FORTIFY_SOURCE"])
+fi
+
# Check for support for loadable sqlite extensions
AC_MSG_CHECKING(for --enable-loadable-sqlite-extensions)
AC_ARG_ENABLE(loadable-sqlite-extensions,