Skip to content

Commit 4f8e3c5

Browse files
committed
Update docs for internal EMSCRIPTEN_VERSION setting. NFC
I proposed removing this internal setting in #25661 but it turns out it was useful for externally managed JS library files. However, I don't think it should be tested as part of emscripten_get_compiler_setting.c since C/C++ can already get the compiler version using VERSION macros, no need for the runtime check. Indeed I hope we can stop exposing any internal settings to emscripten_get_compiler_setting: #25663
1 parent 49fdd76 commit 4f8e3c5

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

src/settings_internal.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ var WASI_MODULE_NAME = "wasi_snapshot_preview1";
107107
var JS_LIBRARIES = [];
108108

109109
// This will contain the emscripten version. This can be useful in combination
110-
// with RETAIN_COMPILER_SETTINGS
110+
// external JS library files that need to check the version of emscripten they
111+
// are being used with.
111112
var EMSCRIPTEN_VERSION = '';
112113

113114
// Will be set to 0 if -fno-rtti is used on the command line.

test/core/emscripten_get_compiler_setting.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ int main() {
1313
printf("INVOKE_RUN: %ld\n", emscripten_get_compiler_setting("INVOKE_RUN"));
1414
assert((unsigned)emscripten_get_compiler_setting("OPT_LEVEL") <= 3);
1515
assert((unsigned)emscripten_get_compiler_setting("DEBUG_LEVEL") <= 4);
16-
printf("EMSCRIPTEN_VERSION: %s\n", (char*)emscripten_get_compiler_setting("EMSCRIPTEN_VERSION"));
16+
printf("CLOSURE_WARNINGS: %s\n", (char*)emscripten_get_compiler_setting("CLOSURE_WARNINGS"));
1717
}
1818

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
INVOKE_RUN: 1
2-
EMSCRIPTEN_VERSION: waka
2+
CLOSURE_WARNINGS: quiet

test/test_core.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,9 +1920,7 @@ def test_emscripten_get_now(self):
19201920
def test_emscripten_get_compiler_setting(self):
19211921
if not self.is_optimizing() and ('-flto' in self.cflags or '-flto=thin' in self.cflags):
19221922
self.skipTest('https://github.com/emscripten-core/emscripten/issues/25015')
1923-
expected = read_file(test_file('core/emscripten_get_compiler_setting.out'))
1924-
expected = expected.replace('waka', utils.EMSCRIPTEN_VERSION)
1925-
self.do_runf('core/emscripten_get_compiler_setting.c', expected, cflags=['-sRETAIN_COMPILER_SETTINGS'])
1923+
self.do_core_test('emscripten_get_compiler_setting.c', cflags=['-sRETAIN_COMPILER_SETTINGS'])
19261924

19271925
def test_emscripten_get_compiler_setting_error(self):
19281926
# with assertions, a runtime error is shown if you try to use the API without RETAIN_COMPILER_SETTINGS

test/test_jslib.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,3 +671,11 @@ def test_jslib_override_system_symbol(self):
671671
# When WebGL is explicitly linked to in strict mode, the linking order on command line should enable overriding.
672672
self.cflags += ['-sAUTO_JS_LIBRARIES=0', '-sMAX_WEBGL_VERSION=2', '-lwebgl.js', '--js-library', test_file('test_jslib_override_system_symbol.js')]
673673
self.do_run_in_out_file_test('test_jslib_override_system_symbol.c')
674+
675+
def test_jslib_version_check(self):
676+
create_file('libfoo.js', '''
677+
#if parseInt(EMSCRIPTEN_VERSION.split('.')[0]) > 3
678+
#error "library does not support emscripten > 3.0.0"
679+
#endif
680+
''')
681+
self.assert_fail([EMCC, '--js-library=libfoo.js'], 'error: libfoo.js:3: #error "library does not support emscripten > 3.0.0"')

0 commit comments

Comments
 (0)