Skip to content

Commit edc9686

Browse files
committed
Deprecate RELOCATABLE and LINKABLE settings.
For some tests that use this flag I simply replaced or removed that flag, for others I added `-Wno-deprecated` for now. See: #25262
1 parent eb6fcad commit edc9686

File tree

6 files changed

+21
-32
lines changed

6 files changed

+21
-32
lines changed

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ See docs/process.md for more on how version tagging works.
2020

2121
4.0.15 (in development)
2222
-----------------------
23+
- The `RELOCATABLE` and `LINKABLE` settings were deprecated in favor the higher
24+
level and better supported `MAIN_MODULE` / `SIDE_MODULE` settings. (#25265)
2325
- The `-gsource-map` flag has been updated to be independent of other types of
2426
debugging effects (in particular it no longer causes the wasm binary to have
2527
a name section, and it no longer suppresses minification of the JS output).

test/common.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2221,10 +2221,12 @@ def get_poppler_library(self, env_init=None):
22212221

22222222
return poppler + freetype
22232223

2224-
def get_zlib_library(self, cmake):
2224+
def get_zlib_library(self, cmake, cflags=None):
22252225
assert cmake or not WINDOWS, 'on windows, get_zlib_library only supports cmake'
22262226

22272227
old_args = self.cflags.copy()
2228+
if cflags:
2229+
self.cflags += cflags
22282230
# inflate.c does -1L << 16
22292231
self.cflags.append('-Wno-shift-negative-value')
22302232
# adler32.c uses K&R sytyle function declarations

test/test_browser.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,14 +2003,6 @@ def test_cubegeom_pre(self):
20032003
def test_cubegeom_pre_regal(self):
20042004
self.reftest('third_party/cubegeom/cubegeom_pre.c', 'third_party/cubegeom/cubegeom_pre.png', cflags=['-sUSE_REGAL', '-DUSE_REGAL', '-lGL', '-lSDL', '-lc++', '-lc++abi'])
20052005

2006-
@requires_graphics_hardware
2007-
@no_swiftshader
2008-
def test_cubegeom_pre_relocatable(self):
2009-
# RELOCATABLE needs to be set via `set_setting` so that it will also apply when
2010-
# building `browser_reporting.c`
2011-
self.set_setting('RELOCATABLE')
2012-
self.reftest('third_party/cubegeom/cubegeom_pre.c', 'third_party/cubegeom/cubegeom_pre.png', cflags=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'])
2013-
20142006
@requires_graphics_hardware
20152007
@no_swiftshader
20162008
def test_cubegeom_pre2(self):

test/test_core.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,7 +1844,7 @@ def test_emscripten_api(self):
18441844
self.clear_setting('EXPORTED_FUNCTIONS')
18451845
self.set_setting('EXPORT_ALL')
18461846
self.set_setting('LINKABLE')
1847-
self.do_core_test('test_emscripten_api.c')
1847+
self.do_core_test('test_emscripten_api.c', cflags=['-Wno-deprecated'])
18481848

18491849
def test_emscripten_run_script_string_int(self):
18501850
src = r'''
@@ -5180,8 +5180,7 @@ def test_dylink_spaghetti(self):
51805180
@needs_make('mingw32-make')
51815181
@with_dylink_reversed
51825182
def test_dylink_zlib(self):
5183-
self.set_setting('RELOCATABLE')
5184-
zlib_archive = self.get_zlib_library(cmake=WINDOWS)
5183+
zlib_archive = self.get_zlib_library(cmake=WINDOWS, cflags=['-fPIC'])
51855184
# example.c uses K&R style function declarations
51865185
self.cflags.append('-Wno-deprecated-non-prototype')
51875186
self.cflags.append('-I' + test_file('third_party/zlib'))
@@ -5844,11 +5843,7 @@ def test_std_function_incomplete_return(self):
58445843
self.do_core_test('test_std_function_incomplete_return.cpp')
58455844

58465845
def test_istream(self):
5847-
for linkable in [0]: # , 1]:
5848-
print(linkable)
5849-
# regression check for issue #273
5850-
self.set_setting('LINKABLE', linkable)
5851-
self.do_core_test('test_istream.cpp')
5846+
self.do_core_test('test_istream.cpp')
58525847

58535848
@no_wasmfs('depends on FS.makedev which WASMFS does not have')
58545849
def test_fs_base(self):
@@ -6631,7 +6626,7 @@ def test_cubescript(self):
66316626
@needs_dylink
66326627
def test_relocatable_void_function(self):
66336628
self.set_setting('RELOCATABLE')
6634-
self.do_core_test('test_relocatable_void_function.c')
6629+
self.do_core_test('test_relocatable_void_function.c', cflags=['-Wno-deprecated'])
66356630

66366631
@wasm_simd
66376632
@parameterized({

test/test_other.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,7 +1569,7 @@ def test_export_all(self):
15691569

15701570
# Explicitly test with -Oz to ensure libc_optz is included alongside
15711571
# libc when `--whole-archive` is used.
1572-
self.emcc('lib.c', ['-Oz', '-sEXPORT_ALL', '-sLINKABLE', '--pre-js', 'pre.js'], output_filename='a.out.js')
1572+
self.emcc('lib.c', ['-Oz', '-sEXPORT_ALL', '-sLINKABLE', '-Wno-deprecated', '--pre-js', 'pre.js'], output_filename='a.out.js')
15731573
self.assertContained('libf1\nlibf2\n', self.run_js('a.out.js'))
15741574

15751575
def test_export_keepalive(self):
@@ -2504,21 +2504,21 @@ def test_sdl2_mixer_wav(self):
25042504
def test_sdl2_linkable(self):
25052505
# Ensure that SDL2 can be built with LINKABLE. This implies there are no undefined
25062506
# symbols in the library (because LINKABLE includes the entire library).
2507-
self.emcc(test_file('browser/test_sdl2_misc.c'), ['-sLINKABLE', '-sUSE_SDL=2'], output_filename='a.out.js')
2508-
self.emcc(test_file('browser/test_sdl2_misc.c'), ['-sLINKABLE', '--use-port=sdl2'], output_filename='a.out.js')
2507+
self.emcc(test_file('browser/test_sdl2_misc.c'), ['-sLINKABLE', '-Wno-deprecated', '-sUSE_SDL=2'], output_filename='a.out.js')
2508+
self.emcc(test_file('browser/test_sdl2_misc.c'), ['-sLINKABLE', '-Wno-deprecated', '--use-port=sdl2'], output_filename='a.out.js')
25092509

25102510
def test_sdl3_linkable(self):
25112511
# Ensure that SDL3 can be built with LINKABLE. This implies there are no undefined
25122512
# symbols in the library (because LINKABLE includes the entire library).
25132513
self.cflags.append('-Wno-experimental')
2514-
self.emcc(test_file('browser/test_sdl3_misc.c'), ['-sLINKABLE', '-sUSE_SDL=3'], output_filename='a.out.js')
2515-
self.emcc(test_file('browser/test_sdl3_misc.c'), ['-sLINKABLE', '--use-port=sdl3'], output_filename='a.out.js')
2514+
self.emcc(test_file('browser/test_sdl3_misc.c'), ['-sLINKABLE', '-Wno-deprecated', '-sUSE_SDL=3'], output_filename='a.out.js')
2515+
self.emcc(test_file('browser/test_sdl3_misc.c'), ['-sLINKABLE', '-Wno-deprecated', '--use-port=sdl3'], output_filename='a.out.js')
25162516

25172517
@requires_network
25182518
def test_sdl2_gfx_linkable(self):
25192519
# Same as above but for sdl2_gfx library
2520-
self.emcc(test_file('browser/test_sdl2_misc.c'), ['-Wl,-fatal-warnings', '-sLINKABLE', '-sUSE_SDL_GFX=2'], output_filename='a.out.js')
2521-
self.emcc(test_file('browser/test_sdl2_misc.c'), ['-Wl,-fatal-warnings', '-sLINKABLE', '--use-port=sdl2_gfx'], output_filename='a.out.js')
2520+
self.emcc(test_file('browser/test_sdl2_misc.c'), ['-Wl,-fatal-warnings', '-sLINKABLE', '-Wno-deprecated', '-sUSE_SDL_GFX=2'], output_filename='a.out.js')
2521+
self.emcc(test_file('browser/test_sdl2_misc.c'), ['-Wl,-fatal-warnings', '-sLINKABLE', '-Wno-deprecated', '--use-port=sdl2_gfx'], output_filename='a.out.js')
25222522

25232523
@requires_network
25242524
def test_libpng(self):
@@ -5894,8 +5894,8 @@ def test_no_dynamic_execution(self):
58945894
self.assertNotContained('new Function', src)
58955895
delete_file('a.out.js')
58965896

5897-
# Test that -sDYNAMIC_EXECUTION=0 and -sRELOCATABLE are allowed together.
5898-
self.do_runf('hello_world.c', cflags=['-O1', '-sDYNAMIC_EXECUTION=0', '-sRELOCATABLE'])
5897+
# Test that -sDYNAMIC_EXECUTION=0 and -sMAIN_MODULE are allowed together.
5898+
self.do_runf('hello_world.c', cflags=['-O1', '-sDYNAMIC_EXECUTION=0', '-sMAIN_MODULE'])
58995899

59005900
create_file('test.c', r'''
59015901
#include <emscripten/emscripten.h>
@@ -9228,7 +9228,7 @@ def test_dasho_is_dir(self):
92289228

92299229
@parameterized({
92309230
'': ([],),
9231-
'relocatable': (['-sRELOCATABLE'],),
9231+
'main_module': (['-sMAIN_MODULE'],),
92329232
})
92339233
def test_ctor_ordering(self, args):
92349234
# ctor order must be identical to js builds, deterministically
@@ -13095,10 +13095,6 @@ def test_pthread_mutex_deadlock(self):
1309513095
self.do_runf('other/test_pthread_mutex_deadlock.c', 'pthread mutex deadlock detected',
1309613096
cflags=['-g'], assert_returncode=NON_ZERO)
1309713097

13098-
@node_pthreads
13099-
def test_pthread_relocatable(self):
13100-
self.do_run_in_out_file_test('hello_world.c', cflags=['-sRELOCATABLE'])
13101-
1310213098
@node_pthreads
1310313099
def test_pthread_unavailable(self):
1310413100
# Run a simple hello world program that uses pthreads

tools/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@
124124
'LEGALIZE_JS_FFI': 'to disable JS type legalization use `-sWASM_BIGINT` or `-sSTANDALONE_WASM`',
125125
'ASYNCIFY_EXPORTS': 'please use JSPI_EXPORTS instead',
126126
'USE_WEBGPU': 'please try migrating to --use-port=emdawnwebgpu, which implements a newer, incompatible version of webgpu.h (see tools/ports/emdawnwebgpu.py for more info)',
127+
'LINKABLE': 'scheduled for removal in favor of SIDE_MODULE/MAIN_MODULE (https://github.com/emscripten-core/emscripten/issues/25262)',
128+
'RELOCATABLE': 'scheduled for removal in favor of SIDE_MODULE/MAIN_MODULE (https://github.com/emscripten-core/emscripten/issues/25262)',
127129
}
128130

129131
# Settings that don't need to be externalized when serializing to json because they

0 commit comments

Comments
 (0)