Closed
Description
Reproduction steps:
- Use any c program. Take for example the following main.c
int main(int argc, char** argv) { return 0; }
- Compile with
/home/ernesto/code/emsdk/upstream/emscripten/emcc -Oz -Wl,--stack-first main.c
- Compilation will fail with: "wasm-ld: error: --global-base cannot be less than stack size when --stack-first is used"
- Now compile with
/home/ernesto/code/emsdk/upstream/emscripten/emcc -Wl,--stack-first main.c
compilation succeeds.
Workarounds:
- Avoid "-Oz" when compiling with "--stack-first"
- Edit "settings.js" and set "var GLOBAL_BASE = 1024;" to the same value as "var STACK_SIZE = 64*1024;"
Potential resolutions:
- The "emcc.py" and "em++.py" programs can check if the "-Oz" flag is used together with "--stack-first". If so (Option 1) set the value of GLOBAL_BASE to the same value as STACK_SIZE. (Option 2) Exit with an error informing the user they are using an incompatible combination of flags.
Happy to issue a pull request with the fix above if any of those solutions would be satisfactory.
Metadata
Metadata
Assignees
Labels
No labels