From 9eb7763809f7f4c71fdfc1266eae7e5936b34bc6 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 9 Oct 2024 14:13:57 -0700 Subject: [PATCH] [embind] Remove init_embind. NFC (#22705) All this function was doing was exporting a bunch of library methods. If folks want to export these functions they can do it themselves using the normal mechanisms. --- ChangeLog.md | 4 ++++ src/embind/embind.js | 13 ++----------- test/test_other.py | 2 +- tools/link.py | 1 + 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 1b0ff3aef931..c2cfac3ae772 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -26,6 +26,10 @@ See docs/process.md for more on how version tagging works. - Fix regression introduced in 3.1.67 (#22557) which broke webgpu / int64 integration. (#22689) - SDL2 port updated from 2.28.4 to 2.30.8. (#22697) +- embind no longer exports any library functions by default. Previously we + would export getInheritedInstanceCount, getLiveInheritedInstances, + flushPendingDeletes and setDelayFunction. If you need these library function + exprted they can be added to `EXPORTED_RUNTIME_METHODS`. (#22705) 3.1.68 - 09/30/24 ----------------- diff --git a/src/embind/embind.js b/src/embind/embind.js index d547b471afc2..eae477827216 100644 --- a/src/embind/embind.js +++ b/src/embind/embind.js @@ -59,16 +59,6 @@ var LibraryEmbind = { }`, $EmValOptionalType__deps: ['$EmValType'], $EmValOptionalType: '=Object.assign({optional: true}, EmValType);', - $init_embind__deps: [ - '$getInheritedInstanceCount', '$getLiveInheritedInstances', - '$flushPendingDeletes', '$setDelayFunction'], - $init_embind__postset: 'init_embind();', - $init_embind: () => { - Module['getInheritedInstanceCount'] = getInheritedInstanceCount; - Module['getLiveInheritedInstances'] = getLiveInheritedInstances; - Module['flushPendingDeletes'] = flushPendingDeletes; - Module['setDelayFunction'] = setDelayFunction; - }, $throwUnboundTypeError__deps: ['$registeredTypes', '$typeDependencies', '$UnboundTypeError', '$getTypeName'], $throwUnboundTypeError: (message, types) => { @@ -219,7 +209,6 @@ var LibraryEmbind = { }, // raw pointer -> instance - $registeredInstances__deps: ['$init_embind'], $registeredInstances: {}, $getBasestPointer__deps: ['$throwBindingError'], @@ -1582,6 +1571,8 @@ var LibraryEmbind = { '$releaseClassHandle', '$throwBindingError', '$detachFinalizer', + '$flushPendingDeletes', + '$delayFunction', ], $init_ClassHandle: () => { Object.assign(ClassHandle.prototype, { diff --git a/test/test_other.py b/test/test_other.py index 0d5e3a4057b7..4b4b17a5a4d1 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -3240,7 +3240,7 @@ def test_embind(self, *extra_args): '-Wno-deprecated-declarations', '-lembind', '-sRETAIN_COMPILER_SETTINGS', - '-sEXPORTED_RUNTIME_METHODS=getCompilerSetting', + '-sEXPORTED_RUNTIME_METHODS=getCompilerSetting,setDelayFunction,flushPendingDeletes', '-sWASM_ASYNC_COMPILATION=0', # This test uses a `CustomSmartPtr` class which has 1MB of data embedded in # it which means we need more stack space than normal. diff --git a/tools/link.py b/tools/link.py index d98e74fd0955..22a8b7494fb0 100644 --- a/tools/link.py +++ b/tools/link.py @@ -1949,6 +1949,7 @@ def run_embind_gen(wasm_target, js_syms, extra_settings, linker_inputs): if building.is_wasm_dylib(linker_input): safe_copy(linker_input, in_temp('')) + settings.EXPORTED_RUNTIME_METHODS = [] # Ignore any options or settings that can conflict with running the TS # generation output. # Don't invoke the program's `main` function.