Skip to content

Commit 5c9a00c

Browse files
authored
Add bigendian test suite (#25068)
This PR adds a new `bigendian0` test suite that can be used to verify big endian compilation support.
1 parent fe2e532 commit 5c9a00c

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/test_core.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ def decorated(self, textdecoder, *args, **kwargs):
400400
no_safe_heap = make_no_decorator_for_setting('SAFE_HEAP')
401401
no_strict = make_no_decorator_for_setting('STRICT')
402402
no_strict_js = make_no_decorator_for_setting('STRICT_JS')
403+
no_big_endian = make_no_decorator_for_setting('SUPPORT_BIG_ENDIAN')
403404

404405

405406
def is_sanitizing(args):
@@ -6629,6 +6630,7 @@ def test_neon_wasm_simd(self):
66296630
'': ([],),
66306631
'nontrapping': (['-mnontrapping-fptoint'],),
66316632
})
6633+
@no_big_endian('SIMD support is currently not compatible with big endian')
66326634
def test_sse1(self, args):
66336635
src = test_file('sse/test_sse1.cpp')
66346636
self.run_process([shared.CLANG_CXX, src, '-msse', '-o', 'test_sse1', '-D_CRT_SECURE_NO_WARNINGS=1'] + clang_native.get_clang_native_args(), stdout=PIPE)
@@ -6649,6 +6651,7 @@ def test_sse1(self, args):
66496651
'': ([],),
66506652
'nontrapping': (['-mnontrapping-fptoint'],),
66516653
})
6654+
@no_big_endian('SIMD support is currently not compatible with big endian')
66526655
def test_sse2(self, args):
66536656
src = test_file('sse/test_sse2.cpp')
66546657
self.run_process([shared.CLANG_CXX, src, '-msse2', '-Wno-argument-outside-range', '-o', 'test_sse2', '-D_CRT_SECURE_NO_WARNINGS=1'] + clang_native.get_clang_native_args(), stdout=PIPE)
@@ -6662,6 +6665,7 @@ def test_sse2(self, args):
66626665
@wasm_simd
66636666
@requires_native_clang
66646667
@requires_x64_cpu
6668+
@no_big_endian('SIMD support is currently not compatible with big endian')
66656669
def test_sse3(self):
66666670
src = test_file('sse/test_sse3.cpp')
66676671
self.run_process([shared.CLANG_CXX, src, '-msse3', '-Wno-argument-outside-range', '-o', 'test_sse3', '-D_CRT_SECURE_NO_WARNINGS=1'] + clang_native.get_clang_native_args(), stdout=PIPE)
@@ -6675,6 +6679,7 @@ def test_sse3(self):
66756679
@wasm_simd
66766680
@requires_native_clang
66776681
@requires_x64_cpu
6682+
@no_big_endian('SIMD support is currently not compatible with big endian')
66786683
def test_ssse3(self):
66796684
src = test_file('sse/test_ssse3.cpp')
66806685
self.run_process([shared.CLANG_CXX, src, '-mssse3', '-Wno-argument-outside-range', '-o', 'test_ssse3', '-D_CRT_SECURE_NO_WARNINGS=1'] + clang_native.get_clang_native_args(), stdout=PIPE)
@@ -6690,6 +6695,7 @@ def test_ssse3(self):
66906695
@requires_native_clang
66916696
@requires_x64_cpu
66926697
@is_slow_test
6698+
@no_big_endian('SIMD support is currently not compatible with big endian')
66936699
def test_sse4_1(self):
66946700
src = test_file('sse/test_sse4_1.cpp')
66956701
# Run with inlining disabled to avoid slow LLVM behavior with lots of macro expanded loops inside a function body.
@@ -6708,6 +6714,7 @@ def test_sse4_1(self):
67086714
'': (False,),
67096715
'2': (True,),
67106716
})
6717+
@no_big_endian('SIMD support is currently not compatible with big endian')
67116718
def test_sse4(self, use_4_2):
67126719
msse4 = '-msse4.2' if use_4_2 else '-msse4'
67136720
src = test_file('sse/test_sse4_2.cpp')
@@ -6729,6 +6736,7 @@ def test_sse4(self, use_4_2):
67296736
'': ([],),
67306737
'nontrapping': (['-mnontrapping-fptoint'],),
67316738
})
6739+
@no_big_endian('SIMD support is currently not compatible with big endian')
67326740
def test_avx(self, args):
67336741
src = test_file('sse/test_avx.cpp')
67346742
self.run_process([shared.CLANG_CXX, src, '-mavx', '-Wno-argument-outside-range', '-Wpedantic', '-o', 'test_avx', '-D_CRT_SECURE_NO_WARNINGS=1'] + clang_native.get_clang_native_args(), stdout=PIPE)
@@ -6749,6 +6757,7 @@ def test_avx(self, args):
67496757
'': ([],),
67506758
'nontrapping': (['-mnontrapping-fptoint'],),
67516759
})
6760+
@no_big_endian('SIMD support is currently not compatible with big endian')
67526761
def test_avx2(self, args):
67536762
src = test_file('sse/test_avx2.cpp')
67546763
self.run_process([shared.CLANG_CXX, src, '-mavx2', '-Wno-argument-outside-range', '-Wpedantic', '-o', 'test_avx2', '-D_CRT_SECURE_NO_WARNINGS=1'] + clang_native.get_clang_native_args(), stdout=PIPE)
@@ -10032,5 +10041,27 @@ def setUp(self):
1003210041
minimal0 = make_run('minimal0', cflags=['-g'], settings={'MINIMAL_RUNTIME': 1})
1003310042
llvmlibc = make_run('llvmlibc', cflags=['-lllvmlibc'])
1003410043

10044+
# To run the big endian test suite on a little endian Linux host:
10045+
# 1. sudo apt install -y qemu-user libc6-s390x-cross libstdc++6-s390x-cross
10046+
# 2. wget https://nodejs.org/dist/v22.16.0/node-v22.16.0-linux-s390x.tar.xz
10047+
# 3. tar xJf node-v22.14.0-linux-s390x.tar.xz
10048+
# 4. run a little endian emsdk install, e.g. `emsdk install sdk-main-64bit`
10049+
# 5. activate little endian emsdk install, e.g. `emsdk activate sdk-main-64bit`
10050+
# 6. modify the generated emsdk install: edit file .emscripten under emsdk/ root directory, and change the line
10051+
# NODE_JS = emsdk_path + '/node/22.16.0_64bit/bin/node'
10052+
# to point to big endian node:
10053+
# NODE_JS = ['qemu-s390x', '-L', '/usr/s390x-linux-gnu/', '/home/user/node-v22.16.0-linux-s390x/bin/node']
10054+
# 7. enter emsdk environment in current terminal with `source ./emsdk_env.sh`
10055+
# 8. modify EMSDK_NODE environment variable to also point to the big endian node:
10056+
# export EMSDK_NODE="qemu-s390x -L /usr/s390x-linux-gnu/ /home/user/node-v22.16.0-linux-s390x/bin/node"
10057+
# 9. run some tests in big endian mode: in Emscripten root directory, run
10058+
# `test/runner bigendian` to run all tests, or a single test with
10059+
# `test/runner bigendian.test_jslib_i64_params`
10060+
10061+
# The above test scheme has a small quirk that it will also use the Big Endian version of node.js for internal
10062+
# Emscripten compilation. At a quick test, this actually worked, so maybe this would be fine for this test harness.
10063+
# Alternatively, we would want to find a way to separate compiler node from runtime node somehow in the harness.
10064+
bigendian0 = make_run('bigendian0', cflags=['-O0'], settings={'SUPPORT_BIG_ENDIAN': 1})
10065+
1003510066
# TestCoreBase is just a shape for the specific subclasses, we don't test it itself
1003610067
del TestCoreBase # noqa

0 commit comments

Comments
 (0)