Skip to content

Commit 1f2c4bc

Browse files
committed
Don't include internal compiler settings with RETAIN_COMPILER_SETTINGS
This is technically a breaking change so I mentioned it in the ChangeLog. Fixes: #25663
1 parent f69a8f6 commit 1f2c4bc

File tree

6 files changed

+15
-13
lines changed

6 files changed

+15
-13
lines changed

ChangeLog.md

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

2121
4.0.19 (in development)
2222
-----------------------
23+
- The `RETAIN_COMPILER_SETTINGS` settings and the corresponding
24+
`emscripten_get_compiler_setting` API not longer store or report internal
25+
compiler settings (this listed in `setttings_internal.js`). (#25667)
2326

2427
4.0.18 - 10/24/25
2528
-----------------

src/parseTools.mjs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -806,17 +806,8 @@ function addAtPostRun(code) {
806806

807807
function makeRetainedCompilerSettings() {
808808
const ret = {};
809-
for (const [name, value] of Object.entries(global)) {
810-
if (name[0] !== '_' && name == name.toUpperCase()) {
811-
if (
812-
typeof value == 'number' ||
813-
typeof value == 'boolean' ||
814-
typeof value == 'string' ||
815-
Array.isArray(name)
816-
) {
817-
ret[name] = value;
818-
}
819-
}
809+
for (const name of PUBLIC_SETTINGS) {
810+
ret[name] = globalThis[name];
820811
}
821812
return ret;
822813
}

src/settings_internal.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,6 @@ var OUTPUT_FORMAT = '';
278278
var LOAD_SOURCE_MAP = false;
279279

280280
var ALIASES = [];
281+
282+
// List of public setting names (Used by RETAIN_COMPILER_SETTINGS)
283+
var PUBLIC_SETTINGS = [];

test/core/emscripten_get_compiler_setting.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
#include <emscripten.h>
1111

1212
int main() {
13+
// Test boolean, int, and string settings
1314
printf("INVOKE_RUN: %ld\n", emscripten_get_compiler_setting("INVOKE_RUN"));
14-
assert((unsigned)emscripten_get_compiler_setting("OPT_LEVEL") <= 3);
15-
assert((unsigned)emscripten_get_compiler_setting("DEBUG_LEVEL") <= 4);
15+
assert((unsigned)emscripten_get_compiler_setting("ASSERTIONS") <= 2);
1616
printf("CLOSURE_WARNINGS: %s\n", (char*)emscripten_get_compiler_setting("CLOSURE_WARNINGS"));
17+
18+
printf("EMSCRIPTEN_VERSION: %s\n", (char*)emscripten_get_compiler_setting("EMSCRIPTEN_VERSION"));
1719
}
1820

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
INVOKE_RUN: 1
22
CLOSURE_WARNINGS: quiet
3+
EMSCRIPTEN_VERSION: invalid compiler setting: EMSCRIPTEN_VERSION

tools/link.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,6 +1806,8 @@ def get_full_import_name(name):
18061806
'emscripten_stack_get_end']
18071807

18081808
settings.EMSCRIPTEN_VERSION = utils.EMSCRIPTEN_VERSION
1809+
if settings.RETAIN_COMPILER_SETTINGS:
1810+
settings.PUBLIC_SETTINGS = [k for k in settings.attrs.keys() if k not in settings.internal_settings]
18091811
settings.SOURCE_MAP_BASE = options.source_map_base or ''
18101812

18111813
settings.LINK_AS_CXX = (shared.run_via_emxx or settings.DEFAULT_TO_CXX) and not options.nostdlibxx

0 commit comments

Comments
 (0)