Skip to content

Commit 8d19cea

Browse files
committed
Attempt to fix endian test for Emscripten.
1 parent aef5f84 commit 8d19cea

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

Tools/configure/pyconf.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2886,10 +2886,20 @@ def ax_c_float_words_bigendian(
28862886
if callable(on_unknown):
28872887
on_unknown()
28882888
return
2889-
# Read the linked binary and look for the marker strings.
2890-
try:
2891-
data = open(exe_path, "rb").read()
2892-
except OSError:
2889+
# Read all conftest* output files and look for the marker strings.
2890+
# Autoconf uses "grep noonsees conftest*" which globs all outputs;
2891+
# this is important for Emscripten where the compiler may produce
2892+
# conftest.js + conftest.wasm instead of a single conftest binary.
2893+
data = b""
2894+
for name in os.listdir(tmp):
2895+
if not name.startswith("conftest") or name == "conftest.c":
2896+
continue
2897+
path = os.path.join(tmp, name)
2898+
try:
2899+
data += open(path, "rb").read()
2900+
except OSError:
2901+
pass
2902+
if not data:
28932903
if callable(on_unknown):
28942904
on_unknown()
28952905
return

Tools/configure/transpiler/pyconf.awk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,13 +2027,13 @@ function pyconf_ax_c_float_words_bigendian(on_big, on_little, on_unknown, src, c
20272027
cmd = cmd V["CC"] " " V["CPPFLAGS"] " " V["CFLAGS"] " " V["LDFLAGS"] " " conftest " -o " exe " " V["LIBS"] " 2>/dev/null"
20282028
rc = system(cmd)
20292029
if (rc != 0) {
2030-
system("rm -f " conftest " " exe)
2030+
system("rm -f " _pyconf_tmpdir "/conftest*")
20312031
_pyconf_retval = "unknown"
20322032
return
20332033
}
2034-
has_big = (system("grep -c noonsees " exe " >/dev/null 2>&1") == 0)
2035-
has_little = (system("grep -c seesnoon " exe " >/dev/null 2>&1") == 0)
2036-
system("rm -f " conftest " " exe)
2034+
has_big = (system("grep -c noonsees " _pyconf_tmpdir "/conftest* >/dev/null 2>&1") == 0)
2035+
has_little = (system("grep -c seesnoon " _pyconf_tmpdir "/conftest* >/dev/null 2>&1") == 0)
2036+
system("rm -f " _pyconf_tmpdir "/conftest*")
20372037
if (has_big && !has_little)
20382038
_pyconf_retval = "big"
20392039
else if (has_little && !has_big)

0 commit comments

Comments
 (0)