Skip to content

Commit

Permalink
Revert bundler target specific default transformations (#4253)
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda authored Nov 28, 2024
1 parent 83c9deb commit c7cab6b
Show file tree
Hide file tree
Showing 75 changed files with 535 additions and 465 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,6 @@ jobs:
- run: rustup update --no-self-update stable && rustup default stable
- run: rustup target add wasm32-unknown-unknown
- run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -s -- -f
- run: |
curl -L https://github.com/WebAssembly/binaryen/releases/download/version_112/binaryen-version_112-x86_64-linux.tar.gz -sSf > binaryen-version_112-x86_64-linux.tar.gz
tar -xz -f binaryen-version_112-x86_64-linux.tar.gz binaryen-version_112/bin/wasm2js
echo "$PWD/binaryen-version_112/bin" >> $GITHUB_PATH
- run: |
cargo build -p wasm-bindgen-cli
ln -snf `pwd`/target/debug/wasm-bindgen $(dirname `which cargo`)/wasm-bindgen
Expand Down
3 changes: 0 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@
* Optimized ABI performance for `Option<{i32,u32,isize,usize,f32,*const T,*mut T}>`.
[#4183](https://github.com/rustwasm/wasm-bindgen/pull/4183)

* Reference type proposal transformations are not applied by default when detecting it in the Wasm module for the bundler target because currently `webpack` doesn't support it.
[#4235](https://github.com/rustwasm/wasm-bindgen/pull/4235)

* Deprecate `--reference-types` in favor of automatic target feature detection.
[#4237](https://github.com/rustwasm/wasm-bindgen/pull/4237)

Expand Down
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ members = [
"examples/wasm-in-wasm",
"examples/wasm-in-wasm-imports",
"examples/wasm-in-web-worker",
"examples/wasm2js",
"examples/weather_report",
"examples/webaudio",
"examples/webgl",
Expand Down
5 changes: 1 addition & 4 deletions crates/cli-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,7 @@ impl Bindgen {
};

// Enable reference type transformations if the module is already using it.
// Currently `webpack` does not support reference types.
if !matches!(self.mode, OutputMode::Bundler { .. })
&& wasm_bindgen_wasm_conventions::target_feature(&module, "reference-types").ok()
== Some(true)
if let Ok(true) = wasm_bindgen_wasm_conventions::target_feature(&module, "reference-types")
{
self.externref = true;
}
Expand Down
11 changes: 11 additions & 0 deletions crates/cli/tests/reference/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,14 @@ export function add_i32(a, b) {
return ret;
}

export function __wbindgen_init_externref_table() {
const table = wasm.__wbindgen_export_0;
const offset = table.grow(4);
table.set(0, undefined);
table.set(offset + 0, undefined);
table.set(offset + 1, null);
table.set(offset + 2, true);
table.set(offset + 3, false);
;
};

11 changes: 8 additions & 3 deletions crates/cli/tests/reference/add.wat
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
(module $reference_test.wasm
(type (;0;) (func (param i32 i32) (result i32)))
(func $add_u32 (;0;) (type 0) (param i32 i32) (result i32))
(func $add_i32 (;1;) (type 0) (param i32 i32) (result i32))
(type (;0;) (func))
(type (;1;) (func (param i32 i32) (result i32)))
(import "./reference_test_bg.js" "__wbindgen_init_externref_table" (func (;0;) (type 0)))
(func $add_u32 (;1;) (type 1) (param i32 i32) (result i32))
(func $add_i32 (;2;) (type 1) (param i32 i32) (result i32))
(table (;0;) 128 externref)
(memory (;0;) 17)
(export "memory" (memory 0))
(export "add_u32" (func $add_u32))
(export "add_i32" (func $add_i32))
(export "__wbindgen_export_0" (table 0))
(export "__wbindgen_start" (func 0))
(@custom "target_features" (after code) "\04+\0amultivalue+\0fmutable-globals+\0freference-types+\08sign-ext")
)

11 changes: 11 additions & 0 deletions crates/cli/tests/reference/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ export class ClassBuilder {
}
}

export function __wbindgen_init_externref_table() {
const table = wasm.__wbindgen_export_0;
const offset = table.grow(4);
table.set(0, undefined);
table.set(offset + 0, undefined);
table.set(offset + 1, null);
table.set(offset + 2, true);
table.set(offset + 3, false);
;
};

export function __wbindgen_throw(arg0, arg1) {
throw new Error(getStringFromWasm0(arg0, arg1));
};
Expand Down
13 changes: 9 additions & 4 deletions crates/cli/tests/reference/builder.wat
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
(module $reference_test.wasm
(type (;0;) (func (result i32)))
(type (;1;) (func (param i32 i32)))
(func $__wbg_classbuilder_free (;0;) (type 1) (param i32 i32))
(func $classbuilder_builder (;1;) (type 0) (result i32))
(type (;0;) (func))
(type (;1;) (func (result i32)))
(type (;2;) (func (param i32 i32)))
(import "./reference_test_bg.js" "__wbindgen_init_externref_table" (func (;0;) (type 0)))
(func $__wbg_classbuilder_free (;1;) (type 2) (param i32 i32))
(func $classbuilder_builder (;2;) (type 1) (result i32))
(table (;0;) 128 externref)
(memory (;0;) 17)
(export "memory" (memory 0))
(export "__wbg_classbuilder_free" (func $__wbg_classbuilder_free))
(export "classbuilder_builder" (func $classbuilder_builder))
(export "__wbindgen_export_0" (table 0))
(export "__wbindgen_start" (func 0))
(@custom "target_features" (after code) "\04+\0amultivalue+\0fmutable-globals+\0freference-types+\08sign-ext")
)

11 changes: 11 additions & 0 deletions crates/cli/tests/reference/constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ export class ClassConstructor {
}
}

export function __wbindgen_init_externref_table() {
const table = wasm.__wbindgen_export_0;
const offset = table.grow(4);
table.set(0, undefined);
table.set(offset + 0, undefined);
table.set(offset + 1, null);
table.set(offset + 2, true);
table.set(offset + 3, false);
;
};

export function __wbindgen_throw(arg0, arg1) {
throw new Error(getStringFromWasm0(arg0, arg1));
};
Expand Down
13 changes: 9 additions & 4 deletions crates/cli/tests/reference/constructor.wat
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
(module $reference_test.wasm
(type (;0;) (func (result i32)))
(type (;1;) (func (param i32 i32)))
(func $__wbg_classconstructor_free (;0;) (type 1) (param i32 i32))
(func $classconstructor_new (;1;) (type 0) (result i32))
(type (;0;) (func))
(type (;1;) (func (result i32)))
(type (;2;) (func (param i32 i32)))
(import "./reference_test_bg.js" "__wbindgen_init_externref_table" (func (;0;) (type 0)))
(func $__wbg_classconstructor_free (;1;) (type 2) (param i32 i32))
(func $classconstructor_new (;2;) (type 1) (result i32))
(table (;0;) 128 externref)
(memory (;0;) 17)
(export "memory" (memory 0))
(export "__wbg_classconstructor_free" (func $__wbg_classconstructor_free))
(export "classconstructor_new" (func $classconstructor_new))
(export "__wbindgen_export_0" (table 0))
(export "__wbindgen_start" (func 0))
(@custom "target_features" (after code) "\04+\0amultivalue+\0fmutable-globals+\0freference-types+\08sign-ext")
)

12 changes: 12 additions & 0 deletions crates/cli/tests/reference/empty.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,15 @@ export function __wbg_set_wasm(val) {
wasm = val;
}


export function __wbindgen_init_externref_table() {
const table = wasm.__wbindgen_export_0;
const offset = table.grow(4);
table.set(0, undefined);
table.set(offset + 0, undefined);
table.set(offset + 1, null);
table.set(offset + 2, true);
table.set(offset + 3, false);
;
};

5 changes: 5 additions & 0 deletions crates/cli/tests/reference/empty.wat
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
(module $reference_test.wasm
(type (;0;) (func))
(import "./reference_test_bg.js" "__wbindgen_init_externref_table" (func (;0;) (type 0)))
(table (;0;) 128 externref)
(memory (;0;) 16)
(export "memory" (memory 0))
(export "__wbindgen_export_0" (table 0))
(export "__wbindgen_start" (func 0))
(@custom "target_features" (after export) "\04+\0amultivalue+\0fmutable-globals+\0freference-types+\08sign-ext")
)

11 changes: 11 additions & 0 deletions crates/cli/tests/reference/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ export const Ordering = Object.freeze({

const __wbindgen_enum_ColorName = ["green", "yellow", "red"];

export function __wbindgen_init_externref_table() {
const table = wasm.__wbindgen_export_0;
const offset = table.grow(4);
table.set(0, undefined);
table.set(offset + 0, undefined);
table.set(offset + 1, null);
table.set(offset + 2, true);
table.set(offset + 3, false);
;
};

export function __wbindgen_throw(arg0, arg1) {
throw new Error(getStringFromWasm0(arg0, arg1));
};
Expand Down
17 changes: 11 additions & 6 deletions crates/cli/tests/reference/enums.wat
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
(module $reference_test.wasm
(type (;0;) (func (param i32) (result i32)))
(func $enum_echo (;0;) (type 0) (param i32) (result i32))
(func $option_enum_echo (;1;) (type 0) (param i32) (result i32))
(func $get_name (;2;) (type 0) (param i32) (result i32))
(func $option_string_enum_echo (;3;) (type 0) (param i32) (result i32))
(func $option_order (;4;) (type 0) (param i32) (result i32))
(type (;0;) (func))
(type (;1;) (func (param i32) (result i32)))
(import "./reference_test_bg.js" "__wbindgen_init_externref_table" (func (;0;) (type 0)))
(func $enum_echo (;1;) (type 1) (param i32) (result i32))
(func $option_enum_echo (;2;) (type 1) (param i32) (result i32))
(func $get_name (;3;) (type 1) (param i32) (result i32))
(func $option_string_enum_echo (;4;) (type 1) (param i32) (result i32))
(func $option_order (;5;) (type 1) (param i32) (result i32))
(table (;0;) 128 externref)
(memory (;0;) 17)
(export "memory" (memory 0))
(export "enum_echo" (func $enum_echo))
(export "option_enum_echo" (func $option_enum_echo))
(export "get_name" (func $get_name))
(export "option_string_enum_echo" (func $option_string_enum_echo))
(export "option_order" (func $option_order))
(export "__wbindgen_export_0" (table 0))
(export "__wbindgen_start" (func 0))
(@custom "target_features" (after code) "\04+\0amultivalue+\0fmutable-globals+\0freference-types+\08sign-ext")
)

11 changes: 11 additions & 0 deletions crates/cli/tests/reference/getter-setter.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,17 @@ export class Foo {
}
}

export function __wbindgen_init_externref_table() {
const table = wasm.__wbindgen_export_0;
const offset = table.grow(4);
table.set(0, undefined);
table.set(offset + 0, undefined);
table.set(offset + 1, null);
table.set(offset + 2, true);
table.set(offset + 3, false);
;
};

export function __wbindgen_throw(arg0, arg1) {
throw new Error(getStringFromWasm0(arg0, arg1));
};
Expand Down
53 changes: 29 additions & 24 deletions crates/cli/tests/reference/getter-setter.wat
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
(module $reference_test.wasm
(type (;0;) (func (result i32)))
(type (;1;) (func (param i32)))
(type (;2;) (func (param i32) (result i32)))
(type (;3;) (func (param i32) (result f64)))
(type (;4;) (func (param i32 i32)))
(type (;5;) (func (param i32 i32) (result i32)))
(type (;6;) (func (param i32 i32 i32)))
(type (;7;) (func (param i32 i32 i32 i32) (result i32)))
(type (;8;) (func (param i32 f64)))
(func $__wbindgen_realloc (;0;) (type 7) (param i32 i32 i32 i32) (result i32))
(func $__wbindgen_malloc (;1;) (type 5) (param i32 i32) (result i32))
(func $foo_set_weird (;2;) (type 6) (param i32 i32 i32))
(func $__wbg_set_foo_y (;3;) (type 8) (param i32 f64))
(func $__wbg_get_foo_y (;4;) (type 3) (param i32) (result f64))
(func $__wbg_get_foo_x (;5;) (type 2) (param i32) (result i32))
(func $foo_set_z (;6;) (type 8) (param i32 f64))
(func $foo_set_lone_setter (;7;) (type 8) (param i32 f64))
(func $foo_z (;8;) (type 3) (param i32) (result f64))
(func $foo_lone_getter (;9;) (type 3) (param i32) (result f64))
(func $__wbg_set_foo_x (;10;) (type 4) (param i32 i32))
(func $foo_weird (;11;) (type 2) (param i32) (result i32))
(func $foo_x_static (;12;) (type 0) (result i32))
(func $__wbg_foo_free (;13;) (type 4) (param i32 i32))
(func $foo_set_x_static (;14;) (type 1) (param i32))
(type (;0;) (func))
(type (;1;) (func (result i32)))
(type (;2;) (func (param i32)))
(type (;3;) (func (param i32) (result i32)))
(type (;4;) (func (param i32) (result f64)))
(type (;5;) (func (param i32 i32)))
(type (;6;) (func (param i32 i32) (result i32)))
(type (;7;) (func (param i32 i32 i32)))
(type (;8;) (func (param i32 i32 i32 i32) (result i32)))
(type (;9;) (func (param i32 f64)))
(import "./reference_test_bg.js" "__wbindgen_init_externref_table" (func (;0;) (type 0)))
(func $__wbindgen_realloc (;1;) (type 8) (param i32 i32 i32 i32) (result i32))
(func $__wbindgen_malloc (;2;) (type 6) (param i32 i32) (result i32))
(func $foo_set_weird (;3;) (type 7) (param i32 i32 i32))
(func $__wbg_set_foo_y (;4;) (type 9) (param i32 f64))
(func $__wbg_get_foo_y (;5;) (type 4) (param i32) (result f64))
(func $__wbg_get_foo_x (;6;) (type 3) (param i32) (result i32))
(func $foo_set_z (;7;) (type 9) (param i32 f64))
(func $foo_set_lone_setter (;8;) (type 9) (param i32 f64))
(func $foo_z (;9;) (type 4) (param i32) (result f64))
(func $foo_lone_getter (;10;) (type 4) (param i32) (result f64))
(func $__wbg_set_foo_x (;11;) (type 5) (param i32 i32))
(func $foo_weird (;12;) (type 3) (param i32) (result i32))
(func $foo_x_static (;13;) (type 1) (result i32))
(func $__wbg_foo_free (;14;) (type 5) (param i32 i32))
(func $foo_set_x_static (;15;) (type 2) (param i32))
(table (;0;) 128 externref)
(memory (;0;) 17)
(export "memory" (memory 0))
(export "__wbg_foo_free" (func $__wbg_foo_free))
Expand All @@ -38,8 +41,10 @@
(export "foo_set_weird" (func $foo_set_weird))
(export "foo_x_static" (func $foo_x_static))
(export "foo_set_x_static" (func $foo_set_x_static))
(export "__wbindgen_export_0" (table 0))
(export "__wbindgen_malloc" (func $__wbindgen_malloc))
(export "__wbindgen_realloc" (func $__wbindgen_realloc))
(export "__wbindgen_start" (func 0))
(@custom "target_features" (after code) "\04+\0amultivalue+\0fmutable-globals+\0freference-types+\08sign-ext")
)

Loading

0 comments on commit c7cab6b

Please sign in to comment.