Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,7 @@ jobs:
# We include most but not all of the nodefs and node rawfs tests here.
# test_fs_nodefs_rw, test_fs_nodefs_statvfs, and test_unistd_io_nodefs_bigint fail.
test_targets: "
other.test_embind_tsgen_remove_relaxed_simd
other.test_gen_struct_info
other.test_native_call_before_init
other.test_js_optimizer_verbose
Expand Down
24 changes: 24 additions & 0 deletions test/other/test_relaxed_simd.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <wasm_simd128.h>
#include <stdio.h>
#include <stdio.h>
#include <emscripten/bind.h>

void print_madd() {
v128_t v1 = wasm_f32x4_make(1.2f, 3.4f, 5.6f, 7.8f);
v128_t v2 = wasm_f32x4_make(2.1f, 4.3f, 6.5f, 8.7f);
v128_t v3 = wasm_f32x4_make(3.1f, 5.3f, 8.5f, 9.7f);
v128_t v4 = wasm_f32x4_relaxed_madd(v1, v2, v3);
printf("v3: [%.1f, %.1f, %.1f, %.1f]\n",
wasm_f32x4_extract_lane(v4, 0),
wasm_f32x4_extract_lane(v4, 1),
wasm_f32x4_extract_lane(v4, 2),
wasm_f32x4_extract_lane(v4, 3));
}

int main() {
print_madd();
}

EMSCRIPTEN_BINDINGS(my_module) {
emscripten::function("print_madd", &print_madd);
}
4 changes: 4 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -3611,6 +3611,10 @@ def test_embind_tsgen_ignore(self, extra_args, expected_ts_file):
self.emcc('other/embind_tsgen.cpp', extra_args)
self.assertFileContents(test_file(f'other/{expected_ts_file}'), read_file('embind_tsgen.d.ts'))

def test_embind_tsgen_remove_relaxed_simd(self):
self.emcc('other/test_relaxed_simd.cpp', ['-mrelaxed-simd', '-msse', '-lembind', '--emit-tsd', 'embind_tsgen.d.ts'])
self.assertContained('print_madd()', read_file('embind_tsgen.d.ts'))

def test_embind_tsgen_worker_env(self):
self.cflags += ['-lembind', '--emit-tsd', 'embind_tsgen.d.ts']
# Passing -sWASM_WORKERS requires the 'worker' environment
Expand Down
17 changes: 13 additions & 4 deletions tools/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -2040,12 +2040,21 @@ def run_embind_gen(options, wasm_target, js_syms, extra_settings):
outfile_js = in_temp('tsgen.js')
# The Wasm outfile may be modified by emscripten.emscript, so use a temporary file.
outfile_wasm = in_temp('tsgen.wasm')
emscripten.emscript(wasm_target, outfile_wasm, outfile_js, js_syms, finalize=False)
metadata = emscripten.emscript(wasm_target, outfile_wasm, outfile_js, js_syms, finalize=False)

# Strip out any Wasm features that can't run in older versions of node.
wasm_opt_args = []
if '--enable-relaxed-simd' in metadata.features:
# Relaxed SIMD isn't supported on older versions of node.
wasm_opt_args += ['--remove-relaxed-simd']
if '--enable-memory64' in metadata.features:
# See comment above about lowering memory64.
wasm_opt_args += ['--memory64-lowering', '--table64-lowering']
if wasm_opt_args:
building.run_wasm_opt(outfile_wasm, outfile_wasm, wasm_opt_args)

# Build the flags needed by Node.js to properly run the output file.
node_args = []
if settings.MEMORY64:
# See comment above about lowering memory64.
building.run_wasm_opt(outfile_wasm, outfile_wasm, ['--memory64-lowering', '--table64-lowering'])
if settings.WASM_EXCEPTIONS:
node_args += shared.node_exception_flags(config.NODE_JS)
# Run the generated JS file with the proper flags to generate the TypeScript bindings.
Expand Down
Loading