Optimisation and assertions

9 views
Skip to first unread message

John Dallman

unread,
Nov 26, 2025, 9:37:47 AM (7 days ago) Nov 26
to emscripte...@googlegroups.com
I'm linking with -sASSERTIONS=2 -O0, but not getting any assertions going off.  


Optimization levels above -O1 or -Og increasingly degrade LLVM debug information (as with other architectures), and optimization flags at link time also disable Emscripten’s runtime ASSERTIONS checks.

Does -O0 disable ASSERTIONS checks? 

I get this warning when linking with, or without -O0:

em++: warning: running limited binaryen optimizations because DWARF info requested (or indirectly required) [-Wlimited-postlink-optimizations]

Which makes me wonder why binaryen optimisations are being done? 

Thanks very much,

John Dallman

Alon Zakai

unread,
Nov 26, 2025, 1:52:38 PM (7 days ago) Nov 26
to emscripte...@googlegroups.com
On Wed, Nov 26, 2025 at 6:37 AM John Dallman <jgdats...@gmail.com> wrote:
I'm linking with -sASSERTIONS=2 -O0, but not getting any assertions going off.  


Optimization levels above -O1 or -Og increasingly degrade LLVM debug information (as with other architectures), and optimization flags at link time also disable Emscripten’s runtime ASSERTIONS checks.

Does -O0 disable ASSERTIONS checks? 


No, it doesn't.

You can look at the JS output file to see the extra assertions are emitted for -sASSERTIONS=2. Perhaps diff against a build without that flag. You will see the flag adds stack checks and other things.
 
I get this warning when linking with, or without -O0:

em++: warning: running limited binaryen optimizations because DWARF info requested (or indirectly required) [-Wlimited-postlink-optimizations]

Which makes me wonder why binaryen optimisations are being done? 


Check your full link command - you likely have an -O1 or -O2 or such, in addition to the -O0. If that's not it, what is your full link command?
 
Thanks very much,

John Dallman

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/emscripten-discuss/CAH1xqgke4V%3DvuAOACzm2uf8WgKxQhnS9x4fC3-fLV_mKonZcHQ%40mail.gmail.com.

John Dallman

unread,
Nov 27, 2025, 9:04:23 AM (6 days ago) Nov 27
to emscripte...@googlegroups.com
> You can look at the JS output file to see the extra assertions are emitted for 
> -sASSERTIONS=2. Perhaps diff against a build without that flag. You will see 
> the flag adds stack checks and other things.

I will need guidance as to what to look for. My knowledge of JavaScript is minimal: I'm a C programmer who finds JS quite confusing. 

> Check your full link command - you likely have an -O1 or -O2 or such, in addition to the -O0. 

Nope.

> If that's not it, what is your full link command?

em++ --pre-js /Path/to/kid_node_prerun.js -sMAXIMUM_MEMORY=4000MB -sEXPORTED_FUNCTIONS=ENV,_main \
-sALLOW_MEMORY_GROWTH -sSTACK_SIZE=4096KB -sNODERAWFS -g --emit-symbol-map -sASSERTIONS=2 \
-sSAFE_HEAP=1 /Path/to/lsp/kernel.o clu/object_plus.o lsp/lisp.o /Path/to/lib/webasm/aga_fix.o /Path/to/system/release/kid_support.a /Path/to/system/release/pskernel_archive.a -o /u/jgd/regimes/webasm/kid.js

I get these warnings: 
em++: warning: running limited binaryen optimizations because DWARF info requested (or indirectly required) [-Wlimited-postlink-optimizations]
warning: no output file specified, not emitting output 

Thanks,

John 

Sam Clegg

unread,
Nov 29, 2025, 2:59:05 PM (4 days ago) Nov 29
to emscripte...@googlegroups.com
I think the warning you are seeing might be a little misleading in this case.

The reason for the warning is the `-sSAFE_HEAP=1` flag.  This flag requires us to run a binaryen pass over the final output, and currently whenever we run any binaryen passes, and we also have `-g`, then we issue this warning.

Perhaps the warning should be rephrased or downgraded in the case when optimization is not actually requested.    Alon would probably know which is the best option here.

Cheers,
sam

John Dallman

unread,
Dec 1, 2025, 9:41:09 AM (2 days ago) Dec 1
to emscripte...@googlegroups.com
On Sat, Nov 29, 2025 at 7:59 PM 'Sam Clegg' via emscripten-discuss <emscripte...@googlegroups.com> wrote:

> The reason for the warning is the `-sSAFE_HEAP=1` flag.  This flag requires us to 
> run a binaryen pass over the final output, and currently whenever we run any binaryen 
> passes, and we also have `-g`, then we issue this warning.

> Perhaps the warning should be rephrased or downgraded in the case when optimization 
> is not actually requested. Alon would probably know which is the best option here.

That would be welcome. What does the "warning: no output file specified, not emitting output" message that comes just after it signify? 

Thanks,

John



Alon Zakai

unread,
Dec 1, 2025, 11:59:10 AM (2 days ago) Dec 1
to emscripte...@googlegroups.com

Alon Zakai

unread,
Dec 1, 2025, 12:02:05 PM (2 days ago) Dec 1
to emscripte...@googlegroups.com
"no output file specified" can be ignored, but I am confused why it appears... I can't reproduce it with a similar link command locally.

Reply all
Reply to author
Forward
0 new messages