https://github.com/python/cpython/commit/025cc26b406f017505dbed8af7820106d1ff2885
commit: 025cc26b406f017505dbed8af7820106d1ff2885
branch: main
author: stratakis <[email protected]>
committer: vstinner <[email protected]>
date: 2026-06-02T11:43:30+02:00
summary:
gh-115119: Fix libmpdec detection when pkg-config files are missing (#150502)
The fallback for systems with no mpdecimal .pc files used AC_LINK_IFELSE
directly, which relied on LIBMPDEC_LIBS being set. On failure this was empty
so the link test ran without -lmpdec.
Use AC_CHECK_HEADER and AC_CHECK_LIB instead.
files:
A Misc/NEWS.d/next/Build/2026-05-27-14-28-36.gh-issue-115119.wotFWh.rst
M configure
M configure.ac
diff --git
a/Misc/NEWS.d/next/Build/2026-05-27-14-28-36.gh-issue-115119.wotFWh.rst
b/Misc/NEWS.d/next/Build/2026-05-27-14-28-36.gh-issue-115119.wotFWh.rst
new file mode 100644
index 000000000000000..04fdf3617f0cdef
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2026-05-27-14-28-36.gh-issue-115119.wotFWh.rst
@@ -0,0 +1 @@
+Fix the detection of libmpdec header when no .pc files are available.
diff --git a/configure b/configure
index 94735c8d018a1f7..eb53b200bf78bc5 100755
--- a/configure
+++ b/configure
@@ -16487,33 +16487,93 @@ save_LIBS=$LIBS
CPPFLAGS="$CPPFLAGS $LIBMPDEC_CFLAGS"
LIBS="$LIBS $LIBMPDEC_LIBS"
+ ac_fn_c_check_header_compile "$LINENO" "mpdecimal.h"
"ac_cv_header_mpdecimal_h" "$ac_includes_default"
+if test "x$ac_cv_header_mpdecimal_h" = xyes
+then :
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for mpd_version
in -lmpdec" >&5
+printf %s "checking for mpd_version in -lmpdec... " >&6; }
+if test ${ac_cv_lib_mpdec_mpd_version+y}
+then :
+ printf %s "(cached) " >&6
+else case e in #(
+ e) ac_check_lib_save_LIBS=$LIBS
+LIBS="-lmpdec $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.
+ The 'extern "C"' is for builds by C++ compilers;
+ although this is not generally supported in C code supporting it here
+ has little cost and some practical benefit (sr 110532). */
+#ifdef __cplusplus
+extern "C"
+#endif
+char mpd_version (void);
+int
+main (void)
+{
+return mpd_version ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+ ac_cv_lib_mpdec_mpd_version=yes
+else case e in #(
+ e) ac_cv_lib_mpdec_mpd_version=no ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS ;;
+esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result:
$ac_cv_lib_mpdec_mpd_version" >&5
+printf "%s\n" "$ac_cv_lib_mpdec_mpd_version" >&6; }
+if test "x$ac_cv_lib_mpdec_mpd_version" = xyes
+then :
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
- #include <mpdecimal.h>
- #if MPD_VERSION_HEX < 0x02050000
- # error "mpdecimal 2.5.0 or higher required"
- #endif
+
+ #include <mpdecimal.h>
+ #if MPD_VERSION_HEX < 0x02050000
+ # error "mpdecimal 2.5.0 or higher required"
+ #endif
int
main (void)
{
-const char *x = mpd_version();
+
;
return 0;
}
_ACEOF
-if ac_fn_c_try_link "$LINENO"
+if ac_fn_c_try_compile "$LINENO"
then :
have_mpdec=yes
else case e in #(
e) have_mpdec=no ;;
esac
fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam \
- conftest$ac_exeext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+
+else case e in #(
+ e) have_mpdec=no ;;
+esac
+fi
+
+
+else case e in #(
+ e) have_mpdec=no ;;
+esac
+fi
+
if test "x$have_mpdec" = xyes
then :
@@ -16542,33 +16602,93 @@ save_LIBS=$LIBS
CPPFLAGS="$CPPFLAGS $LIBMPDEC_CFLAGS"
LIBS="$LIBS $LIBMPDEC_LIBS"
+ ac_fn_c_check_header_compile "$LINENO" "mpdecimal.h"
"ac_cv_header_mpdecimal_h" "$ac_includes_default"
+if test "x$ac_cv_header_mpdecimal_h" = xyes
+then :
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for mpd_version
in -lmpdec" >&5
+printf %s "checking for mpd_version in -lmpdec... " >&6; }
+if test ${ac_cv_lib_mpdec_mpd_version+y}
+then :
+ printf %s "(cached) " >&6
+else case e in #(
+ e) ac_check_lib_save_LIBS=$LIBS
+LIBS="-lmpdec $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.
+ The 'extern "C"' is for builds by C++ compilers;
+ although this is not generally supported in C code supporting it here
+ has little cost and some practical benefit (sr 110532). */
+#ifdef __cplusplus
+extern "C"
+#endif
+char mpd_version (void);
+int
+main (void)
+{
+return mpd_version ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+ ac_cv_lib_mpdec_mpd_version=yes
+else case e in #(
+ e) ac_cv_lib_mpdec_mpd_version=no ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS ;;
+esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result:
$ac_cv_lib_mpdec_mpd_version" >&5
+printf "%s\n" "$ac_cv_lib_mpdec_mpd_version" >&6; }
+if test "x$ac_cv_lib_mpdec_mpd_version" = xyes
+then :
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
- #include <mpdecimal.h>
- #if MPD_VERSION_HEX < 0x02050000
- # error "mpdecimal 2.5.0 or higher required"
- #endif
+
+ #include <mpdecimal.h>
+ #if MPD_VERSION_HEX < 0x02050000
+ # error "mpdecimal 2.5.0 or higher required"
+ #endif
int
main (void)
{
-const char *x = mpd_version();
+
;
return 0;
}
_ACEOF
-if ac_fn_c_try_link "$LINENO"
+if ac_fn_c_try_compile "$LINENO"
then :
have_mpdec=yes
else case e in #(
e) have_mpdec=no ;;
esac
fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam \
- conftest$ac_exeext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+
+else case e in #(
+ e) have_mpdec=no ;;
+esac
+fi
+
+
+else case e in #(
+ e) have_mpdec=no ;;
+esac
+fi
+
if test "x$have_mpdec" = xyes
then :
diff --git a/configure.ac b/configure.ac
index 9192211c7c1871d..b2f3f7210050693 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4380,16 +4380,19 @@ PKG_CHECK_MODULES([LIBMPDEC], [libmpdec >= 2.5.0],
[have_mpdec=yes], [
WITH_SAVE_ENV([
CPPFLAGS="$CPPFLAGS $LIBMPDEC_CFLAGS"
LIBS="$LIBS $LIBMPDEC_LIBS"
-
- AC_LINK_IFELSE([
- AC_LANG_PROGRAM([
- #include <mpdecimal.h>
- #if MPD_VERSION_HEX < 0x02050000
- # error "mpdecimal 2.5.0 or higher required"
- #endif
- ], [const char *x = mpd_version();])],
- [have_mpdec=yes],
- [have_mpdec=no])
+ AC_CHECK_HEADER([mpdecimal.h], [
+ AC_CHECK_LIB([mpdec], [mpd_version], [
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #include <mpdecimal.h>
+ #if MPD_VERSION_HEX < 0x02050000
+ # error "mpdecimal 2.5.0 or higher required"
+ #endif
+ ], [])],
+ [have_mpdec=yes],
+ [have_mpdec=no])
+ ], [have_mpdec=no])
+ ], [have_mpdec=no])
AS_VAR_IF([have_mpdec], [yes], [
LIBMPDEC_CFLAGS=${LIBMPDEC_CFLAGS-""}
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]