Skip to content

Commit 9dfbe09

Browse files
committed
Drop malloc impl if building with USES_DYNAMIC_ALLOC=0
1 parent 51126cd commit 9dfbe09

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

emcc.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,10 @@ def is_supported_link_flag(f):
12861286
shared.Settings.FETCH = 1
12871287
shared.Settings.SYSTEM_JS_LIBRARIES.append(shared.path_from_root('src', 'library_asmfs.js'))
12881288

1289+
# Explicitly drop linking in a malloc implementation if program is not using any dynamic allocation calls.
1290+
if not shared.Settings.USES_DYNAMIC_ALLOC:
1291+
shared.Settings.MALLOC = 'none'
1292+
12891293
if shared.Settings.MALLOC == 'emmalloc':
12901294
shared.Settings.SYSTEM_JS_LIBRARIES.append(shared.path_from_root('src', 'library_emmalloc.js'))
12911295

tests/test_other.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9559,7 +9559,7 @@ def test_minimal_runtime_code_size(self):
95599559
path_from_root('tests', 'minimal_webgl', 'webgl.c'),
95609560
'--js-library', path_from_root('tests', 'minimal_webgl', 'library_js.js'),
95619561
'-s', 'RUNTIME_FUNCS_TO_IMPORT=[]',
9562-
'-s', 'USES_DYNAMIC_ALLOC=2', '-lGL',
9562+
'-s', 'USES_DYNAMIC_ALLOC=1', '-lGL',
95639563
'-s', 'MODULARIZE=1']
95649564
hello_webgl2_sources = hello_webgl_sources + ['-s', 'MAX_WEBGL_VERSION=2']
95659565

0 commit comments

Comments
 (0)