From 268d27044254b44be5b0393d6a7a8268cdd1eb34 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Fri, 3 May 2024 10:13:49 +0200 Subject: [PATCH 01/12] gh-115119: Default to --with-system-libmpdec=yes Mark _decimal as missing if libmpdecimal is not found. --- Doc/using/configure.rst | 7 +++- configure | 90 +++++++++++++++++++++++++++++++++++++++-- configure.ac | 16 ++++++-- 3 files changed, 104 insertions(+), 9 deletions(-) diff --git a/Doc/using/configure.rst b/Doc/using/configure.rst index e662c0dafdb8de..20b4fb3c030e33 100644 --- a/Doc/using/configure.rst +++ b/Doc/using/configure.rst @@ -804,11 +804,14 @@ Libraries options .. option:: --with-system-libmpdec - Build the ``_decimal`` extension module using an installed ``mpdec`` - library, see the :mod:`decimal` module (default is no). + Build the ``_decimal`` extension module using an installed ``mpdecimal`` + library, see the :mod:`decimal` module (default is yes). .. versionadded:: 3.3 + .. versionchanged:: 3.13 + Default to using the installed ``mpdecimal`` library. + .. seealso:: :option:`LIBMPDEC_CFLAGS` and :option:`LIBMPDEC_LIBS`. .. option:: --with-readline=readline|editline diff --git a/configure b/configure index cc85aed2aa51c2..4dbc2c6c01d995 100755 --- a/configure +++ b/configure @@ -1892,8 +1892,9 @@ Optional Packages: --with-libs='lib1 ...' link against additional libs (default is no) --with-system-expat build pyexpat module using an installed expat library, see Doc/library/pyexpat.rst (default is no) - --with-system-libmpdec build _decimal module using an installed libmpdec - library, see Doc/library/decimal.rst (default is no) + --with-system-libmpdec build _decimal module using an installed mpdecimal + library, see Doc/library/decimal.rst (default is + yes) --with-decimal-contextvar build _decimal module using a coroutine-local rather than a thread-local context (default is yes) @@ -14611,7 +14612,7 @@ if test ${with_system_libmpdec+y} then : withval=$with_system_libmpdec; else $as_nop - with_system_libmpdec="no" + with_system_libmpdec="yes" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_system_libmpdec" >&5 @@ -14700,6 +14701,87 @@ else $as_nop LIBMPDEC_INTERNAL="\$(LIBMPDEC_HEADERS) \$(LIBMPDEC_A)" fi +if test "x$with_system_libmpdec" = xyes +then : + save_CFLAGS=$CFLAGS +save_CPPFLAGS=$CPPFLAGS +save_LDFLAGS=$LDFLAGS +save_LIBS=$LIBS + + + CPPFLAGS="$LIBMPDEC_CFLAGS $CPPFLAGS" + LDFLAGS="$LIBMPDEC_LIBS $LDFLAGS" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing mpd_version" >&5 +printf %s "checking for library containing mpd_version... " >&6; } +if test ${ac_cv_search_mpd_version+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +char mpd_version (); +int +main (void) +{ +return mpd_version (); + ; + return 0; +} +_ACEOF +for ac_lib in '' mpdec +do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO" +then : + ac_cv_search_mpd_version=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext + if test ${ac_cv_search_mpd_version+y} +then : + break +fi +done +if test ${ac_cv_search_mpd_version+y} +then : + +else $as_nop + ac_cv_search_mpd_version=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_mpd_version" >&5 +printf "%s\n" "$ac_cv_search_mpd_version" >&6; } +ac_res=$ac_cv_search_mpd_version +if test "$ac_res" != no +then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + have_mpdec=yes +else $as_nop + have_mpdec=no +fi + +CFLAGS=$save_CFLAGS +CPPFLAGS=$save_CPPFLAGS +LDFLAGS=$save_LDFLAGS +LIBS=$save_LIBS + + +else $as_nop + have_mpdec=yes +fi + # Disable forced inlining in debug builds, see GH-94847 if test "x$with_pydebug" = xyes then : @@ -30393,7 +30475,7 @@ then : if true then : - if true + if test "$have_mpdec" = "yes" then : py_cv_module__decimal=yes else $as_nop diff --git a/configure.ac b/configure.ac index c55e33add20fde..a5d18181a1eb70 100644 --- a/configure.ac +++ b/configure.ac @@ -3974,10 +3974,10 @@ 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)] + [build _decimal module using an installed mpdecimal library, see Doc/library/decimal.rst (default is yes)] )], [], - [with_system_libmpdec="no"]) + [with_system_libmpdec="yes"]) AC_MSG_RESULT([$with_system_libmpdec]) AS_VAR_IF( @@ -3991,6 +3991,14 @@ AS_VAR_IF( LIBMPDEC_LIBS="-lm \$(LIBMPDEC_A)" LIBMPDEC_INTERNAL="\$(LIBMPDEC_HEADERS) \$(LIBMPDEC_A)"]) +AS_VAR_IF([with_system_libmpdec], [yes], + [WITH_SAVE_ENV([ + CPPFLAGS="$LIBMPDEC_CFLAGS $CPPFLAGS" + LDFLAGS="$LIBMPDEC_LIBS $LDFLAGS" + AC_SEARCH_LIBS([mpd_version], [mpdec], + [have_mpdec=yes], [have_mpdec=no])])], + [have_mpdec=yes]) + # Disable forced inlining in debug builds, see GH-94847 AS_VAR_IF( [with_pydebug], [yes], @@ -7665,7 +7673,9 @@ PY_STDLIB_MOD([_curses_panel], [], [test "$have_panel" != "no"], [$PANEL_CFLAGS $CURSES_CFLAGS], [$PANEL_LIBS $CURSES_LIBS] ) -PY_STDLIB_MOD([_decimal], [], [], [$LIBMPDEC_CFLAGS], [$LIBMPDEC_LIBS]) +PY_STDLIB_MOD([_decimal], + [], [test "$have_mpdec" = "yes"], + [$LIBMPDEC_CFLAGS], [$LIBMPDEC_LIBS]) PY_STDLIB_MOD([_dbm], [test -n "$with_dbmliborder"], [test "$have_dbm" != "no"], [$DBM_CFLAGS], [$DBM_LIBS]) From 6f020d08b67c66bb78a838b60c3dc1aaf9d61545 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Sun, 5 May 2024 22:49:23 +0200 Subject: [PATCH 02/12] Use the same style as the surrounding code --- configure | 7 +++---- configure.ac | 15 ++++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/configure b/configure index 04d1cdfa7b145d..e859d09ca03b07 100755 --- a/configure +++ b/configure @@ -14708,10 +14708,9 @@ save_CPPFLAGS=$CPPFLAGS save_LDFLAGS=$LDFLAGS save_LIBS=$LIBS - - CPPFLAGS="$LIBMPDEC_CFLAGS $CPPFLAGS" - LDFLAGS="$LIBMPDEC_LIBS $LDFLAGS" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing mpd_version" >&5 +CPPFLAGS="$LIBMPDEC_CFLAGS $CPPFLAGS" + LDFLAGS="$LIBMPDEC_LIBS $LDFLAGS" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing mpd_version" >&5 printf %s "checking for library containing mpd_version... " >&6; } if test ${ac_cv_search_mpd_version+y} then : diff --git a/configure.ac b/configure.ac index 3705edca84a709..c6bcd6550caa23 100644 --- a/configure.ac +++ b/configure.ac @@ -3991,13 +3991,14 @@ AS_VAR_IF( LIBMPDEC_LIBS="-lm \$(LIBMPDEC_A)" LIBMPDEC_INTERNAL="\$(LIBMPDEC_HEADERS) \$(LIBMPDEC_A)"]) -AS_VAR_IF([with_system_libmpdec], [yes], - [WITH_SAVE_ENV([ - CPPFLAGS="$LIBMPDEC_CFLAGS $CPPFLAGS" - LDFLAGS="$LIBMPDEC_LIBS $LDFLAGS" - AC_SEARCH_LIBS([mpd_version], [mpdec], - [have_mpdec=yes], [have_mpdec=no])])], - [have_mpdec=yes]) +AS_VAR_IF( + [with_system_libmpdec], [yes], + [WITH_SAVE_ENV( + [CPPFLAGS="$LIBMPDEC_CFLAGS $CPPFLAGS" + LDFLAGS="$LIBMPDEC_LIBS $LDFLAGS" + AC_SEARCH_LIBS([mpd_version], [mpdec], + [have_mpdec=yes], [have_mpdec=no])])], + [have_mpdec=yes]) # Disable forced inlining in debug builds, see GH-94847 AS_VAR_IF( From fe56023aff73ba3e9ab0026e1536cf2dfac88d2c Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Sun, 5 May 2024 22:51:27 +0200 Subject: [PATCH 03/12] Fail if --with-system-libmpdec is given but no library was found --- configure | 4 ++-- configure.ac | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure b/configure index e859d09ca03b07..2f68cf7183912c 100755 --- a/configure +++ b/configure @@ -30505,9 +30505,9 @@ printf %s "checking for stdlib extension module _decimal... " >&6; } if test "$py_cv_module__decimal" != "n/a" then : - if true + if test "$have_mpdec" = "yes" then : - if test "$have_mpdec" = "yes" + if true then : py_cv_module__decimal=yes else $as_nop diff --git a/configure.ac b/configure.ac index c6bcd6550caa23..7d0d6fcb1dd4e0 100644 --- a/configure.ac +++ b/configure.ac @@ -7678,7 +7678,7 @@ PY_STDLIB_MOD([_curses_panel], [$PANEL_CFLAGS $CURSES_CFLAGS], [$PANEL_LIBS $CURSES_LIBS] ) PY_STDLIB_MOD([_decimal], - [], [test "$have_mpdec" = "yes"], + [test "$have_mpdec" = "yes"], [], [$LIBMPDEC_CFLAGS], [$LIBMPDEC_LIBS]) PY_STDLIB_MOD([_dbm], [test -n "$with_dbmliborder"], [test "$have_dbm" != "no"], From 00068973daa97130f48642372e704a88dae24f87 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Sun, 5 May 2024 23:07:51 +0200 Subject: [PATCH 04/12] Address review: warn if bundled version is used --- configure | 2 ++ configure.ac | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 2f68cf7183912c..c96c89bafee29f 100755 --- a/configure +++ b/configure @@ -14779,6 +14779,8 @@ LIBS=$save_LIBS else $as_nop have_mpdec=yes + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: the bundled copy of libmpdecimal is scheduled for removal in Python 3.15; consider using a system installed mpdecimal library." >&5 +printf "%s\n" "$as_me: WARNING: the bundled copy of libmpdecimal is scheduled for removal in Python 3.15; consider using a system installed mpdecimal library." >&2;} fi # Disable forced inlining in debug builds, see GH-94847 diff --git a/configure.ac b/configure.ac index 7d0d6fcb1dd4e0..e298d1daf0c220 100644 --- a/configure.ac +++ b/configure.ac @@ -3998,7 +3998,10 @@ AS_VAR_IF( LDFLAGS="$LIBMPDEC_LIBS $LDFLAGS" AC_SEARCH_LIBS([mpd_version], [mpdec], [have_mpdec=yes], [have_mpdec=no])])], - [have_mpdec=yes]) + [AS_VAR_SET([have_mpdec], [yes]) + AC_MSG_WARN([m4_normalize([the bundled copy of libmpdecimal is scheduled for + removal in Python 3.15; consider using a system + installed mpdecimal library.])])]) # Disable forced inlining in debug builds, see GH-94847 AS_VAR_IF( From 4f87c917c8c48840fd67cb2b3050fcf78c4e3745 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 6 May 2024 00:21:46 +0200 Subject: [PATCH 05/12] Address review: warn if system library was not found --- configure | 20 +++++++++++++------- configure.ac | 26 ++++++++++++++------------ 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/configure b/configure index c96c89bafee29f..2405938af71c82 100755 --- a/configure +++ b/configure @@ -14708,9 +14708,10 @@ save_CPPFLAGS=$CPPFLAGS save_LDFLAGS=$LDFLAGS save_LIBS=$LIBS -CPPFLAGS="$LIBMPDEC_CFLAGS $CPPFLAGS" - LDFLAGS="$LIBMPDEC_LIBS $LDFLAGS" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing mpd_version" >&5 + + CPPFLAGS="$LIBMPDEC_CFLAGS $CPPFLAGS" + LDFLAGS="$LIBMPDEC_LIBS $LDFLAGS" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing mpd_version" >&5 printf %s "checking for library containing mpd_version... " >&6; } if test ${ac_cv_search_mpd_version+y} then : @@ -14778,11 +14779,16 @@ LIBS=$save_LIBS else $as_nop - have_mpdec=yes - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: the bundled copy of libmpdecimal is scheduled for removal in Python 3.15; consider using a system installed mpdecimal library." >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: the bundled copy of libmpdecimal is scheduled for removal in Python 3.15; consider using a system installed mpdecimal library." >&5 printf "%s\n" "$as_me: WARNING: the bundled copy of libmpdecimal is scheduled for removal in Python 3.15; consider using a system installed mpdecimal library." >&2;} fi +if test "$with_system_libmpdec" = "yes" && test "$have_mpdec" = "no" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: no system libmpdecimal found; unable to build _decimal" >&5 +printf "%s\n" "$as_me: WARNING: no system libmpdecimal found; unable to build _decimal" >&2;} +fi + # Disable forced inlining in debug builds, see GH-94847 if test "x$with_pydebug" = xyes then : @@ -30507,9 +30513,9 @@ printf %s "checking for stdlib extension module _decimal... " >&6; } if test "$py_cv_module__decimal" != "n/a" then : - if test "$have_mpdec" = "yes" + if true then : - if true + if test "$have_mpdec" = "yes" then : py_cv_module__decimal=yes else $as_nop diff --git a/configure.ac b/configure.ac index e298d1daf0c220..102d4ffb75615f 100644 --- a/configure.ac +++ b/configure.ac @@ -3991,17 +3991,19 @@ AS_VAR_IF( LIBMPDEC_LIBS="-lm \$(LIBMPDEC_A)" LIBMPDEC_INTERNAL="\$(LIBMPDEC_HEADERS) \$(LIBMPDEC_A)"]) -AS_VAR_IF( - [with_system_libmpdec], [yes], - [WITH_SAVE_ENV( - [CPPFLAGS="$LIBMPDEC_CFLAGS $CPPFLAGS" - LDFLAGS="$LIBMPDEC_LIBS $LDFLAGS" - AC_SEARCH_LIBS([mpd_version], [mpdec], - [have_mpdec=yes], [have_mpdec=no])])], - [AS_VAR_SET([have_mpdec], [yes]) - AC_MSG_WARN([m4_normalize([the bundled copy of libmpdecimal is scheduled for - removal in Python 3.15; consider using a system - installed mpdecimal library.])])]) +AS_VAR_IF([with_system_libmpdec], [yes], + [WITH_SAVE_ENV([ + CPPFLAGS="$LIBMPDEC_CFLAGS $CPPFLAGS" + LDFLAGS="$LIBMPDEC_LIBS $LDFLAGS" + AC_SEARCH_LIBS( + [mpd_version], [mpdec], + [have_mpdec=yes], [have_mpdec=no])])], + [AC_MSG_WARN([m4_normalize([ + the bundled copy of libmpdecimal is scheduled for removal in Python 3.15; + consider using a system installed mpdecimal library.])])]) + +AS_IF([test "$with_system_libmpdec" = "yes" && test "$have_mpdec" = "no"], + [AC_MSG_WARN([no system libmpdecimal found; unable to build _decimal])]) # Disable forced inlining in debug builds, see GH-94847 AS_VAR_IF( @@ -7681,7 +7683,7 @@ PY_STDLIB_MOD([_curses_panel], [$PANEL_CFLAGS $CURSES_CFLAGS], [$PANEL_LIBS $CURSES_LIBS] ) PY_STDLIB_MOD([_decimal], - [test "$have_mpdec" = "yes"], [], + [], [test "$have_mpdec" = "yes"], [$LIBMPDEC_CFLAGS], [$LIBMPDEC_LIBS]) PY_STDLIB_MOD([_dbm], [test -n "$with_dbmliborder"], [test "$have_dbm" != "no"], From f8f4ea2327c657559cb20e7437f0116270d3b24d Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 6 May 2024 00:36:37 +0200 Subject: [PATCH 06/12] For now, build with bundled libmpdec in Ubuntu CIs --- .github/workflows/build.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 299c02e0944d42..8111951637f003 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -232,7 +232,8 @@ jobs: ../cpython-ro-srcdir/configure \ --config-cache \ --with-pydebug \ - --with-openssl=$OPENSSL_DIR + --with-openssl=$OPENSSL_DIR \ + --with-system-libmpdec=no build_ubuntu_free_threading: name: 'Ubuntu (free-threading)' @@ -246,7 +247,8 @@ jobs: --config-cache \ --with-pydebug \ --with-openssl=$OPENSSL_DIR \ - --disable-gil + --disable-gil \ + --with-system-libmpdec=no build_ubuntu_ssltests: name: 'Ubuntu SSL tests with OpenSSL' @@ -371,7 +373,8 @@ jobs: ../cpython-ro-srcdir/configure \ --config-cache \ --with-pydebug \ - --with-openssl=$OPENSSL_DIR + --with-openssl=$OPENSSL_DIR \ + --with-system-libmpdec=no - name: Build CPython out-of-tree working-directory: ${{ env.CPYTHON_BUILDDIR }} run: make -j4 @@ -477,7 +480,7 @@ jobs: save: ${{ github.event_name == 'push' }} max-size: "200M" - name: Configure CPython - run: ./configure --config-cache --with-address-sanitizer --without-pymalloc + run: ./configure --config-cache --with-address-sanitizer --without-pymalloc --with-system-libmpdec=no - name: Build CPython run: make -j4 - name: Display build info From 8e8086679d891515c72a860df4972339db8ab3a5 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 6 May 2024 00:40:15 +0200 Subject: [PATCH 07/12] Add NEWS --- .../next/Build/2024-05-06-00-39-06.gh-issue-115119.LT27pF.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Misc/NEWS.d/next/Build/2024-05-06-00-39-06.gh-issue-115119.LT27pF.rst diff --git a/Misc/NEWS.d/next/Build/2024-05-06-00-39-06.gh-issue-115119.LT27pF.rst b/Misc/NEWS.d/next/Build/2024-05-06-00-39-06.gh-issue-115119.LT27pF.rst new file mode 100644 index 00000000000000..653df986757e18 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2024-05-06-00-39-06.gh-issue-115119.LT27pF.rst @@ -0,0 +1,3 @@ +The :program:`configure` option :option:`--with-system-libmpdec` now defaults +to ``yes``. The bundled version of ``libmpdecimal`` will be removed in Python +3.15. From e51c1f7edc9cc3ccff6ec08a519612c7f511ff40 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 6 May 2024 00:43:14 +0200 Subject: [PATCH 08/12] What's New --- Doc/whatsnew/3.13.rst | 5 +++++ .../Build/2024-05-06-00-39-06.gh-issue-115119.LT27pF.rst | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index 11c3f931909a34..52678679e1e64c 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -1776,6 +1776,10 @@ Changes in the Python API Build Changes ============= +* The :file:`configure` option :option:`--with-system-libmpdec` now defaults + to ``yes``. The bundled copy of ``libmpdecimal`` will be removed in Python + 3.15. + * Autoconf 2.71 and aclocal 1.16.4 are now required to regenerate the :file:`configure` script. (Contributed by Christian Heimes in :gh:`89886`.) @@ -2305,6 +2309,7 @@ Pending Removal in Python 3.14 Pending Removal in Python 3.15 ------------------------------ +* The bundled copy of ``libmpdecimal``. * :c:func:`PyImport_ImportModuleNoBlock`: use :c:func:`PyImport_ImportModule`. * :c:func:`PyWeakref_GET_OBJECT`: use :c:func:`PyWeakref_GetRef` instead. * :c:func:`PyWeakref_GetObject`: use :c:func:`PyWeakref_GetRef` instead. diff --git a/Misc/NEWS.d/next/Build/2024-05-06-00-39-06.gh-issue-115119.LT27pF.rst b/Misc/NEWS.d/next/Build/2024-05-06-00-39-06.gh-issue-115119.LT27pF.rst index 653df986757e18..a3e25388416a2f 100644 --- a/Misc/NEWS.d/next/Build/2024-05-06-00-39-06.gh-issue-115119.LT27pF.rst +++ b/Misc/NEWS.d/next/Build/2024-05-06-00-39-06.gh-issue-115119.LT27pF.rst @@ -1,3 +1,2 @@ -The :program:`configure` option :option:`--with-system-libmpdec` now defaults -to ``yes``. The bundled version of ``libmpdecimal`` will be removed in Python -3.15. +The :file:`configure` option :option:`--with-system-libmpdec` now defaults to ``yes``. +The bundled copy of ``libmpdecimal`` will be removed in Python 3.15. From a971a262d1196cd89b21e81e274fbccce1a50355 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 6 May 2024 00:47:43 +0200 Subject: [PATCH 09/12] Actually use bundled version if told to do so --- configure | 3 ++- configure.ac | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 2405938af71c82..50280d3cbef47b 100755 --- a/configure +++ b/configure @@ -14779,7 +14779,8 @@ LIBS=$save_LIBS else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: the bundled copy of libmpdecimal is scheduled for removal in Python 3.15; consider using a system installed mpdecimal library." >&5 + have_mpdec=yes + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: the bundled copy of libmpdecimal is scheduled for removal in Python 3.15; consider using a system installed mpdecimal library." >&5 printf "%s\n" "$as_me: WARNING: the bundled copy of libmpdecimal is scheduled for removal in Python 3.15; consider using a system installed mpdecimal library." >&2;} fi diff --git a/configure.ac b/configure.ac index 102d4ffb75615f..3582ddb1dd12e1 100644 --- a/configure.ac +++ b/configure.ac @@ -3998,7 +3998,8 @@ AS_VAR_IF([with_system_libmpdec], [yes], AC_SEARCH_LIBS( [mpd_version], [mpdec], [have_mpdec=yes], [have_mpdec=no])])], - [AC_MSG_WARN([m4_normalize([ + [AS_VAR_SET([have_mpdec], [yes]) + AC_MSG_WARN([m4_normalize([ the bundled copy of libmpdecimal is scheduled for removal in Python 3.15; consider using a system installed mpdecimal library.])])]) From e3f3e178f4e86626c8a0f3cd70de92b44058a6d2 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 6 May 2024 09:02:12 +0200 Subject: [PATCH 10/12] Address review: add deprecated-removed directive regarding the removal of the mpdecimal sources Co-authored-by: Zachary Ware --- Doc/using/configure.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/using/configure.rst b/Doc/using/configure.rst index 20b4fb3c030e33..d30356d2058eff 100644 --- a/Doc/using/configure.rst +++ b/Doc/using/configure.rst @@ -812,6 +812,10 @@ Libraries options .. versionchanged:: 3.13 Default to using the installed ``mpdecimal`` library. + .. deprecated-removed:: 3.13 3.15 + A copy of the ``mpdecimal`` library sources will no longer be distributed + with Python 3.15. + .. seealso:: :option:`LIBMPDEC_CFLAGS` and :option:`LIBMPDEC_LIBS`. .. option:: --with-readline=readline|editline From c84f2b7105ca29c4a40c0ac8eb0db1fae8ebf553 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 6 May 2024 10:18:02 +0200 Subject: [PATCH 11/12] Add libmpdec-dev to CI deps, remove CI hack, and enforce mpdecimal version check in configure --- .github/workflows/build.yml | 11 ++-- .github/workflows/posix-deps-apt.sh | 1 + configure | 78 ++++++++--------------------- configure.ac | 16 ++++-- 4 files changed, 39 insertions(+), 67 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8111951637f003..299c02e0944d42 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -232,8 +232,7 @@ jobs: ../cpython-ro-srcdir/configure \ --config-cache \ --with-pydebug \ - --with-openssl=$OPENSSL_DIR \ - --with-system-libmpdec=no + --with-openssl=$OPENSSL_DIR build_ubuntu_free_threading: name: 'Ubuntu (free-threading)' @@ -247,8 +246,7 @@ jobs: --config-cache \ --with-pydebug \ --with-openssl=$OPENSSL_DIR \ - --disable-gil \ - --with-system-libmpdec=no + --disable-gil build_ubuntu_ssltests: name: 'Ubuntu SSL tests with OpenSSL' @@ -373,8 +371,7 @@ jobs: ../cpython-ro-srcdir/configure \ --config-cache \ --with-pydebug \ - --with-openssl=$OPENSSL_DIR \ - --with-system-libmpdec=no + --with-openssl=$OPENSSL_DIR - name: Build CPython out-of-tree working-directory: ${{ env.CPYTHON_BUILDDIR }} run: make -j4 @@ -480,7 +477,7 @@ jobs: save: ${{ github.event_name == 'push' }} max-size: "200M" - name: Configure CPython - run: ./configure --config-cache --with-address-sanitizer --without-pymalloc --with-system-libmpdec=no + run: ./configure --config-cache --with-address-sanitizer --without-pymalloc - name: Build CPython run: make -j4 - name: Display build info diff --git a/.github/workflows/posix-deps-apt.sh b/.github/workflows/posix-deps-apt.sh index 0800401f4cd113..fb485bd4f82bd2 100755 --- a/.github/workflows/posix-deps-apt.sh +++ b/.github/workflows/posix-deps-apt.sh @@ -15,6 +15,7 @@ apt-get -yq install \ libgdbm-dev \ libgdbm-compat-dev \ liblzma-dev \ + libmpdec-dev \ libncurses5-dev \ libreadline6-dev \ libsqlite3-dev \ diff --git a/configure b/configure index 50280d3cbef47b..36296f8e385ecf 100755 --- a/configure +++ b/configure @@ -14622,19 +14622,19 @@ if test "x$with_system_libmpdec" = xyes then : pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libmpdec" >&5 -printf %s "checking for libmpdec... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libmpdec >= 2.5.0" >&5 +printf %s "checking for libmpdec >= 2.5.0... " >&6; } if test -n "$LIBMPDEC_CFLAGS"; then pkg_cv_LIBMPDEC_CFLAGS="$LIBMPDEC_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libmpdec\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libmpdec") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libmpdec >= 2.5.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libmpdec >= 2.5.0") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_LIBMPDEC_CFLAGS=`$PKG_CONFIG --cflags "libmpdec" 2>/dev/null` + pkg_cv_LIBMPDEC_CFLAGS=`$PKG_CONFIG --cflags "libmpdec >= 2.5.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -14646,12 +14646,12 @@ if test -n "$LIBMPDEC_LIBS"; then pkg_cv_LIBMPDEC_LIBS="$LIBMPDEC_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libmpdec\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libmpdec") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libmpdec >= 2.5.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libmpdec >= 2.5.0") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_LIBMPDEC_LIBS=`$PKG_CONFIG --libs "libmpdec" 2>/dev/null` + pkg_cv_LIBMPDEC_LIBS=`$PKG_CONFIG --libs "libmpdec >= 2.5.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -14672,9 +14672,9 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - LIBMPDEC_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libmpdec" 2>&1` + LIBMPDEC_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libmpdec >= 2.5.0" 2>&1` else - LIBMPDEC_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libmpdec" 2>&1` + LIBMPDEC_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libmpdec >= 2.5.0" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$LIBMPDEC_PKG_ERRORS" >&5 @@ -14711,66 +14711,32 @@ save_LIBS=$LIBS CPPFLAGS="$LIBMPDEC_CFLAGS $CPPFLAGS" LDFLAGS="$LIBMPDEC_LIBS $LDFLAGS" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing mpd_version" >&5 -printf %s "checking for library containing mpd_version... " >&6; } -if test ${ac_cv_search_mpd_version+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char mpd_version (); + + #include + #if MPD_VERSION_HEX < 0x02050000 + # error "mpdecimal 2.5.0 or higher required" + #endif + int main (void) { -return mpd_version (); +void *x = mpd_version; ; return 0; } _ACEOF -for ac_lib in '' mpdec -do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO" -then : - ac_cv_search_mpd_version=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext - if test ${ac_cv_search_mpd_version+y} -then : - break -fi -done -if test ${ac_cv_search_mpd_version+y} -then : - -else $as_nop - ac_cv_search_mpd_version=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_mpd_version" >&5 -printf "%s\n" "$ac_cv_search_mpd_version" >&6; } -ac_res=$ac_cv_search_mpd_version -if test "$ac_res" != no +if ac_fn_c_try_link "$LINENO" then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" have_mpdec=yes else $as_nop have_mpdec=no fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext CFLAGS=$save_CFLAGS CPPFLAGS=$save_CPPFLAGS diff --git a/configure.ac b/configure.ac index 3582ddb1dd12e1..e992a754346b8a 100644 --- a/configure.ac +++ b/configure.ac @@ -3983,7 +3983,7 @@ AC_MSG_RESULT([$with_system_libmpdec]) AS_VAR_IF( [with_system_libmpdec], [yes], [PKG_CHECK_MODULES( - [LIBMPDEC], [libmpdec], [], + [LIBMPDEC], [libmpdec >= 2.5.0], [], [LIBMPDEC_CFLAGS=${LIBMPDEC_CFLAGS-""} LIBMPDEC_LIBS=${LIBMPDEC_LIBS-"-lmpdec -lm"} LIBMPDEC_INTERNAL=])], @@ -3995,9 +3995,17 @@ AS_VAR_IF([with_system_libmpdec], [yes], [WITH_SAVE_ENV([ CPPFLAGS="$LIBMPDEC_CFLAGS $CPPFLAGS" LDFLAGS="$LIBMPDEC_LIBS $LDFLAGS" - AC_SEARCH_LIBS( - [mpd_version], [mpdec], - [have_mpdec=yes], [have_mpdec=no])])], + + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([ + #include + #if MPD_VERSION_HEX < 0x02050000 + # error "mpdecimal 2.5.0 or higher required" + #endif + ], [void *x = mpd_version;])], + [have_mpdec=yes], + [have_mpdec=no]) + ])], [AS_VAR_SET([have_mpdec], [yes]) AC_MSG_WARN([m4_normalize([ the bundled copy of libmpdecimal is scheduled for removal in Python 3.15; From 1016f0da1319d447d56a6e9e0d7473e789219d65 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 6 May 2024 11:11:31 +0200 Subject: [PATCH 12/12] Make the mpdec link check more accurate, and use LIBS iso. LDFLAGS --- configure | 4 ++-- configure.ac | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 36296f8e385ecf..de426e6b686e68 100755 --- a/configure +++ b/configure @@ -14710,7 +14710,7 @@ save_LIBS=$LIBS CPPFLAGS="$LIBMPDEC_CFLAGS $CPPFLAGS" - LDFLAGS="$LIBMPDEC_LIBS $LDFLAGS" + LIBS="$LIBMPDEC_LIBS $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -14724,7 +14724,7 @@ save_LIBS=$LIBS int main (void) { -void *x = mpd_version; +const char *x = mpd_version(); ; return 0; } diff --git a/configure.ac b/configure.ac index e992a754346b8a..8eb96767487592 100644 --- a/configure.ac +++ b/configure.ac @@ -3994,7 +3994,7 @@ AS_VAR_IF( AS_VAR_IF([with_system_libmpdec], [yes], [WITH_SAVE_ENV([ CPPFLAGS="$LIBMPDEC_CFLAGS $CPPFLAGS" - LDFLAGS="$LIBMPDEC_LIBS $LDFLAGS" + LIBS="$LIBMPDEC_LIBS $LIBS" AC_LINK_IFELSE([ AC_LANG_PROGRAM([ @@ -4002,7 +4002,7 @@ AS_VAR_IF([with_system_libmpdec], [yes], #if MPD_VERSION_HEX < 0x02050000 # error "mpdecimal 2.5.0 or higher required" #endif - ], [void *x = mpd_version;])], + ], [const char *x = mpd_version();])], [have_mpdec=yes], [have_mpdec=no]) ])],