Skip to content

Commit 2b50627

Browse files
committed
Run more of out tests with -sNO_DEFAULT_TO_CXX
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 c4d76b8 commit 2b50627

File tree

7 files changed

+16
-17
lines changed

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-
8408
1+
8377
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
23069
1+
22984
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7238
1+
7204
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19693
1+
19608

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
@@ -3092,7 +3092,7 @@ def test_embind_tsgen_ignore(self):
30923092
self.assertFileContents(test_file('other/embind_tsgen.d.ts'), read_file('embind_tsgen.d.ts'))
30933093

30943094
def test_embind_tsgen_test_embind(self):
3095-
self.run_process([EMCC, test_file('embind/embind_test.cpp'),
3095+
self.run_process([EMXX, test_file('embind/embind_test.cpp'),
30963096
'-lembind', '--embind-emit-tsd', 'embind_tsgen_test_embind.d.ts',
30973097
# This test explicitly creates std::string from unsigned char pointers
30983098
# which is deprecated in upstream LLVM.
@@ -3108,7 +3108,7 @@ def test_embind_tsgen_val(self):
31083108
self.assertExists('embind_tsgen_val.d.ts')
31093109

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

31193119
def test_embind_tsgen_memory64(self):
31203120
# Check that when memory64 is enabled longs & unsigned longs are mapped to bigint in the generated TS bindings
3121-
self.run_process([EMCC, test_file('other/embind_tsgen_memory64.cpp'),
3121+
self.run_process([EMXX, test_file('other/embind_tsgen_memory64.cpp'),
31223122
'-lembind', '--embind-emit-tsd', 'embind_tsgen_memory64.d.ts', '-sMEMORY64', '-Wno-experimental'] +
31233123
self.get_emcc_args())
31243124
self.assertFileContents(test_file('other/embind_tsgen_memory64.d.ts'), read_file('embind_tsgen_memory64.d.ts'))
31253125

31263126
def test_embind_tsgen_exceptions(self):
31273127
# Check that when Wasm exceptions and assertions are enabled bindings still generate.
3128-
self.run_process([EMCC, test_file('other/embind_tsgen.cpp'),
3128+
self.run_process([EMXX, test_file('other/embind_tsgen.cpp'),
31293129
'-lembind', '--embind-emit-tsd', 'embind_tsgen.d.ts', '-fwasm-exceptions', '-sASSERTIONS'])
31303130
self.assertFileContents(test_file('other/embind_tsgen.d.ts'), read_file('embind_tsgen.d.ts'))
31313131

0 commit comments

Comments
 (0)