libretro / libretro/RetroArch

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

Open
#13,437 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
14.1k
Forks
2.2k
Avg merge
7h 35m
Merged PRs (30d)
51

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with dist-cores.sh and Makefile.emscripten, then trace where the final Emscripten link command is assembled. Review the reported linker warnings and verify how EXPORT_ES6 and MODULARIZE reach the final WASM/JS output. Done means the generated JavaScript exports as an ES6 module and the warnings no longer occur during linking.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, shell, wasm
Domain
build-system, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.