Skip to content

Commit 4e442df

Browse files
authored
Enable MINIMAL_RUNTIME code size tests for Wasm backend (#10116)
* Enable MINIMAL_RUNTIME code size tests for Wasm backend * Add in debugging for JS libraries. Remove unnecessary function maybeAddGLDep(). * Debug macOS box * Restore mac CI and fix GL linkage * Update code size in test
1 parent 4111bd1 commit 4e442df

File tree

4 files changed

+23
-24
lines changed

4 files changed

+23
-24
lines changed

src/library_html5.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2388,7 +2388,11 @@ var LibraryJSEvents = {
23882388
// for all the messages, one of which is this GL-using one. This won't be
23892389
// called if GL is not linked in, but also make sure to not add a dep on
23902390
// GL unnecessarily from here, as that would cause a linker error.
2391-
emscripten_webgl_do_create_context__deps: maybeAddGLDep(['$JSEvents', '_emscripten_webgl_power_preferences', '_findEventTarget', '_findCanvasEventTarget']),
2391+
emscripten_webgl_do_create_context__deps: [
2392+
#if LibraryManager.has('library_webgl.js')
2393+
'$GL',
2394+
#endif
2395+
'$JSEvents', '_emscripten_webgl_power_preferences', '_findEventTarget', '_findCanvasEventTarget'],
23922396
// This function performs proxying manually, depending on the style of context that is to be created.
23932397
emscripten_webgl_do_create_context: function(target, attributes) {
23942398
#if ASSERTIONS

src/modules.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -526,16 +526,3 @@ var PassManager = {
526526
*/
527527
}
528528
};
529-
530-
// Given a list of dependencies, maybe add GL to it, if it was linked in
531-
// (note that the item with this list of dependencies should not call GL code
532-
// if it is not; this just avoids even adding a dependency that would error).
533-
// This only matters in strict mode (specifically AUTO_JS_LIBRARIES=0), as in
534-
// non-strict mode the GL library is always linked in anyhow.
535-
function maybeAddGLDep(deps) {
536-
if (AUTO_JS_LIBRARIES ||
537-
SYSTEM_JS_LIBRARIES.indexOf('library_webgl.js') >= 0) {
538-
deps.push('$GL');
539-
}
540-
return deps;
541-
}

tests/test_other.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9543,7 +9543,6 @@ def test(wasm, closure, opt):
95439543
test(['-s', 'WASM=0'], closure, opt)
95449544
test(['-s', 'WASM=1', '-s', 'WASM_ASYNC_COMPILATION=0'], closure, opt)
95459545

9546-
@no_wasm_backend('tests asmjs, sizes sensitive to fastcomp')
95479546
def test_minimal_runtime_code_size(self):
95489547
smallest_code_size_args = ['-s', 'MINIMAL_RUNTIME=2',
95499548
'-s', 'AGGRESSIVE_VARIABLE_ELIMINATION=1',
@@ -9575,17 +9574,24 @@ def test_minimal_runtime_code_size(self):
95759574
path_from_root('tests', 'minimal_webgl', 'webgl.c'),
95769575
'--js-library', path_from_root('tests', 'minimal_webgl', 'library_js.js'),
95779576
'-s', 'RUNTIME_FUNCS_TO_IMPORT=[]',
9578-
'-s', 'USES_DYNAMIC_ALLOC=2', '-lGL',
9577+
'-s', 'USES_DYNAMIC_ALLOC=2', '-lwebgl.js',
95799578
'-s', 'MODULARIZE=1']
95809579
hello_webgl2_sources = hello_webgl_sources + ['-s', 'MAX_WEBGL_VERSION=2']
95819580

9582-
test_cases = [
9583-
(asmjs + opts, hello_world_sources, {'a.html': 1483, 'a.js': 289, 'a.asm.js': 113, 'a.mem': 6}),
9584-
(opts, hello_world_sources, {'a.html': 1440, 'a.js': 604, 'a.wasm': 86}),
9585-
(asmjs + opts, hello_webgl_sources, {'a.html': 1606, 'a.js': 4880, 'a.asm.js': 11139, 'a.mem': 321}),
9586-
(opts, hello_webgl_sources, {'a.html': 1557, 'a.js': 4837, 'a.wasm': 8841}),
9587-
(opts, hello_webgl2_sources, {'a.html': 1557, 'a.js': 5324, 'a.wasm': 8841}) # Compare how WebGL2 sizes stack up with WebGL 1
9588-
]
9581+
if self.is_wasm_backend():
9582+
test_cases = [
9583+
(opts, hello_world_sources, {'a.html': 1445, 'a.js': 455, 'a.wasm': 176}),
9584+
(opts, hello_webgl_sources, {'a.html': 1565, 'a.js': 4636, 'a.wasm': 11918}),
9585+
(opts, hello_webgl2_sources, {'a.html': 1565, 'a.js': 5143, 'a.wasm': 11918}) # Compare how WebGL2 sizes stack up with WebGL 1
9586+
]
9587+
else:
9588+
test_cases = [
9589+
(asmjs + opts, hello_world_sources, {'a.html': 1483, 'a.js': 289, 'a.asm.js': 113, 'a.mem': 6}),
9590+
(opts, hello_world_sources, {'a.html': 1440, 'a.js': 604, 'a.wasm': 86}),
9591+
(asmjs + opts, hello_webgl_sources, {'a.html': 1606, 'a.js': 4880, 'a.asm.js': 11139, 'a.mem': 321}),
9592+
(opts, hello_webgl_sources, {'a.html': 1557, 'a.js': 4837, 'a.wasm': 8841}),
9593+
(opts, hello_webgl2_sources, {'a.html': 1557, 'a.js': 5324, 'a.wasm': 8841}) # Compare how WebGL2 sizes stack up with WebGL 1
9594+
]
95899595

95909596
success = True
95919597

tools/shared.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2890,7 +2890,9 @@ def path_to_system_js_libraries(library_name):
28902890
library_files = []
28912891
if library_name in js_system_libraries:
28922892
if len(js_system_libraries[library_name]):
2893-
library_files += js_system_libraries[library_name] if isinstance(js_system_libraries[library_name], list) else [js_system_libraries[library_name]]
2893+
lib = js_system_libraries[library_name] if isinstance(js_system_libraries[library_name], list) else [js_system_libraries[library_name]]
2894+
library_files += lib
2895+
logger.debug('Linking in JS library ' + str(lib))
28942896

28952897
elif library_name.endswith('.js') and os.path.isfile(path_from_root('src', 'library_' + library_name)):
28962898
library_files += ['library_' + library_name]

0 commit comments

Comments
 (0)