Skip to content

Commit 26fcac5

Browse files
committed
Remove references to RELOCATABLE/LINKABLE from test code. NFC
These settings are due for deprecation/removal, plus none of these tests were really depending on them specifically (as opposed to dynamic linking in general). See #25262
1 parent cf323dc commit 26fcac5

File tree

3 files changed

+38
-43
lines changed

3 files changed

+38
-43
lines changed

test/test_core.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,15 +1854,14 @@ def test_set_align(self):
18541854
self.do_core_test('test_set_align.c')
18551855

18561856
@no_modularize_instance('uses Module object directly')
1857-
@no_js_math('JS_MATH is not compatible with LINKABLE')
18581857
@parameterized({
18591858
'': (['-sEXPORTED_FUNCTIONS=_main,_save_me_aimee'],),
18601859
# test EXPORT_ALL too
1861-
'export_all': (['-Wno-deprecated', '-sEXPORT_ALL', '-sLINKABLE'],),
1860+
'export_all': (['-sEXPORT_ALL', '-sMAIN_MODULE'],),
18621861
})
18631862
def test_emscripten_api(self, args):
1864-
if '-sLINKABLE' in args and '-lllvmlibc' in self.cflags:
1865-
self.skipTest('LLVM-libc overlay mode is not compatible with whole-archive (LINKABLE)')
1863+
if '-sMAIN_MODULE' in args:
1864+
self.check_dylink()
18661865
self.do_core_test('test_emscripten_api.c', cflags=args)
18671866

18681867
def test_emscripten_run_script_string_int(self):
@@ -6646,8 +6645,7 @@ def test_cubescript(self):
66466645

66476646
@needs_dylink
66486647
def test_relocatable_void_function(self):
6649-
self.set_setting('RELOCATABLE')
6650-
self.do_core_test('test_relocatable_void_function.c', cflags=['-Wno-deprecated'])
6648+
self.do_core_test('test_relocatable_void_function.c', cflags=['-sMAIN_MODULE=2'])
66516649

66526650
@wasm_simd
66536651
@parameterized({

test/test_other.py

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,12 +1580,11 @@ def test_dot_a_all_contents_invalid(self):
15801580
self.assertContained(['unknown file type', "libfoo.a: archive member 'native.o' is neither Wasm object file nor LLVM bitcode"], stderr)
15811581

15821582
def test_export_all(self):
1583-
lib = r'''
1583+
create_file('main.c', r'''
15841584
#include <stdio.h>
15851585
void libf1() { printf("libf1\n"); }
15861586
void libf2() { printf("libf2\n"); }
1587-
'''
1588-
create_file('lib.c', lib)
1587+
''')
15891588

15901589
create_file('pre.js', '''
15911590
Module.onRuntimeInitialized = () => {
@@ -1596,8 +1595,10 @@ def test_export_all(self):
15961595

15971596
# Explicitly test with -Oz to ensure libc_optz is included alongside
15981597
# libc when `--whole-archive` is used.
1599-
self.emcc('lib.c', ['-Oz', '-sEXPORT_ALL', '-sLINKABLE', '-Wno-deprecated', '--pre-js', 'pre.js'], output_filename='a.out.js')
1600-
self.assertContained('libf1\nlibf2\n', self.run_js('a.out.js'))
1598+
self.do_runf('main.c', 'libf1\nlibf2\n', cflags=['-Oz', '-sEXPORT_ALL', '-sMAIN_MODULE', '--pre-js', 'pre.js'])
1599+
1600+
# Without the `-sEXPORT_ALL` these symbols will not be visible from JS
1601+
self.do_runf('main.c', '_libf1 is not defined', assert_returncode=NON_ZERO, cflags=['-Oz', '-sMAIN_MODULE', '--pre-js', 'pre.js'])
16011602

16021603
def test_export_keepalive(self):
16031604
create_file('main.c', r'''
@@ -2532,23 +2533,23 @@ def test_sdl2_mixer_wav(self):
25322533
self.emcc('browser/test_sdl2_mixer_wav.c', ['--use-port=sdl2_mixer:formats=ogg'], output_filename='a.out.js')
25332534

25342535
def test_sdl2_linkable(self):
2535-
# Ensure that SDL2 can be built with LINKABLE. This implies there are no undefined
2536-
# symbols in the library (because LINKABLE includes the entire library).
2537-
self.emcc('browser/test_sdl2_misc.c', ['-sLINKABLE', '-Wno-deprecated', '-sUSE_SDL=2'], output_filename='a.out.js')
2538-
self.emcc('browser/test_sdl2_misc.c', ['-sLINKABLE', '-Wno-deprecated', '--use-port=sdl2'], output_filename='a.out.js')
2536+
# Ensure that SDL2 can be built with MAIN_MODULE. This implies there are no undefined
2537+
# symbols in the library (because MAIN_MODULE=1 includes the entire library).
2538+
self.emcc('browser/test_sdl2_misc.c', ['-sMAIN_MODULE', '-sUSE_SDL=2'], output_filename='a.out.js')
2539+
self.emcc('browser/test_sdl2_misc.c', ['-sMAIN_MODULE', '--use-port=sdl2'], output_filename='a.out.js')
25392540

25402541
def test_sdl3_linkable(self):
2541-
# Ensure that SDL3 can be built with LINKABLE. This implies there are no undefined
2542-
# symbols in the library (because LINKABLE includes the entire library).
2542+
# Ensure that SDL3 can be built with MAIN_MODULE. This implies there are no undefined
2543+
# symbols in the library (because MAIN_MODULE=1 includes the entire library).
25432544
self.cflags.append('-Wno-experimental')
2544-
self.emcc('browser/test_sdl3_misc.c', ['-sLINKABLE', '-Wno-deprecated', '-sUSE_SDL=3'], output_filename='a.out.js')
2545-
self.emcc('browser/test_sdl3_misc.c', ['-sLINKABLE', '-Wno-deprecated', '--use-port=sdl3'], output_filename='a.out.js')
2545+
self.emcc('browser/test_sdl3_misc.c', ['-sMAIN_MODULE', '-sUSE_SDL=3'], output_filename='a.out.js')
2546+
self.emcc('browser/test_sdl3_misc.c', ['-sMAIN_MODULE', '--use-port=sdl3'], output_filename='a.out.js')
25462547

25472548
@requires_network
25482549
def test_sdl2_gfx_linkable(self):
25492550
# Same as above but for sdl2_gfx library
2550-
self.emcc('browser/test_sdl2_misc.c', ['-Wl,-fatal-warnings', '-sLINKABLE', '-Wno-deprecated', '-sUSE_SDL_GFX=2'], output_filename='a.out.js')
2551-
self.emcc('browser/test_sdl2_misc.c', ['-Wl,-fatal-warnings', '-sLINKABLE', '-Wno-deprecated', '--use-port=sdl2_gfx'], output_filename='a.out.js')
2551+
self.emcc('browser/test_sdl2_misc.c', ['-Wl,-fatal-warnings', '-sMAIN_MODULE', '-sUSE_SDL_GFX=2'], output_filename='a.out.js')
2552+
self.emcc('browser/test_sdl2_misc.c', ['-Wl,-fatal-warnings', '-sMAIN_MODULE', '--use-port=sdl2_gfx'], output_filename='a.out.js')
25522553

25532554
@requires_network
25542555
def test_libpng(self):
@@ -5733,9 +5734,9 @@ def test_bad_function_pointer_cast(self, opts, wasm, safe):
57335734
''')
57345735

57355736
for emulate_casts in (0, 1):
5736-
for relocatable in (0, 1):
5737-
# wasm2js is not compatible with relocatable mode
5738-
if not wasm and relocatable:
5737+
for dylink in (0, 1):
5738+
# wasm2js is not compatible with dynamic linking
5739+
if dylink and not wasm:
57395740
continue
57405741
cmd = [EMXX, 'src.cpp'] + opts
57415742
if not wasm:
@@ -5744,8 +5745,8 @@ def test_bad_function_pointer_cast(self, opts, wasm, safe):
57445745
cmd += ['-sSAFE_HEAP']
57455746
if emulate_casts:
57465747
cmd += ['-sEMULATE_FUNCTION_POINTER_CASTS']
5747-
if relocatable:
5748-
cmd += ['-sRELOCATABLE'] # disables asm-optimized safe heap
5748+
if dylink:
5749+
cmd += ['-sMAIN_MODULE=2'] # disables asm-optimized safe heap
57495750
print(cmd)
57505751
self.run_process(cmd)
57515752
returncode = 0 if emulate_casts or not wasm else NON_ZERO
@@ -12776,10 +12777,10 @@ def test_pthread_export_es6(self, args):
1277612777
self.assertContained('hello, world!', output)
1277712778

1277812779
def test_wasm2js_no_dylink(self):
12779-
for arg in ('-sMAIN_MODULE', '-sSIDE_MODULE', '-sRELOCATABLE'):
12780+
for arg in ('-sMAIN_MODULE', '-sSIDE_MODULE'):
1278012781
print(arg)
1278112782
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sWASM=0', arg])
12782-
self.assertContained('emcc: error: WASM2JS is not compatible with RELOCATABLE', err)
12783+
self.assertContained(r'emcc: error: WASM2JS is not compatible with .*_MODULE \(wasm2js does not support dynamic linking\)', err, regex=True)
1278312784

1278412785
def test_wasm2js_standalone(self):
1278512786
self.do_run_in_out_file_test('hello_world.c', cflags=['-sSTANDALONE_WASM', '-sWASM=0'])
@@ -13015,12 +13016,12 @@ def test_gen_struct_info_env(self):
1301513016
with env_modify({'EMCC_CFLAGS': '-O2 BAD_ARG', 'EMCC_FORCE_STDLIBS': '1', 'EMCC_ONLY_FORCED_STDLIBS': '1'}):
1301613017
self.run_process([PYTHON, path_from_root('tools/gen_struct_info.py'), '-o', 'out.json'])
1301713018

13018-
def test_relocatable_limited_exports(self):
13019-
# Building with RELOCATABLE should *not* automatically export all sybmols.
13020-
self.run_process([EMCC, test_file('hello_world.c'), '-sRELOCATABLE', '-o', 'out.wasm'])
13019+
def test_dylink_limited_exports(self):
13020+
# Building with MAIN_MODULE=2 should *not* automatically export all sybmols.
13021+
self.run_process([EMCC, test_file('hello_world.c'), '-sMAIN_MODULE=2', '-o', 'out.wasm'])
1302113022

13022-
# Building with RELOCATABLE + LINKABLE should include and export all of the standard library
13023-
self.run_process([EMCC, test_file('hello_world.c'), '-sRELOCATABLE', '-sLINKABLE', '-o', 'out_linkable.wasm'])
13023+
# Building with MAIN_MODULE=1 should include and export all of the standard library
13024+
self.run_process([EMCC, test_file('hello_world.c'), '-sMAIN_MODULE', '-o', 'out_linkable.wasm'])
1302413025

1302513026
exports = self.parse_wasm('out.wasm')[1]
1302613027
exports_linkable = self.parse_wasm('out_linkable.wasm')[1]
@@ -13211,18 +13212,13 @@ def test_reverse_deps_allow_undefined(self):
1321113212
''')
1321213213
self.do_runf('test.c', cflags=['-sERROR_ON_UNDEFINED_SYMBOLS=0'])
1321313214

13214-
@parameterized({
13215-
'relocatable': ('-sRELOCATABLE',),
13216-
'linkable': ('-sLINKABLE',),
13217-
'main_module': ('-sMAIN_MODULE',),
13218-
})
13219-
def test_check_undefined(self, flag):
13215+
def test_dylink_undefined(self):
1322013216
# positive case: no undefined symbols
13221-
self.run_process([EMCC, flag, '-sERROR_ON_UNDEFINED_SYMBOLS', test_file('hello_world.c')])
13217+
self.run_process([EMCC, '-sMAIN_MODULE', test_file('hello_world.c')])
1322213218
self.run_js('a.out.js')
1322313219

1322413220
# negative case: foo is undefined in test_check_undefined.c
13225-
err = self.expect_fail([EMCC, flag, '-sERROR_ON_UNDEFINED_SYMBOLS', test_file('other/test_check_undefined.c')])
13221+
err = self.expect_fail([EMCC, '-sMAIN_MODULE', test_file('other/test_check_undefined.c')])
1322613222
self.assertContained('undefined symbol: foo', err)
1322713223

1322813224
@also_with_wasm64
@@ -14125,7 +14121,7 @@ def test_wasm_worker_errors(self):
1412514121
self.assertContained('-sSINGLE_FILE is not supported with -sWASM_WORKERS', err)
1412614122
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sWASM_WORKERS', '-sPROXY_TO_WORKER'])
1412714123
self.assertContained('-sPROXY_TO_WORKER is not supported with -sWASM_WORKERS', err)
14128-
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sWASM_WORKERS', '-sRELOCATABLE'])
14124+
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sWASM_WORKERS', '-sMAIN_MODULE'])
1412914125
self.assertContained('dynamic linking is not supported with -sWASM_WORKERS', err)
1413014126

1413114127
def test_clock_nanosleep(self):

tools/settings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@
137137
# List of incompatible settings, of the form (SETTINGS_A, SETTING_B, OPTIONAL_REASON_FOR_INCOMPAT)
138138
INCOMPATIBLE_SETTINGS = [
139139
('MINIMAL_RUNTIME', 'RELOCATABLE', None),
140-
('WASM2JS', 'RELOCATABLE', None),
140+
('WASM2JS', 'MAIN_MODULE', 'wasm2js does not support dynamic linking'),
141+
('WASM2JS', 'SIDE_MODULE', 'wasm2js does not support dynamic linking'),
141142
('MODULARIZE', 'PROXY_TO_WORKER', 'if you want to run in a worker with -sMODULARIZE, you likely want to do the worker side setup manually'),
142143
('MODULARIZE', 'NO_DECLARE_ASM_MODULE_EXPORTS', None),
143144
('EVAL_CTORS', 'WASM2JS', None),

0 commit comments

Comments
 (0)