Skip to content

Commit b6d85fe

Browse files
authored
Remove EM_LOG_C_STACK feature of emscripten_log (#23553)
This was supported by `emscripten-source-map.min.js` which seems like minified source map parser, but I don't think this feature has worked for at least 4 years since we switched to using wasm and wasm source maps. This feature was part of `emscripten_log` since it was first added in 26d6ad3 but I know of anyone that ever used it. Fixes: #13089
1 parent 4819c27 commit b6d85fe

8 files changed

+15
-72
lines changed

.gitattributes

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ tools/crunch-worker.js -diff
44
third_party/lzma.js/lzma-decoder.js -diff
55
third_party/lzma.js/lzma-full.js -diff
66
test/other/test_emsize.js -diff
7-
src/emscripten-source-map.min.js -diff
87
test/* linguist-vendored
98
third_party/* linguist-vendored
109
system/ linguist-vendored

ChangeLog.md

+6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ See docs/process.md for more on how version tagging works.
2525
emcc itself. This enables support for C++20 in cmake projects. (#21987)
2626
- The version of python required to run emscripten was bumped from 3.6 to 3.8.
2727
(#23417)
28+
- The `EM_LOG_C_STACK` flag to `emscripten_log` was deprecated and the helper
29+
file on which it was based (`emscripten-source-map.min.js`) deleted. This
30+
feature (userspace source map parsing in logs) was never ported to wasm
31+
source maps, so it has not worked in many years, and there have been no
32+
requests for it. This has no impact on the source map support in browser
33+
devtools. (#23553)
2834

2935
4.0.2 - 01/30/25
3036
----------------

eslint.config.mjs

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export default [{
4747
'src/gl-matrix.js',
4848
'src/headless.js',
4949
'src/headlessCanvas.js',
50-
'src/emscripten-source-map.min.js',
5150
'src/source_map_support.js',
5251
'src/Fetch.js',
5352
'src/settings.js',

src/emscripten-source-map.min.js

-32
This file was deleted.

src/lib/libstack_trace.js

+6-20
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@ var LibraryStackTrace = {
2020
var iNextLine = callstack.indexOf('\n', Math.max(iThisFunc, iThisFunc2))+1;
2121
callstack = callstack.slice(iNextLine);
2222

23-
// If user requested to see the original source stack, but no source map
24-
// information is available, just fall back to showing the JS stack.
25-
if (flags & {{{ cDefs.EM_LOG_C_STACK }}} && typeof emscripten_source_map == 'undefined') {
26-
warnOnce('Source map information is not available, emscripten_log with EM_LOG_C_STACK will be ignored. Build with "--pre-js $EMSCRIPTEN/src/emscripten-source-map.min.js" linker flag to add source map loading to code.');
27-
flags ^= {{{ cDefs.EM_LOG_C_STACK }}};
28-
flags |= {{{ cDefs.EM_LOG_JS_STACK }}};
23+
#if ASSERTIONS
24+
if (flags & {{{ cDefs.EM_LOG_C_STACK }}}) {
25+
warnOnce('emscripten_log with EM_LOG_C_STACK no longer has any effect');
2926
}
27+
#endif
3028

3129
// Process all lines:
3230
var lines = callstack.split('\n');
@@ -72,23 +70,11 @@ var LibraryStackTrace = {
7270
}
7371
}
7472

75-
var haveSourceMap = false;
76-
77-
if (flags & {{{ cDefs.EM_LOG_C_STACK }}}) {
78-
var orig = emscripten_source_map.originalPositionFor({line: lineno, column: column});
79-
haveSourceMap = orig?.source;
80-
if (haveSourceMap) {
81-
if (flags & {{{ cDefs.EM_LOG_NO_PATHS }}}) {
82-
orig.source = orig.source.substring(orig.source.replace(/\\/g, "/").lastIndexOf('/')+1);
83-
}
84-
callstack += ` at ${symbolName} (${orig.source}:${orig.line}:${orig.column})\n`;
85-
}
86-
}
87-
if ((flags & {{{ cDefs.EM_LOG_JS_STACK }}}) || !haveSourceMap) {
73+
if ((flags & {{{ cDefs.EM_LOG_C_STACK | cDefs.EM_LOG_JS_STACK }}})) {
8874
if (flags & {{{ cDefs.EM_LOG_NO_PATHS }}}) {
8975
file = file.substring(file.replace(/\\/g, "/").lastIndexOf('/')+1);
9076
}
91-
callstack += (haveSourceMap ? (` = ${symbolName}`) : (` at ${symbolName}`)) + ` (${file}:${lineno}:${column})\n`;
77+
callstack += ` at ${symbolName} (${file}:${lineno}:${column})\n`;
9278
}
9379
}
9480
// Trim extra whitespace at the end of the output.

test/emscripten_log/emscripten_log.cpp

+1-13
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ void __attribute__((noinline)) bar(int = 0, char * = 0, double = 0) {
5353
MYASSERT(1 == 1, "");
5454

5555
int flags = EM_LOG_NO_PATHS | EM_LOG_JS_STACK | EM_LOG_FUNC_PARAMS;
56-
#ifndef RUN_FROM_JS_SHELL
57-
flags |= EM_LOG_C_STACK;
58-
#endif
5956

6057
// We can programmatically get the callstack.
6158
// 1. Ask for callstack length:
@@ -79,16 +76,7 @@ void __attribute__((noinline)) bar(int = 0, char * = 0, double = 0) {
7976
8077
but the line numbers will greatly vary depending on the mode we are compiling in, so cannot test with direct string comparison. */
8178

82-
if ((flags & EM_LOG_C_STACK) != 0) {
83-
// TODO(https://github.com/emscripten-core/emscripten/issues/13089)
84-
// We should be able to check for emscripten_log.cpp here but sadly
85-
// source maps seems to be broken under wasm.
86-
#if 0
87-
MYASSERT(!!strstr(callstack, ".cpp:"), "Callstack was %s!", callstack);
88-
#endif
89-
} else {
90-
MYASSERT(!!strstr(callstack, ".js:"), "Callstack was %s!", callstack);
91-
}
79+
MYASSERT(!!strstr(callstack, ".js:"), "Callstack was %s!", callstack);
9280
MYASSERT(!!strstr(callstack, "bar(int, char*, double)"), "Callstack was %s!", callstack);
9381
MYASSERT(!!strstr(callstack, "void Foo<int>()"), "Callstack was %s!", callstack);
9482

test/test_browser.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,7 @@ def test_zzz_html_source_map(self):
356356
''')
357357

358358
def test_emscripten_log(self):
359-
self.btest_exit('emscripten_log/emscripten_log.cpp',
360-
args=['-Wno-deprecated-pragma', '--pre-js', path_from_root('src/emscripten-source-map.min.js'), '-gsource-map'])
359+
self.btest_exit('emscripten_log/emscripten_log.cpp', args=['-Wno-deprecated-pragma', '-gsource-map'])
361360

362361
@also_with_wasmfs
363362
def test_preload_file(self):

test/test_core.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -7864,9 +7864,7 @@ def test_modularize_closure_pre(self):
78647864
@no_wasm2js('symbol names look different wasm2js backtraces')
78657865
@also_with_wasm_bigint
78667866
def test_emscripten_log(self):
7867-
if '-g' not in self.emcc_args:
7868-
self.emcc_args.append('-g')
7869-
self.emcc_args += ['-DRUN_FROM_JS_SHELL', '-Wno-deprecated-pragma']
7867+
self.emcc_args += ['-g', '-DRUN_FROM_JS_SHELL', '-Wno-deprecated-pragma']
78707868
self.do_run_in_out_file_test('emscripten_log/emscripten_log.cpp', interleaved_output=False)
78717869
# test closure compiler as well
78727870
if self.maybe_closure():

0 commit comments

Comments
 (0)