Issues with "production" flag and web export template build

Godot Version

4.4.1

Question

Hey, I am experimenting with minimizing the size of a (single-threaded, release) web export template, and noticed a problem that seems to be related to the scons “production” flag.

With production="yes" I get a couple warnings in the linking stage:

wasm-ld: warning: function signature mismatch: _ZNK19AudioStreamPlayback19get_sample_playbackEv
>>> defined as () -> void in servers\libservers.web.template_release.wasm32.nothreads.a(audio_stream.web.template_release.wasm32.nothreads.o)
>>> defined as (i32, i32) -> void in lto.tmp

wasm-ld: warning: function signature mismatch: _ZNK8Resource9duplicateEb
>>> defined as () -> void in core\libcore.web.template_release.wasm32.nothreads.a(resource.web.template_release.wasm32.nothreads.o)
>>> defined as (i32, i32, i32) -> void in lto.tmp

wasm-ld: warning: function signature mismatch: _ZNK11AudioStream15generate_sampleEv
>>> defined as () -> void in servers\libservers.web.template_release.wasm32.nothreads.a(audio_stream.web.template_release.wasm32.nothreads.o)
>>> defined as (i32, i32) -> void in lto.tmp
Creating 'bin\godot.web.template_release.wasm32.nothreads.wrapped.js'
Install file: "bin\godot.web.template_release.wasm32.nothreads.wasm" as "bin\.web_zip\godot.wasm"
Install file: "bin\godot.web.template_release.wasm32.nothreads.wrapped.js" as "bin\.web_zip\godot.js"

And when exporting a build with the resulting template, the engine fails to run in the browser with an “indirect call to null” message:

I can build without the “production” flag just fine, and the template is even smaller without it - so no problem there. Just would like to know if this known / expected / worth a bug report?

Thanks!

production=yes is an alias for use_static_cpp=yes debug_symbols=no lto=auto. Statically linking libstdc++ allows for better binary portability when compiling for Linux. This alias also enables link-time optimization when compiling for Linux, Web and Windows with MinGW, but keeps LTO disabled when compiling for macOS, iOS or Windows with MSVC. This is because LTO on those platforms is very slow to link or has issues with the generated code.

Godot github

I’d bet static cpp is causing your issues, which shouldn’t be applied to templates and especially web templates anyways. I’d bet production=yes is for building the editor, and specifically building the editor once for linux, for any distro.

@popcar2 wrote a lovely blog not long ago on minifying exports

1 Like

You may be right in that the production flag isn’t meant for templates… I figured the sentence “This alias also enables link-time optimization when compiling for Linux, Web and Windows[…]” was hinting at web export templates, but who knows.

That’s a really nice article, thanks for the link!

There is also a web editor! Though I don’t think it would benefit or work with static cpp either.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.