How would I go about adding a compiler option to emscripten for building to html5?

I want to add the --bind option to the emcc call when building for html5, would I add this in html5toolchain.cs?
I’m just trying to use the embind, specifically the val functionality.

I think there is currently no machinery to allow adding in custom Emscripten linker flags. You can achieve it if you compile UE4 from sources at GitHub. If doing that, go and edit the file Engine/Source/Programs/UnrealBuildTool/HTML5/HTML5ToolChain.cs, and find the function GetLinkArguments(), and add in --bind flag there.

Another way, which might be simpler if you’re using a precompiled UE4 package, might be to go and hack the script in the bundled compiler. Find the file inside UE4 installation directory, and add e.g. on this line a directive

newargs = newargs + ['--bind']

or something like that, to force the --bind flag to be present in UE4 link. Then try doing a full rebuild. Not sure if this will work, but it’s probably so quick to test that it might be preferable if you don’t currently have the sources installed.

so I’m now running the unreal engine I got off github and have added --bind to the getlinkarguments function, but now when I build for html5 it gets stuck at:

UATHelper: Packaging (HTML5): UnrealBuildTool: #include “…” search starts here:
UATHelper: Packaging (HTML5): UnrealBuildTool: #include <…> search starts here:
A list of paths in the engine folders where include header files may exist
UATHelper: Packaging (HTML5): UnrealBuildTool: End of search list.

I can see in the output log right above this output that the --bind did something because now it has bind.cpp as the last thing when it tries to Link myproject.js.

I’m guessing one of the header files in bind.cpp can’t be found at the locations listed? I’ve also found some posts where the original unresolved symbol errors in emscripten I was seeing are actually just warnings? Can I disable show warnings as errors on my custom ue4?

Iirc those lines get always printed out. If there is no explicit errors, then I would not assume those are a source of a problem. The final link can take a long time when rebuilding from scratch (~10 minutes, depending on CPU speed). Try checking e.g. in a process monitor tool to check if there’s any real progress in the build, and where it’s getting stuck at.

you were right! Thanks for your help. Now if only the optimizer would stop crashing randomly on packaging…