From 2396d3e99495fbf3323e9cdb1c120d247f2929cb Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 6 Jan 2025 13:00:42 -0800 Subject: [PATCH] Warn on the incompatibility between source maps and SINGLE_FILE (#23292) Source maps require a source map file, which SINGLE_FILE disallows. We disable source maps in that case, but did not show a warning before this PR. Fixes #23257 --- test/test_other.py | 5 +++++ tools/link.py | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/test/test_other.py b/test/test_other.py index e81bcebcd19e9..5212e19acc812 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -9541,6 +9541,11 @@ def test_single_file_no_clobber_wasm(self): self.assertExists('hello_world.js') self.assertFileContents('hello_world.wasm', 'not wasm') + def test_single_file_disables_source_map(self): + cmd = [EMCC, test_file('hello_world.c'), '-sSINGLE_FILE', '-gsource-map'] + stderr = self.run_process(cmd, stderr=PIPE).stderr + self.assertContained('warning: SINGLE_FILE disables source map support', stderr) + def test_wasm2js_no_clobber_wasm(self): create_file('hello_world.wasm', 'not wasm') self.do_runf('hello_world.c', emcc_args=['-sWASM=0']) diff --git a/tools/link.py b/tools/link.py index 6bf9b2abc8573..016ebeb51cefa 100644 --- a/tools/link.py +++ b/tools/link.py @@ -1501,7 +1501,8 @@ def phase_linker_setup(options, state, newargs): # noqa: C901, PLR0912, PLR0915 if settings.WASM_BIGINT: settings.LEGALIZE_JS_FFI = 0 - if settings.SINGLE_FILE: + if settings.SINGLE_FILE and settings.GENERATE_SOURCE_MAP: + diagnostics.warning('emcc', 'SINGLE_FILE disables source map support (which requires a .map file)') settings.GENERATE_SOURCE_MAP = 0 if settings.EVAL_CTORS: