Skip to content

Commit 6936396

Browse files
committedAug 1, 2022
CMake: pass --experimental-wasm-simd to Node.js < 17 in corrade_add_test().
Snce version 15 Node.js ships with V8 8.6, which contains also the remaining bitmask instructions, so from that version onwards there should be no harm from having SIMD enabled. Older versions have SIMD incomplete, meaning general code won't really run anyway, independently of the flag being set or not.
1 parent d15c2ea commit 6936396

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed
 

‎modules/UseCorrade.cmake

+16-1
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,22 @@ function(corrade_add_test test_name)
450450
set_property(TARGET ${test_name} APPEND_STRING PROPERTY COMPILE_FLAGS " -s DISABLE_EXCEPTION_CATCHING=0")
451451
set_property(TARGET ${test_name} APPEND_STRING PROPERTY LINK_FLAGS " -s DISABLE_EXCEPTION_CATCHING=0")
452452
find_package(NodeJs REQUIRED)
453-
add_test(NAME ${test_name} COMMAND NodeJs::NodeJs $<TARGET_FILE:${test_name}> ${arguments})
453+
# Node.js before version 17 needs --experimental-wasm-simd. Version
454+
# 17 upgraded to V8 9.1, which has the option enabled by default:
455+
# https://github.com/nodejs/node/commit/a7cbf19a82c75e9a65e90fb8ba4947e2fc52ef39
456+
# Since the code defining these flags explicitly says "remove once
457+
# they hit stable":
458+
# https://github.com/v8/v8/blob/ba8ad5dd17ea85c856c09c2ff603641487d1f0ca/src/wasm/wasm-feature-flags.h#L101-L109
459+
# even though it causes numberous issues such as:
460+
# https://github.com/nodejs/node/issues/43592
461+
# I'm future-proofing and not setting it for version 17+. From the
462+
# other side, the flag goes back to ancient version 6 (2017), so it
463+
# should be no problem to just pass it there always:
464+
# https://github.com/v8/v8/commit/45618a9ab5cc98a5de200b0116670e8c272f0c5f
465+
if(NodeJS_VERSION VERSION_LESS 17)
466+
set(experimental_wasm_simd --experimental-wasm-simd)
467+
endif()
468+
add_test(NAME ${test_name} COMMAND NodeJs::NodeJs ${experimental_wasm_simd} $<TARGET_FILE:${test_name}> ${arguments})
454469

455470
# Embed all files
456471
foreach(file ${files})

0 commit comments

Comments
 (0)
Please sign in to comment.