Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-89640: Hardcode WASM float word ordering as little endian #126387

Merged

Conversation

erlend-aasland
Copy link
Contributor

@erlend-aasland erlend-aasland commented Nov 4, 2024

@erlend-aasland
Copy link
Contributor Author

cc. @hoodmane

@erlend-aasland erlend-aasland linked an issue Nov 4, 2024 that may be closed by this pull request
@erlend-aasland erlend-aasland changed the title gh-89640: Hardcode Emscripten float word ordering gh-89640: Hardcode WASM float word ordering as little endian Nov 4, 2024
@hoodmane
Copy link
Contributor

hoodmane commented Nov 4, 2024

Thanks for the help @erlend-aasland!

@rruuaanng

This comment was marked as spam.

@hoodmane
Copy link
Contributor

hoodmane commented Nov 4, 2024

Any compliant implementation of webassembly is little endian:
https://webassembly.github.io/spec/core/binary/values.html#floating-point

I think that if someone forked the spec and invented "big endian wasm" but still called the target wasm32-???-??? that would be met with a lot of hostility by the webassembly folks. Only wasm32-emscripten should ever hit this branch though, so it might be a tiny bit better to match [*emscripten*] and then we'll find out if AX_C_FLOAT_WORDS_BIGENDIAN ever started failing to detect wasi correctly, however unlikely that might be.

If for some reason we don't want to hard code Emscripten, there is an option here:
autoconf-archive/autoconf-archive#316

@erlend-aasland erlend-aasland merged commit 532fc08 into python:main Nov 4, 2024
43 checks passed
@erlend-aasland erlend-aasland deleted the autoconf/emscripten-workaround branch November 4, 2024 20:48
erlend-aasland added a commit to erlend-aasland/cpython that referenced this pull request Nov 5, 2024
…ython#126387)

Properly detect float word ordering on Linux (pythongh-125571)

autoconf-archive patch by Dan Amelang.

(cherry picked from commit 26d6277)

Hardcode WASM float word ordering to little endian (pythongh-126387)

(cherry picked from commit 532fc08)
erlend-aasland added a commit that referenced this pull request Nov 5, 2024
…26429)

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)
erlend-aasland added a commit that referenced this pull request Nov 5, 2024
…26430)

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)
@hoodmane
Copy link
Contributor

hoodmane commented Nov 8, 2024

One effect that this change had is that it will no longer raise the error:

Unknown float word ordering. You need to manually preset
ax_cv_c_float_words_bigendian=no (or yes) according to your system.

if the float word order does not match arm or wasm and AX_C_FLOAT_WORDS_BIGENDIAN returns undefined. I think we should consider doing this:

--- a/configure.ac
+++ b/configure.ac
@@ -5920,7 +5920,15 @@ AX_C_FLOAT_WORDS_BIGENDIAN(
                                 stored in ARM mixed-endian order (byte order 45670123)])],
            [wasm*], [AC_DEFINE([DOUBLE_IS_LITTLE_ENDIAN_IEEE754], [1],
                                [Define if C doubles are 64-bit IEEE 754 binary format,
-                                stored with the least significant byte first])])])
+                                stored with the least significant byte first])],
+           AC_MSG_ERROR[([
+
+Unknown float word ordering. You need to manually preset
+ax_cv_c_float_words_bigendian=no (or yes) according to your system.
+
+           ])]
+  )]
+)
 
 # The short float repr introduced in Python 3.1 requires the
 # correctly-rounded string <-> double conversion functions from

hoodmane added a commit to hoodmane/cpython that referenced this pull request Nov 8, 2024
…float word order

Before python#126387, if we didn't detect float word order we'd raise the following
configure error:
```
Unknown float word ordering. You need to manually preset
ax_cv_c_float_words_bigendian=no (or yes) according to your system.
```
This puts it back (except for host_cpu arm or wasm).
hoodmane added a commit to hoodmane/cpython that referenced this pull request Nov 8, 2024
…float word order

Before python#126387, if we didn't detect float word order we'd raise the following
configure error:
```
Unknown float word ordering. You need to manually preset
ax_cv_c_float_words_bigendian=no (or yes) according to your system.
```
This puts it back (except for host_cpu arm or wasm).
@erlend-aasland
Copy link
Contributor Author

erlend-aasland commented Nov 8, 2024

Good catch, @hoodmane! Yes, indeed we should. Would you like to propose a PR? I noticed you already did :)

erlend-aasland pushed a commit that referenced this pull request Nov 8, 2024
…word order (#126569)

Before #126387, if we didn't detect float word order we'd raise the following
configure error:

    Unknown float word ordering. You need to manually preset
    ax_cv_c_float_words_bigendian=no (or yes) according to your system.

This puts it back (except for ARM or WASM, which as hardcoded).
hoodmane added a commit to hoodmane/cpython-devcontainers that referenced this pull request Nov 11, 2024
The original patch:
autoconf-archive/autoconf-archive#279
broke endianness detection on Emscripten. This was fixed in this followup:
autoconf-archive/autoconf-archive#316

We also have worked around the problem by adjusting `configure.ac` in the Python
repo to handle this case:
python/cpython#126387
But it's useful for us to use the upstream autoconf-archive detection so that we
can be completely sure that the fix works in practice.
picnixz pushed a commit to picnixz/cpython that referenced this pull request Dec 8, 2024
…float word order (python#126569)

Before python#126387, if we didn't detect float word order we'd raise the following
configure error:

    Unknown float word ordering. You need to manually preset
    ax_cv_c_float_words_bigendian=no (or yes) according to your system.

This puts it back (except for ARM or WASM, which as hardcoded).
ebonnal pushed a commit to ebonnal/cpython that referenced this pull request Jan 12, 2025
…float word order (python#126569)

Before python#126387, if we didn't detect float word order we'd raise the following
configure error:

    Unknown float word ordering. You need to manually preset
    ax_cv_c_float_words_bigendian=no (or yes) according to your system.

This puts it back (except for ARM or WASM, which as hardcoded).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

configure script cannot detect float word ordering on linux
4 participants