Skip to content

Commit 9dd3add

Browse files
[3.13] gh-89640: harden float word ordering (#125571 and #126387) (#126429)
Properly detect float word ordering on Linux (gh-125571) autoconf-archive patch by Dan Amelang. (cherry picked from commit 26d6277) Hardcode WASM float word ordering to little endian (gh-126387) (cherry picked from commit 532fc08)
1 parent 88e0131 commit 9dd3add

File tree

8 files changed

+114
-66
lines changed

8 files changed

+114
-66
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
# reproducible: to get the same tools versions (autoconf, aclocal, ...)
9090
runs-on: ubuntu-24.04
9191
container:
92-
image: ghcr.io/python/autoconf:2024.10.11.11293396815
92+
image: ghcr.io/python/autoconf:2024.10.16.11360930377
9393
timeout-minutes: 60
9494
needs: check_source
9595
if: needs.check_source.outputs.run_tests == 'true'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Improve detection of float word ordering on Linux when link-time optimizations
2+
are enabled.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hard-code float word ordering as little endian on WASM.

Tools/build/regen-configure.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -e -x
55
# The check_autoconf_regen job of .github/workflows/build.yml must kept in
66
# sync with this script. Use the same container image than the job so the job
77
# doesn't need to run autoreconf in a container.
8-
IMAGE="ghcr.io/python/autoconf:2024.10.06.11200919239"
8+
IMAGE="ghcr.io/python/autoconf:2024.10.16.11360930377"
99
AUTORECONF="autoreconf -ivf -Werror"
1010

1111
WORK_DIR="/src"

aclocal.m4

Lines changed: 55 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure

Lines changed: 34 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5856,28 +5856,26 @@ AS_VAR_IF([ac_cv_gcc_asm_for_x64], [yes], [
58565856
# * Check for various properties of floating point *
58575857
# **************************************************
58585858

5859-
AX_C_FLOAT_WORDS_BIGENDIAN
5860-
if test "$ax_cv_c_float_words_bigendian" = "yes"
5861-
then
5862-
AC_DEFINE([DOUBLE_IS_BIG_ENDIAN_IEEE754], [1],
5863-
[Define if C doubles are 64-bit IEEE 754 binary format, stored
5864-
with the most significant byte first])
5865-
elif test "$ax_cv_c_float_words_bigendian" = "no"
5866-
then
5867-
AC_DEFINE([DOUBLE_IS_LITTLE_ENDIAN_IEEE754], [1],
5868-
[Define if C doubles are 64-bit IEEE 754 binary format, stored
5869-
with the least significant byte first])
5870-
else
5871-
# Some ARM platforms use a mixed-endian representation for doubles.
5872-
# While Python doesn't currently have full support for these platforms
5873-
# (see e.g., issue 1762561), we can at least make sure that float <-> string
5874-
# conversions work.
5875-
# FLOAT_WORDS_BIGENDIAN doesn't actually detect this case, but if it's not big
5876-
# or little, then it must be this?
5877-
AC_DEFINE([DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754], [1],
5878-
[Define if C doubles are 64-bit IEEE 754 binary format, stored
5879-
in ARM mixed-endian order (byte order 45670123)])
5880-
fi
5859+
AX_C_FLOAT_WORDS_BIGENDIAN(
5860+
[AC_DEFINE([DOUBLE_IS_BIG_ENDIAN_IEEE754], [1],
5861+
[Define if C doubles are 64-bit IEEE 754 binary format,
5862+
stored with the most significant byte first])],
5863+
[AC_DEFINE([DOUBLE_IS_LITTLE_ENDIAN_IEEE754], [1],
5864+
[Define if C doubles are 64-bit IEEE 754 binary format,
5865+
stored with the least significant byte first])],
5866+
[AS_CASE([$host_cpu],
5867+
[*arm*], [# Some ARM platforms use a mixed-endian representation for
5868+
# doubles. While Python doesn't currently have full support
5869+
# for these platforms (see e.g., issue 1762561), we can at
5870+
# least make sure that float <-> string conversions work.
5871+
# FLOAT_WORDS_BIGENDIAN doesn't actually detect this case,
5872+
# but if it's not big or little, then it must be this?
5873+
AC_DEFINE([DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754], [1],
5874+
[Define if C doubles are 64-bit IEEE 754 binary format,
5875+
stored in ARM mixed-endian order (byte order 45670123)])],
5876+
[wasm*], [AC_DEFINE([DOUBLE_IS_LITTLE_ENDIAN_IEEE754], [1],
5877+
[Define if C doubles are 64-bit IEEE 754 binary format,
5878+
stored with the least significant byte first])])])
58815879

58825880
# The short float repr introduced in Python 3.1 requires the
58835881
# correctly-rounded string <-> double conversion functions from

pyconfig.h.in

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@
4747
/* Define if --enable-ipv6 is specified */
4848
#undef ENABLE_IPV6
4949

50-
/* Define to 1 if your system stores words within floats with the most
51-
significant word first */
52-
#undef FLOAT_WORDS_BIGENDIAN
53-
5450
/* Define if getpgrp() must be called as getpgrp(0). */
5551
#undef GETPGRP_HAVE_ARG
5652

0 commit comments

Comments
 (0)