Skip to content

Commit

Permalink
Run more of out tests with -sNO_DEFAULT_TO_CXX
Browse files Browse the repository at this point in the history
We were previously only applying this flag to tests that use
`self.build` (i.e. most test).  Now we apply it to and even larger set.

The code size changes here only occur in debug builds where we enumerate
all known JS symbols, and there are come JS symbols are the C++ only.
  • Loading branch information
sbc100 committed Jan 17, 2024
1 parent 9fe607b commit 79a612a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
19 changes: 11 additions & 8 deletions test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,11 @@ def setUp(self):
self.js_engines = config.JS_ENGINES.copy()
self.settings_mods = {}
self.emcc_args = ['-Wclosure', '-Werror', '-Wno-limited-postlink-optimizations']
# TODO(https://github.com/emscripten-core/emscripten/issues/11121)
# For historical reasons emcc compiles and links as C++ by default.
# However we want to run our tests in a more strict manner. We can
# remove this if the issue above is ever fixed.
self.set_setting('NO_DEFAULT_TO_CXX')
self.ldflags = []
# Increate stack trace limit to maximise usefulness of test failure reports
self.node_args = ['--stack-trace-limit=50']
Expand Down Expand Up @@ -954,9 +959,13 @@ def has_changed_setting(self, key):
def clear_setting(self, key):
self.settings_mods.pop(key, None)

def serialize_settings(self):
def serialize_settings(self, ldflags=True):
ret = []
# Incomplete list of link-only settings
link_only_settings = ['NO_DEFAULT_TO_CXX']
for key, value in self.settings_mods.items():
if not ldflags and key in link_only_settings:
continue
if value == 1:
ret.append(f'-s{key}')
elif type(value) is list:
Expand Down Expand Up @@ -994,7 +1003,7 @@ def get_emcc_args(self, main_file=False, ldflags=True):
def is_ldflag(f):
return any(f.startswith(s) for s in ['-sENVIRONMENT=', '--pre-js=', '--post-js='])

args = self.serialize_settings() + self.emcc_args
args = self.serialize_settings(ldflags) + self.emcc_args
if ldflags:
args += self.ldflags
else:
Expand Down Expand Up @@ -1034,12 +1043,6 @@ def build(self, filename, libraries=None, includes=None, force_c=False, js_outfi
filename = test_file(filename)
suffix = '.js' if js_outfile else '.wasm'
compiler = [compiler_for(filename, force_c)]
if compiler[0] == EMCC:
# TODO(https://github.com/emscripten-core/emscripten/issues/11121)
# For historical reasons emcc compiles and links as C++ by default.
# However we want to run our tests in a more strict manner. We can
# remove this if the issue above is ever fixed.
compiler.append('-sNO_DEFAULT_TO_CXX')

if force_c:
assert shared.suffix(filename) != '.c', 'force_c is not needed for source files ending in .c'
Expand Down
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_O0.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8422
8391
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_O0.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
23089
23004
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_O0.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7251
7218
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_minimal_O0.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19713
19628

0 comments on commit 79a612a

Please sign in to comment.