Skip to content

Commit

Permalink
Remove some hardcoded exports that can now be handled by JS __deps. NFC
Browse files Browse the repository at this point in the history
See #18849
  • Loading branch information
sbc100 committed May 9, 2023
1 parent c8f3ea7 commit e354c7d
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 23 deletions.
18 changes: 3 additions & 15 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2087,6 +2087,7 @@ def phase_linker_setup(options, state, newargs):
if settings.MAIN_MODULE == 1:
settings.INCLUDE_FULL_LIBRARY = 1
settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$loadDylibs']
settings.REQUIRED_EXPORTS += ['malloc']

if settings.MAIN_MODULE == 1 or settings.SIDE_MODULE == 1:
settings.LINKABLE = 1
Expand Down Expand Up @@ -2339,7 +2340,7 @@ def phase_linker_setup(options, state, newargs):
settings.FETCH_WORKER_FILE = unsuffixed_basename(target) + '.fetch.js'

if settings.DEMANGLE_SUPPORT:
settings.REQUIRED_EXPORTS += ['__cxa_demangle']
settings.REQUIRED_EXPORTS += ['__cxa_demangle', 'free']
settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$demangle', '$stackTrace']

if settings.FULL_ES3:
Expand Down Expand Up @@ -2413,11 +2414,6 @@ def phase_linker_setup(options, state, newargs):
exit_with_error('-sPROXY_TO_PTHREAD requires -pthread to work!')
settings.JS_LIBRARIES.append((0, 'library_pthread_stub.js'))

# TODO: Move this into the library JS file once it becomes possible.
# See https://github.com/emscripten-core/emscripten/pull/15982
if settings.INCLUDE_FULL_LIBRARY and not settings.DISABLE_EXCEPTION_CATCHING:
settings.EXPORTED_FUNCTIONS += ['___get_exception_message', '_free']

if settings.MEMORY64:
if settings.ASYNCIFY and settings.MEMORY64 == 1:
exit_with_error('MEMORY64=1 is not compatible with ASYNCIFY')
Expand Down Expand Up @@ -2761,19 +2757,11 @@ def check_memory_setting(setting):
settings.REQUIRED_EXPORTS += ['__funcs_on_exit']

# various settings require malloc/free support from JS
if settings.RELOCATABLE or \
settings.BUILD_AS_WORKER or \
settings.USE_WEBGPU or \
settings.OFFSCREENCANVAS_SUPPORT or \
if settings.BUILD_AS_WORKER or \
settings.LEGACY_GL_EMULATION or \
settings.ASYNCIFY or \
settings.WASMFS or \
settings.DEMANGLE_SUPPORT or \
settings.FORCE_FILESYSTEM or \
settings.STB_IMAGE or \
settings.EMBIND or \
settings.FETCH or \
settings.PROXY_POSIX_SOCKETS or \
options.memory_profiler or \
sanitize:
settings.REQUIRED_EXPORTS += ['malloc', 'free']
Expand Down
4 changes: 2 additions & 2 deletions src/embind/embind.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ var LibraryEmbind = {
return ret;
},

$getTypeName__deps: ['$readLatin1String', '__getTypeName'],
$getTypeName__deps: ['$readLatin1String', '__getTypeName', 'free'],
$getTypeName: function(type) {
var ptr = ___getTypeName(type);
var rv = readLatin1String(ptr);
Expand Down Expand Up @@ -651,7 +651,7 @@ var LibraryEmbind = {
_embind_register_std_string__deps: [
'$readLatin1String', '$registerType',
'$simpleReadValueFromPointer', '$throwBindingError',
'$stringToUTF8', '$lengthBytesUTF8'],
'$stringToUTF8', '$lengthBytesUTF8', 'malloc'],
_embind_register_std_string: function(rawType, name) {
name = readLatin1String(name);
var stdStringIsUTF8
Expand Down
2 changes: 1 addition & 1 deletion src/library_dylink.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ var LibraryDylink = {
// Allocate memory even if malloc isn't ready yet. The allocated memory here
// must be zero initialized since its used for all static data, including bss.
$getMemory__noleakcheck: true,
$getMemory__deps: ['$GOT', '__heap_base', '$zeroMemory'],
$getMemory__deps: ['$GOT', '__heap_base', '$zeroMemory', 'malloc'],
$getMemory: function(size) {
// After the runtime is initialized, we must only use sbrk() normally.
#if DYLINK_DEBUG
Expand Down
2 changes: 2 additions & 0 deletions src/library_fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ var LibraryFetch = {

emscripten_start_fetch: startFetch,
emscripten_start_fetch__deps: [
'malloc',
'free',
'$Fetch',
'$fetchXHR',
'$callUserCallback',
Expand Down
6 changes: 3 additions & 3 deletions src/library_webgpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ var LibraryWebGPU = {
device.label = UTF8ToString(labelPtr);
},

wgpuDeviceSetDeviceLostCallback__deps: ['$callUserCallback', '$stringToNewUTF8'],
wgpuDeviceSetDeviceLostCallback__deps: ['$callUserCallback', '$stringToNewUTF8', 'free'],
wgpuDeviceSetDeviceLostCallback: function(deviceId, callback, userdata) {
var deviceWrapper = WebGPU.mgrDevice.objects[deviceId];
{{{ gpu.makeCheckDefined('deviceWrapper') }}}
Expand Down Expand Up @@ -2432,7 +2432,7 @@ var LibraryWebGPU = {
#endif
},
wgpuInstanceRequestAdapter__deps: ['$callUserCallback', '$stringToNewUTF8'],
wgpuInstanceRequestAdapter__deps: ['$callUserCallback', '$stringToNewUTF8', 'free'],
wgpuInstanceRequestAdapter: function(instanceId, options, callback, userdata) {
{{{ gpu.makeCheck('instanceId === 0, "WGPUInstance is ignored"') }}}
Expand Down Expand Up @@ -2513,7 +2513,7 @@ var LibraryWebGPU = {
return adapter.features.has(WebGPU.FeatureName[featureEnumValue]);
},

wgpuAdapterRequestDevice__deps: ['$callUserCallback', '$stringToNewUTF8'],
wgpuAdapterRequestDevice__deps: ['$callUserCallback', '$stringToNewUTF8', 'free'],
wgpuAdapterRequestDevice: function(adapterId, descriptor, callback, userdata) {
var adapter = WebGPU.mgrAdapter.get(adapterId);

Expand Down
1 change: 0 additions & 1 deletion test/other/metadce/test_metadce_cxx_mangle.exports
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ dynCall_viijii
free
getTempRet0
main
malloc
memory
setTempRet0
setThrew
Expand Down
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_mangle.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
219427
219418

0 comments on commit e354c7d

Please sign in to comment.