Skip to content

Commit d5fbcb1

Browse files
committed
Fix deletion of DEFAULT_LIBRARY_FUNCS_TO_INCLUDE exports
1 parent afcb46c commit d5fbcb1

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

emcc.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,12 @@ def get_last_setting_change(setting):
11091109
# Apply -s settings in newargs here (after optimization levels, so they can override them)
11101110
apply_settings(settings_changes)
11111111

1112+
if shared.Settings.MINIMAL_RUNTIME or 'MINIMAL_RUNTIME=1' in settings_changes:
1113+
# Remove the default exported functions 'malloc', 'free', etc. those should only be linked in if used
1114+
for to_remove in ['malloc', 'free', 'memcpy', 'memset', 'emscripten_get_heap_size']:
1115+
if to_remove in shared.Settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE:
1116+
shared.Settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE.remove(to_remove)
1117+
11121118
shared.verify_settings()
11131119

11141120
def filter_out_dynamic_libs(inputs):
@@ -1249,12 +1255,6 @@ def is_supported_link_flag(f):
12491255

12501256
link_flags = [f for f in link_flags if is_supported_link_flag(f[1])]
12511257

1252-
if shared.Settings.MINIMAL_RUNTIME:
1253-
# Remove the default exported functions 'malloc', 'free', etc. those should only be linked in if used
1254-
for to_remove in ['malloc', 'free', 'memcpy', 'memset']:
1255-
if to_remove in shared.Settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE:
1256-
shared.Settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE.remove(to_remove)
1257-
12581258
if shared.Settings.STACK_OVERFLOW_CHECK:
12591259
if shared.Settings.MINIMAL_RUNTIME:
12601260
shared.Settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$abortStackOverflow']

src/library.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ LibraryManager.library = {
467467
},
468468

469469
emscripten_get_heap_size: function() {
470-
return HEAP8.length;
470+
return HEAPU8.length;
471471
},
472472

473473
emscripten_get_sbrk_ptr__asm: true,

tests/test_other.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9612,11 +9612,11 @@ def test_minimal_runtime_code_size(self):
96129612
]
96139613
else:
96149614
test_cases = [
9615-
(asmjs + opts, hello_world_sources, {'a.html': 1223, 'a.js': 289, 'a.asm.js': 113, 'a.mem': 6}),
9616-
(opts, hello_world_sources, {'a.html': 1205, 'a.js': 633, 'a.wasm': 86}),
9617-
(asmjs + opts, hello_webgl_sources, {'a.html': 1353, 'a.js': 4921, 'a.asm.js': 11129, 'a.mem': 321}),
9618-
(opts, hello_webgl_sources, {'a.html': 1335, 'a.js': 4874, 'a.wasm': 8932}),
9619-
(opts, hello_webgl2_sources, {'a.html': 1335, 'a.js': 5361, 'a.wasm': 8932}) # Compare how WebGL2 sizes stack up with WebGL 1
9615+
(asmjs + opts, hello_world_sources, {'a.html': 1222, 'a.js': 289, 'a.asm.js': 113, 'a.mem': 6}),
9616+
(opts, hello_world_sources, {'a.html': 1204, 'a.js': 630, 'a.wasm': 86}),
9617+
(asmjs + opts, hello_webgl_sources, {'a.html': 1352, 'a.js': 4896, 'a.asm.js': 11129, 'a.mem': 321}),
9618+
(opts, hello_webgl_sources, {'a.html': 1334, 'a.js': 4850, 'a.wasm': 8932}),
9619+
(opts, hello_webgl2_sources, {'a.html': 1334, 'a.js': 5357, 'a.wasm': 8932}) # Compare how WebGL2 sizes stack up with WebGL 1
96209620
]
96219621

96229622
success = True

0 commit comments

Comments
 (0)