Skip to content

Commit f41a36f

Browse files
committed
Remove some hardcoded exports that can now be handled by JS __deps. NFC
See #18849
1 parent c8f3ea7 commit f41a36f

File tree

8 files changed

+15
-26
lines changed

8 files changed

+15
-26
lines changed

emcc.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,6 +2087,7 @@ def phase_linker_setup(options, state, newargs):
20872087
if settings.MAIN_MODULE == 1:
20882088
settings.INCLUDE_FULL_LIBRARY = 1
20892089
settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$loadDylibs']
2090+
settings.REQUIRED_EXPORTS += ['malloc']
20902091

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

23412342
if settings.DEMANGLE_SUPPORT:
2342-
settings.REQUIRED_EXPORTS += ['__cxa_demangle']
2343+
settings.REQUIRED_EXPORTS += ['__cxa_demangle', 'free']
23432344
settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$demangle', '$stackTrace']
23442345

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

2416-
# TODO: Move this into the library JS file once it becomes possible.
2417-
# See https://github.com/emscripten-core/emscripten/pull/15982
2418-
if settings.INCLUDE_FULL_LIBRARY and not settings.DISABLE_EXCEPTION_CATCHING:
2419-
settings.EXPORTED_FUNCTIONS += ['___get_exception_message', '_free']
2420-
24212417
if settings.MEMORY64:
24222418
if settings.ASYNCIFY and settings.MEMORY64 == 1:
24232419
exit_with_error('MEMORY64=1 is not compatible with ASYNCIFY')
@@ -2761,19 +2757,10 @@ def check_memory_setting(setting):
27612757
settings.REQUIRED_EXPORTS += ['__funcs_on_exit']
27622758

27632759
# various settings require malloc/free support from JS
2764-
if settings.RELOCATABLE or \
2765-
settings.BUILD_AS_WORKER or \
2766-
settings.USE_WEBGPU or \
2767-
settings.OFFSCREENCANVAS_SUPPORT or \
2768-
settings.LEGACY_GL_EMULATION or \
2760+
if settings.BUILD_AS_WORKER or \
27692761
settings.ASYNCIFY or \
27702762
settings.WASMFS or \
2771-
settings.DEMANGLE_SUPPORT or \
27722763
settings.FORCE_FILESYSTEM or \
2773-
settings.STB_IMAGE or \
2774-
settings.EMBIND or \
2775-
settings.FETCH or \
2776-
settings.PROXY_POSIX_SOCKETS or \
27772764
options.memory_profiler or \
27782765
sanitize:
27792766
settings.REQUIRED_EXPORTS += ['malloc', 'free']

src/embind/embind.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ var LibraryEmbind = {
371371
return ret;
372372
},
373373

374-
$getTypeName__deps: ['$readLatin1String', '__getTypeName'],
374+
$getTypeName__deps: ['$readLatin1String', '__getTypeName', 'free'],
375375
$getTypeName: function(type) {
376376
var ptr = ___getTypeName(type);
377377
var rv = readLatin1String(ptr);
@@ -651,7 +651,7 @@ var LibraryEmbind = {
651651
_embind_register_std_string__deps: [
652652
'$readLatin1String', '$registerType',
653653
'$simpleReadValueFromPointer', '$throwBindingError',
654-
'$stringToUTF8', '$lengthBytesUTF8'],
654+
'$stringToUTF8', '$lengthBytesUTF8', 'malloc', 'free'],
655655
_embind_register_std_string: function(rawType, name) {
656656
name = readLatin1String(name);
657657
var stdStringIsUTF8

src/library_dylink.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ var LibraryDylink = {
379379
// Allocate memory even if malloc isn't ready yet. The allocated memory here
380380
// must be zero initialized since its used for all static data, including bss.
381381
$getMemory__noleakcheck: true,
382-
$getMemory__deps: ['$GOT', '__heap_base', '$zeroMemory'],
382+
$getMemory__deps: ['$GOT', '__heap_base', '$zeroMemory', 'malloc'],
383383
$getMemory: function(size) {
384384
// After the runtime is initialized, we must only use sbrk() normally.
385385
#if DYLINK_DEBUG

src/library_fetch.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ var LibraryFetch = {
2828

2929
emscripten_start_fetch: startFetch,
3030
emscripten_start_fetch__deps: [
31+
'malloc',
32+
'free',
3133
'$Fetch',
3234
'$fetchXHR',
3335
'$callUserCallback',

src/library_webgl.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ var LibraryGL = {
152152
$GL__deps: [
153153
#if PTHREADS
154154
'malloc', // Needed by registerContext
155+
'free', // Needed by deleteContext
155156
#endif
156157
#if MIN_WEBGL_VERSION == 1
157158
'$webgl_enable_ANGLE_instanced_arrays',
@@ -3933,7 +3934,7 @@ var LibraryGL = {
39333934
}
39343935
},
39353936

3936-
glMapBufferRange__deps: ['$emscriptenWebGLGetBufferBinding', '$emscriptenWebGLValidateMapBufferTarget'],
3937+
glMapBufferRange__deps: ['$emscriptenWebGLGetBufferBinding', '$emscriptenWebGLValidateMapBufferTarget', 'malloc'],
39373938
glMapBufferRange: function(target, offset, length, access) {
39383939
if ((access & (0x1/*GL_MAP_READ_BIT*/ | 0x20/*GL_MAP_UNSYNCHRONIZED_BIT*/)) != 0) {
39393940
err("glMapBufferRange access does not support MAP_READ or MAP_UNSYNCHRONIZED");
@@ -4015,7 +4016,7 @@ var LibraryGL = {
40154016
HEAPU8.subarray(mapping.mem + offset, mapping.mem + offset + length));
40164017
},
40174018

4018-
glUnmapBuffer__deps: ['$emscriptenWebGLGetBufferBinding', '$emscriptenWebGLValidateMapBufferTarget'],
4019+
glUnmapBuffer__deps: ['$emscriptenWebGLGetBufferBinding', '$emscriptenWebGLValidateMapBufferTarget', 'free'],
40194020
glUnmapBuffer: function(target) {
40204021
if (!emscriptenWebGLValidateMapBufferTarget(target)) {
40214022
GL.recordError(0x500/*GL_INVALID_ENUM*/);

src/library_webgpu.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ var LibraryWebGPU = {
810810
device.label = UTF8ToString(labelPtr);
811811
},
812812

813-
wgpuDeviceSetDeviceLostCallback__deps: ['$callUserCallback', '$stringToNewUTF8'],
813+
wgpuDeviceSetDeviceLostCallback__deps: ['$callUserCallback', '$stringToNewUTF8', 'free'],
814814
wgpuDeviceSetDeviceLostCallback: function(deviceId, callback, userdata) {
815815
var deviceWrapper = WebGPU.mgrDevice.objects[deviceId];
816816
{{{ gpu.makeCheckDefined('deviceWrapper') }}}
@@ -2432,7 +2432,7 @@ var LibraryWebGPU = {
24322432
#endif
24332433
},
24342434

2435-
wgpuInstanceRequestAdapter__deps: ['$callUserCallback', '$stringToNewUTF8'],
2435+
wgpuInstanceRequestAdapter__deps: ['$callUserCallback', '$stringToNewUTF8', 'free'],
24362436
wgpuInstanceRequestAdapter: function(instanceId, options, callback, userdata) {
24372437
{{{ gpu.makeCheck('instanceId === 0, "WGPUInstance is ignored"') }}}
24382438

@@ -2513,7 +2513,7 @@ var LibraryWebGPU = {
25132513
return adapter.features.has(WebGPU.FeatureName[featureEnumValue]);
25142514
},
25152515

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

test/other/metadce/test_metadce_cxx_mangle.exports

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ dynCall_viijii
1616
free
1717
getTempRet0
1818
main
19-
malloc
2019
memory
2120
setTempRet0
2221
setThrew
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
219427
1+
219418

0 commit comments

Comments
 (0)