libretro / RetroArch

Cross-platform, sophisticated frontend for the libretro API. Licensed GPLv3.
http://www.libretro.com
GNU General Public License v3.0
10.28k stars 1.83k forks source link

Cores not exporting as ES6 Module when compiled with Emscripten to WebAssembly #13437

Open Zentendo opened 2 years ago

Zentendo commented 2 years ago

Where do you define options for Emscripten such as -s EXPORT_ES6=1 and -s MODULARIZE=1 for the final WASM/JS output of dist-cores.sh? I've defined them here: https://github.com/libretro/RetroArch/blob/master/Makefile.emscripten#L9

But the final output JS still does not export ES6 modules, causing you to use very legacy style 1990's style script tags instead of module loading, not properly supporting async, and I get these compiler warnings during linking:

CC gfx/video_filters/phosphor2x.c
emcc: warning: linker setting ignored during compilation: 'EXPORTED_FUNCTIONS' [-Wunused-command-line-argument]
emcc: warning: linker setting ignored during compilation: 'ALLOW_MEMORY_GROWTH' [-Wunused-command-line-argument]
emcc: warning: linker setting ignored during compilation: 'EXPORTED_RUNTIME_METHODS' [-Wunused-command-line-argument]     
emcc: warning: linker setting ignored during compilation: 'EXPORT_ES6' [-Wunused-command-line-argument]
emcc: warning: linker setting ignored during compilation: 'MODULARIZE' [-Wunused-command-line-argument]

Flag here: https://github.com/emscripten-core/emscripten/blob/main/src/settings.js#L1176

JoeOsborn commented 1 year ago

I think they’d need to be defined as LDFLAGS. I’d actually like to do this so we can have multiple emulators running on one webpage, and I hope to file a patch tomorrow changing the makefile and JavaScript loader to use modularized retroarch.