Skip to content

Commit 3a29901

Browse files
committed
[emscripten] Drop -sWASM=0 variant build
There is now just one emscripten target called `binaryen_js`. The settings for these two targets were almost identical except for. 1. Some JS_OF_OCAML specific stuff which is kept for the new unified target. 2. `-sASSERTIONS` was being forced (See #2507). I dropped this in favor of doing a debug build in testing where this is enabled by default.
1 parent 23f7af1 commit 3a29901

File tree

6 files changed

+29
-86
lines changed

6 files changed

+29
-86
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ CMakeFiles
2929
/dist/
3030
/config.h
3131
/emcc-build
32+
/emcc-build-dbg
3233
compile_commands.json
3334
test/lit/lit.site.cfg.py
3435
CMakeUserPresets.json

CMakeLists.txt

Lines changed: 13 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -529,89 +529,42 @@ endif()
529529
# binaryen.js
530530
#
531531
# Note that we can't emit binaryen.js directly, as there is libbinaryen already
532-
# declared earlier, so we create binaryen_wasm/js.js, which must then be copied.
532+
# declared earlier, so we create binaryen_js.js, which must then be copied.
533533
if(EMSCRIPTEN)
534534
# binaryen.js WebAssembly variant
535-
add_executable(binaryen_wasm ${binaryen_SOURCES})
536-
target_link_libraries(binaryen_wasm PRIVATE binaryen)
537-
target_link_libraries(binaryen_wasm PRIVATE "-sFILESYSTEM")
538-
target_link_libraries(binaryen_wasm PRIVATE "-sEXPORT_NAME=Binaryen")
539-
target_link_libraries(binaryen_wasm PRIVATE "-sNODERAWFS=0")
540-
# Do not error on the repeated NODERAWFS argument
541-
target_link_libraries(binaryen_wasm PRIVATE "-Wno-unused-command-line-argument")
542-
# Emit a single file for convenience of people using binaryen.js as a library,
543-
# so they only need to distribute a single file.
544-
if(EMSCRIPTEN_ENABLE_SINGLE_FILE)
545-
target_link_libraries(binaryen_wasm PRIVATE "-sSINGLE_FILE")
546-
endif()
547-
target_link_libraries(binaryen_wasm PRIVATE "-sEXPORT_ES6")
548-
target_link_libraries(binaryen_wasm PRIVATE "-sEXPORTED_RUNTIME_METHODS=stringToUTF8OnStack,stringToAscii")
549-
target_link_libraries(binaryen_wasm PRIVATE "-sEXPORTED_FUNCTIONS=_malloc,_free")
550-
target_link_libraries(binaryen_wasm PRIVATE "--post-js=${CMAKE_CURRENT_SOURCE_DIR}/src/js/binaryen.js-post.js")
551-
target_link_libraries(binaryen_wasm PRIVATE "-msign-ext")
552-
target_link_libraries(binaryen_wasm PRIVATE "-mbulk-memory")
553-
target_link_libraries(binaryen_wasm PRIVATE optimized "--closure=1")
554-
# TODO: Fix closure warnings! (#5062)
555-
target_link_libraries(binaryen_wasm PRIVATE optimized "-Wno-error=closure")
556-
if (BYN_ENABLE_LTO)
557-
target_link_libraries(binaryen_wasm PRIVATE optimized "-flto")
558-
endif()
559-
target_link_libraries(binaryen_wasm PRIVATE debug "--profiling")
560-
# Avoid catching exit as that can confuse error reporting in Node,
561-
# see https://github.com/emscripten-core/emscripten/issues/17228
562-
target_link_libraries(binaryen_wasm PRIVATE "-sNODEJS_CATCH_EXIT=0")
563-
install(TARGETS binaryen_wasm DESTINATION ${CMAKE_INSTALL_BINDIR})
564-
565-
# binaryen.js JavaScript variant
566535
add_executable(binaryen_js ${binaryen_SOURCES})
567536
target_link_libraries(binaryen_js PRIVATE binaryen)
568-
target_link_libraries(binaryen_js PRIVATE "-sWASM=0")
569-
target_link_libraries(binaryen_js PRIVATE "-sWASM_ASYNC_COMPILATION=0")
570-
571-
if(${CMAKE_CXX_COMPILER_VERSION} STREQUAL "6.0.1")
572-
# only valid with fastcomp and WASM=0
573-
target_link_libraries(binaryen_js PRIVATE "-sELIMINATE_DUPLICATE_FUNCTIONS")
574-
endif()
575-
# Disabling filesystem and setting web environment for js_of_ocaml
576-
# so it doesn't try to detect the "node" environment
577-
if(JS_OF_OCAML)
578-
target_link_libraries(binaryen_js PRIVATE "-sFILESYSTEM=0")
579-
target_link_libraries(binaryen_js PRIVATE "-sENVIRONMENT=web,worker")
580-
else()
581-
target_link_libraries(binaryen_js PRIVATE "-sFILESYSTEM=1")
582-
endif()
537+
target_link_libraries(binaryen_js PRIVATE "-sFILESYSTEM")
538+
target_link_libraries(binaryen_js PRIVATE "-sEXPORT_NAME=Binaryen")
583539
target_link_libraries(binaryen_js PRIVATE "-sNODERAWFS=0")
584540
# Do not error on the repeated NODERAWFS argument
585541
target_link_libraries(binaryen_js PRIVATE "-Wno-unused-command-line-argument")
542+
# Emit a single file for convenience of people using binaryen.js as a library,
543+
# so they only need to distribute a single file.
586544
if(EMSCRIPTEN_ENABLE_SINGLE_FILE)
587545
target_link_libraries(binaryen_js PRIVATE "-sSINGLE_FILE")
588546
endif()
589-
target_link_libraries(binaryen_js PRIVATE "-sEXPORT_NAME=Binaryen")
590-
# Currently, js_of_ocaml can only process ES5 code
591547
if(JS_OF_OCAML)
592-
target_link_libraries(binaryen_js PRIVATE "-sEXPORT_ES6=0")
548+
# js_of_ocaml needs a specified variable with special comment to provide the library to consumer
549+
target_link_libraries(binaryen_js PRIVATE "--extern-pre-js=${CMAKE_CURRENT_SOURCE_DIR}/src/js/binaryen.jsoo-extern-pre.js")
550+
# Currently, js_of_ocaml can only process ES5 code
551+
target_link_libraries(binaryen_js PRIVATE optimized "--closure-args=\"--language_out=ECMASCRIPT5\"")
593552
else()
594-
target_link_libraries(binaryen_js PRIVATE "-sEXPORT_ES6=1")
553+
# Currently, js_of_ocaml can only process ES5 code
554+
target_link_libraries(binaryen_js PRIVATE "-sEXPORT_ES6")
595555
endif()
596556
target_link_libraries(binaryen_js PRIVATE "-sEXPORTED_RUNTIME_METHODS=stringToUTF8OnStack,stringToAscii")
597557
target_link_libraries(binaryen_js PRIVATE "-sEXPORTED_FUNCTIONS=_malloc,_free")
598558
target_link_libraries(binaryen_js PRIVATE "--post-js=${CMAKE_CURRENT_SOURCE_DIR}/src/js/binaryen.js-post.js")
599-
# js_of_ocaml needs a specified variable with special comment to provide the library to consumers
600-
if(JS_OF_OCAML)
601-
target_link_libraries(binaryen_js PRIVATE "--extern-pre-js=${CMAKE_CURRENT_SOURCE_DIR}/src/js/binaryen.jsoo-extern-pre.js")
602-
endif()
559+
target_link_libraries(binaryen_js PRIVATE "-msign-ext")
560+
target_link_libraries(binaryen_js PRIVATE "-mbulk-memory")
603561
target_link_libraries(binaryen_js PRIVATE optimized "--closure=1")
604-
# Currently, js_of_ocaml can only process ES5 code
605-
if(JS_OF_OCAML)
606-
target_link_libraries(binaryen_js PRIVATE optimized "--closure-args=\"--language_out=ECMASCRIPT5\"")
607-
endif()
608562
# TODO: Fix closure warnings! (#5062)
609563
target_link_libraries(binaryen_js PRIVATE optimized "-Wno-error=closure")
610564
if(BYN_ENABLE_LTO)
611565
target_link_libraries(binaryen_js PRIVATE optimized "-flto")
612566
endif()
613567
target_link_libraries(binaryen_js PRIVATE debug "--profiling")
614-
target_link_libraries(binaryen_js PRIVATE debug "-sASSERTIONS")
615568
# Avoid catching exit as that can confuse error reporting in Node,
616569
# see https://github.com/emscripten-core/emscripten/issues/17228
617570
target_link_libraries(binaryen_js PRIVATE "-sNODEJS_CATCH_EXIT=0")

check.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,6 @@ def run():
362362
('example', run_example_tests),
363363
('unit', run_unittest),
364364
('binaryenjs', binaryenjs.test_binaryen_js),
365-
('binaryenjs_wasm', binaryenjs.test_binaryen_wasm),
366365
('lit', run_lit),
367366
('gtest', run_gtest),
368367
])
@@ -371,7 +370,7 @@ def run():
371370
# Run all the tests
372371
def main():
373372
all_suites = TEST_SUITES.keys()
374-
skip_by_default = ['binaryenjs', 'binaryenjs_wasm']
373+
skip_by_default = ['binaryenjs']
375374

376375
if shared.options.list_suites:
377376
for suite in all_suites:

scripts/emcc-tests.sh

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@ set -o pipefail
55

66
SRCDIR="$(dirname $(dirname ${BASH_SOURCE[0]}))"
77

8+
mkdir -p emcc-build-dbg
9+
echo "emcc-tests: build dbg"
10+
emcmake cmake -S $SRCDIR -B emcc-build-dbg -DCMAKE_BUILD_TYPE=Debug -G Ninja
11+
ninja -C emcc-build-dbg binaryen_js
12+
813
mkdir -p emcc-build
9-
echo "emcc-tests: build:wasm"
14+
echo "emcc-tests: build"
1015
emcmake cmake -S $SRCDIR -B emcc-build -DCMAKE_BUILD_TYPE=Release -G Ninja
11-
ninja -C emcc-build binaryen_wasm
12-
echo "emcc-tests: test:wasm"
13-
$SRCDIR/check.py --binaryen-bin=emcc-build/bin binaryenjs_wasm
14-
echo "emcc-tests: done:wasm"
15-
16-
echo "emcc-tests: build:js"
17-
ninja -C emcc-build binaryen_js
18-
echo "emcc-tests: test:js"
16+
ninja -C emcc-build binaryen_js
17+
echo "emcc-tests: test"
1918
$SRCDIR/check.py --binaryen-bin=emcc-build/bin binaryenjs
20-
echo "emcc-tests: done:js"
19+
echo "emcc-tests: done"

scripts/test/binaryenjs.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@ def make_js_test(input_js_file, binaryen_js):
4545
return outname
4646

4747

48-
def do_test_binaryen_js_with(which):
48+
def test_binaryen_js():
4949
if not (shared.MOZJS or shared.NODEJS):
5050
shared.fail_with_error('no vm to run binaryen.js tests')
5151

5252
node_has_wasm = shared.NODEJS and support.node_has_webassembly(shared.NODEJS)
53-
if not os.path.exists(which):
54-
shared.fail_with_error('no ' + which + ' build to test')
53+
if not os.path.exists(shared.BINARYEN_JS):
54+
shared.fail_with_error('no ' + shared.BINARYEN_JS + ' build to test')
5555

56-
print('\n[ checking binaryen.js testcases (' + which + ')... ]\n')
56+
print('\n[ checking binaryen.js testcases (' + shared.BINARYEN_JS + ')... ]\n')
5757

5858
for s in shared.get_tests(shared.get_test_dir('binaryen.js'), ['.js']):
59-
outname = make_js_test(s, which)
59+
outname = make_js_test(s, shared.BINARYEN_JS)
6060

6161
def test(cmd):
6262
if 'fatal' not in s:
@@ -110,11 +110,3 @@ def update(cmd):
110110
update([shared.NODEJS, outname])
111111
else:
112112
print('Skipping ' + s + ' because WebAssembly might not be supported')
113-
114-
115-
def test_binaryen_js():
116-
do_test_binaryen_js_with(shared.BINARYEN_JS)
117-
118-
119-
def test_binaryen_wasm():
120-
do_test_binaryen_js_with(shared.BINARYEN_WASM)

scripts/test/shared.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ def is_exe(fpath):
212212
WASM_EMSCRIPTEN_FINALIZE = [os.path.join(options.binaryen_bin,
213213
'wasm-emscripten-finalize')]
214214
BINARYEN_JS = os.path.join(options.binaryen_bin, 'binaryen_js.js')
215-
BINARYEN_WASM = os.path.join(options.binaryen_bin, 'binaryen_wasm.js')
216215

217216

218217
def wrap_with_valgrind(cmd):

0 commit comments

Comments
 (0)