Skip to content

Commit da8189c

Browse files
authored
[embind] Do not export InternalError and BindingError by default. (#24259)
These exports are likely not needed by default. They also use a non standard way of exporting on the Module object by manually assigning, which causes issues in the future with MODULARIZE=instance.
1 parent 5a85d47 commit da8189c

File tree

6 files changed

+14
-12
lines changed

6 files changed

+14
-12
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ See docs/process.md for more on how version tagging works.
2222
----------------------
2323
- When using cmake the EMSCRIPTEN_FORCE_COMPILERS setting was reverted to
2424
being on by default due to issues that were found with disabling it. (#24223)
25+
- Embind symbols `InternalError`, `BindingError`, and `count_emval_handles` are
26+
no longer exported by default. They can be exported using
27+
`-sEXPORTED_RUNTIME_METHODS=InternalError,BindingError,count_emval_handles`
2528

2629
4.0.8 - 04/30/25
2730
----------------

src/lib/libembind_shared.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// University of Illinois/NCSA Open Source License. Both these licenses can be
44
// found in the LICENSE file.
55
var LibraryEmbindShared = {
6-
$InternalError: "=Module['InternalError'] = class InternalError extends Error { constructor(message) { super(message); this.name = 'InternalError'; }}",
7-
$BindingError: "=Module['BindingError'] = class BindingError extends Error { constructor(message) { super(message); this.name = 'BindingError'; }}",
6+
$InternalError: "= class InternalError extends Error { constructor(message) { super(message); this.name = 'InternalError'; }}",
7+
$BindingError: "= class BindingError extends Error { constructor(message) { super(message); this.name = 'BindingError'; }}",
88

99
$throwInternalError__deps: ['$InternalError'],
1010
$throwInternalError: (message) => { throw new InternalError(message); },

src/lib/libemval.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ var LibraryEmVal = {
4141
#if ASSERTIONS
4242
assert(emval_handles.length === {{{ EMVAL_RESERVED_HANDLES }}} * 2);
4343
#endif
44-
Module['count_emval_handles'] = count_emval_handles;
4544
},
4645

4746
$count_emval_handles__deps: ['$emval_freelist', '$emval_handles'],

test/code_size/embind_hello_wasm.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"a.html": 552,
33
"a.html.gz": 380,
4-
"a.js": 9094,
5-
"a.js.gz": 3993,
4+
"a.js": 9015,
5+
"a.js.gz": 3957,
66
"a.wasm": 7332,
77
"a.wasm.gz": 3369,
8-
"total": 16978,
9-
"total_gz": 7742
8+
"total": 16899,
9+
"total_gz": 7706
1010
}

test/code_size/embind_val_wasm.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"a.html": 552,
33
"a.html.gz": 380,
4-
"a.js": 6940,
5-
"a.js.gz": 2999,
4+
"a.js": 6877,
5+
"a.js.gz": 2968,
66
"a.wasm": 9133,
77
"a.wasm.gz": 4710,
8-
"total": 16625,
9-
"total_gz": 8089
8+
"total": 16562,
9+
"total_gz": 8058
1010
}

test/test_other.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3347,7 +3347,7 @@ def test_embind(self, *extra_args):
33473347
'-Wno-deprecated-declarations',
33483348
'-lembind',
33493349
'-sRETAIN_COMPILER_SETTINGS',
3350-
'-sEXPORTED_RUNTIME_METHODS=getCompilerSetting,setDelayFunction,flushPendingDeletes,PureVirtualError,HEAP8',
3350+
'-sEXPORTED_RUNTIME_METHODS=getCompilerSetting,setDelayFunction,flushPendingDeletes,PureVirtualError,HEAP8,InternalError,BindingError,count_emval_handles',
33513351
'-sWASM_ASYNC_COMPILATION=0',
33523352
# This test uses a `CustomSmartPtr` class which has 1MB of data embedded in
33533353
# it which means we need more stack space than normal.

0 commit comments

Comments
 (0)