Skip to content

Commit 659988f

Browse files
authored
Run more of out tests with -sNO_DEFAULT_TO_CXX (#21096)
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.
1 parent 7983522 commit 659988f

7 files changed

+16
-17
lines changed

test/common.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,11 @@ def setUp(self):
839839
self.js_engines = config.JS_ENGINES.copy()
840840
self.settings_mods = {}
841841
self.emcc_args = ['-Wclosure', '-Werror', '-Wno-limited-postlink-optimizations']
842+
# TODO(https://github.com/emscripten-core/emscripten/issues/11121)
843+
# For historical reasons emcc compiles and links as C++ by default.
844+
# However we want to run our tests in a more strict manner. We can
845+
# remove this if the issue above is ever fixed.
846+
self.set_setting('NO_DEFAULT_TO_CXX')
842847
self.ldflags = []
843848
# Increate stack trace limit to maximise usefulness of test failure reports
844849
self.node_args = ['--stack-trace-limit=50']
@@ -1042,12 +1047,6 @@ def build(self, filename, libraries=None, includes=None, force_c=False, js_outfi
10421047
filename = test_file(filename)
10431048
suffix = '.js' if js_outfile else '.wasm'
10441049
compiler = [compiler_for(filename, force_c)]
1045-
if compiler[0] == EMCC:
1046-
# TODO(https://github.com/emscripten-core/emscripten/issues/11121)
1047-
# For historical reasons emcc compiles and links as C++ by default.
1048-
# However we want to run our tests in a more strict manner. We can
1049-
# remove this if the issue above is ever fixed.
1050-
compiler.append('-sNO_DEFAULT_TO_CXX')
10511050

10521051
if force_c:
10531052
assert shared.suffix(filename) != '.c', 'force_c is not needed for source files ending in .c'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8390
1+
8359
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
23034
1+
22949
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7219
1+
7187
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19658
1+
19573

test/test_browser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,7 @@ def test_sdl_ogl(self):
15631563
def test_sdl_ogl_regal(self):
15641564
shutil.copyfile(test_file('screenshot.png'), 'screenshot.png')
15651565
self.btest('test_sdl_ogl.c', reference='screenshot-gray-purple.png', reference_slack=1,
1566-
args=['-O2', '--minify=0', '--preload-file', 'screenshot.png', '-sUSE_REGAL', '-DUSE_REGAL', '--use-preload-plugins', '-lSDL', '-lGL'])
1566+
args=['-O2', '--minify=0', '--preload-file', 'screenshot.png', '-sUSE_REGAL', '-DUSE_REGAL', '--use-preload-plugins', '-lSDL', '-lGL', '-lc++', '-lc++abi'])
15671567

15681568
@requires_graphics_hardware
15691569
def test_sdl_ogl_defaultmatrixmode(self):
@@ -2114,13 +2114,13 @@ def test_cubegeom(self, args):
21142114
@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
21152115
@requires_graphics_hardware
21162116
def test_cubegeom_regal(self):
2117-
self.btest('third_party/cubegeom/cubegeom.c', reference='third_party/cubegeom/cubegeom.png', args=['-O2', '-g', '-DUSE_REGAL', '-sUSE_REGAL', '-lGL', '-lSDL'], also_proxied=True)
2117+
self.btest('third_party/cubegeom/cubegeom.c', reference='third_party/cubegeom/cubegeom.png', args=['-O2', '-g', '-DUSE_REGAL', '-sUSE_REGAL', '-lGL', '-lSDL', '-lc++', '-lc++abi'], also_proxied=True)
21182118

21192119
@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
21202120
@requires_threads
21212121
@requires_graphics_hardware
21222122
def test_cubegeom_regal_mt(self):
2123-
self.btest('third_party/cubegeom/cubegeom.c', reference='third_party/cubegeom/cubegeom.png', args=['-O2', '-g', '-pthread', '-DUSE_REGAL', '-pthread', '-sUSE_REGAL', '-lGL', '-lSDL'], also_proxied=False)
2123+
self.btest('third_party/cubegeom/cubegeom.c', reference='third_party/cubegeom/cubegeom.png', args=['-O2', '-g', '-pthread', '-DUSE_REGAL', '-pthread', '-sUSE_REGAL', '-lGL', '-lSDL', '-lc++', '-lc++abi'], also_proxied=False)
21242124

21252125
@no_wasm64('wasm64 + LEGACY_GL_EMULATION')
21262126
@requires_graphics_hardware

test/test_other.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3102,7 +3102,7 @@ def test_embind_tsgen_ignore(self):
31023102
self.assertFileContents(test_file('other/embind_tsgen.d.ts'), read_file('embind_tsgen.d.ts'))
31033103

31043104
def test_embind_tsgen_test_embind(self):
3105-
self.run_process([EMCC, test_file('embind/embind_test.cpp'),
3105+
self.run_process([EMXX, test_file('embind/embind_test.cpp'),
31063106
'-lembind', '--embind-emit-tsd', 'embind_tsgen_test_embind.d.ts',
31073107
# This test explicitly creates std::string from unsigned char pointers
31083108
# which is deprecated in upstream LLVM.
@@ -3118,7 +3118,7 @@ def test_embind_tsgen_val(self):
31183118
self.assertExists('embind_tsgen_val.d.ts')
31193119

31203120
def test_embind_tsgen_bigint(self):
3121-
args = [EMCC, test_file('other/embind_tsgen_bigint.cpp'), '-lembind', '--embind-emit-tsd', 'embind_tsgen_bigint.d.ts']
3121+
args = [EMXX, test_file('other/embind_tsgen_bigint.cpp'), '-lembind', '--embind-emit-tsd', 'embind_tsgen_bigint.d.ts']
31223122
# Check that TypeScript generation fails when code contains bigints but their support is not enabled
31233123
stderr = self.expect_fail(args)
31243124
self.assertContained("Missing primitive type to TS type for 'int64_t", stderr)
@@ -3128,14 +3128,14 @@ def test_embind_tsgen_bigint(self):
31283128

31293129
def test_embind_tsgen_memory64(self):
31303130
# Check that when memory64 is enabled longs & unsigned longs are mapped to bigint in the generated TS bindings
3131-
self.run_process([EMCC, test_file('other/embind_tsgen_memory64.cpp'),
3131+
self.run_process([EMXX, test_file('other/embind_tsgen_memory64.cpp'),
31323132
'-lembind', '--embind-emit-tsd', 'embind_tsgen_memory64.d.ts', '-sMEMORY64', '-Wno-experimental'] +
31333133
self.get_emcc_args())
31343134
self.assertFileContents(test_file('other/embind_tsgen_memory64.d.ts'), read_file('embind_tsgen_memory64.d.ts'))
31353135

31363136
def test_embind_tsgen_exceptions(self):
31373137
# Check that when Wasm exceptions and assertions are enabled bindings still generate.
3138-
self.run_process([EMCC, test_file('other/embind_tsgen.cpp'),
3138+
self.run_process([EMXX, test_file('other/embind_tsgen.cpp'),
31393139
'-lembind', '--embind-emit-tsd', 'embind_tsgen.d.ts', '-fwasm-exceptions', '-sASSERTIONS'])
31403140
self.assertFileContents(test_file('other/embind_tsgen.d.ts'), read_file('embind_tsgen.d.ts'))
31413141

0 commit comments

Comments
 (0)