Skip to content

Report JS compiler warnings once, as emcc: warning: ... [-Wjs-compiler] - #28462

Open
juj wants to merge 1 commit into
emscripten-core:mainfrom
juj:js_library_warning_once
Open

juj wants to merge 1 commit into
emscripten-core:mainfrom
juj:js_library_warning_once

Conversation

@juj

@juj juj commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Fix a single #warning statement emitting multiple lines of warnings.

Fixes: #26577

…er]`

A `#warning` in a JS library was reported three times on the first build:

  warning: liba.js:1: #warning This is a test.
  warning: liba.js:1: #warning This is a test.
  emcc: warning: warnings in JS library compilation [-Wjs-compiler]

The JS compiler runs twice per link, first to list the available JS
symbols and then to generate the JS output, and both runs printed the
warning.  The third line was then added by emcc.  Now we get:

  emcc: warning: liba.js:1: #warning This is a test. [-Wjs-compiler]

- The symbol listing run no longer prints warnings when the run that
  generates JS follows it.  When it is the only run (wasm-only output,
  side modules) it still prints them, and its result is no longer cached
  in that case, since a cache hit would hide them on later builds.
- The JS compiler reports its warnings in the same form as emcc's own:
  prefixed with the name of the tool, as clang does for its driver
  warnings, and tagged with `[-Wjs-compiler]`.  The tag is left off when
  the message already names a more specific flag, as the `-Wdeprecated`
  warning for legacy library symbols does.
- `-Wno-js-compiler` now suppresses these warnings.  Previously it only
  suppressed the summary line.
- The summary line is now only printed when the warnings are errors, e.g.
  with `-Werror`, where it is what fails the build.

Warnings that only the symbol listing run produces, about library symbols
that end up not being included, are no longer shown when JS output is
generated.  They were only ever shown on builds that missed the symbol
list cache.

Fixes: emscripten-core#26577

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@juj
juj force-pushed the js_library_warning_once branch from daa55e5 to 6771603 Compare December 1, 2026 00:05
@sbc100

sbc100 commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

This seems like quite a big change for a small-ish benefit. Is the the mulitple-line issue something that is really a problem on your end?

@juj

juj commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator Author

Traditionally Unity has hidden Emscripten compiler warnings and errors from the end user.. (and translated some of those over to Unity build errors, muting all warnings) but since users create JS code as well, they have reported that as a bug that Emscripten messages go to void.

In the next Unity release, we created a map-through layer that converts compiler build warnings and errors to diagnostics in the Unity console: (some random screenshot from web of how the console looks like below)

image

So it would be nice to have those diagnostics be user friendly without redundancies.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using #warning in JS library files diagnoses three times.

2 participants