goblint / cil

C Intermediate Language
https://goblint.github.io/cil/
Other
133 stars 20 forks source link

[Bug] -S flags don't get passed to Emscripten #137

Closed HakonHarnes closed 1 year ago

HakonHarnes commented 1 year ago

Description

Some flags are not passed to Emscripten when merging. I'm attempting to merge several files in a project that uses the SDL library, but I'm unable to properly link the library because the "-sUSE_SDL=2" flag is not being passed to emscripten.

Steps to reproduce

(https://github.com/robertaboukhalil/wasm-asteroids)

$ cilly --merge ../asteroids/*.c --gcc=emcc --out=merge.c -sUSE_SDL=2 

Warning: Unknown argument -sUSE_SDL=2
In file included from ../asteroids/main.c:5:
/usr/lib/emsdk/upstream/emscripten/cache/sysroot/include/fakesdl/SDL.h:1:2: error: "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSE_SDL=2"
 ^
1 error generated.
emcc: error: '/usr/lib/emsdk/upstream/bin/clang -target wasm32-unknown-emscripten -fignore-exceptions -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -DEMSCRIPTEN -Werror=implicit-function-declaration --sysroot=/usr/lib/emsdk/upstream/emscripten/cache/sysroot -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -D_GNUCC -E -DCIL=1 ../asteroids/main.c -o /tmp/cil-V2UzF6Fu.i' failed (returned 1)

Clearly (_#error "To use the emscripten port of SDL use -sUSE_SDL or -sUSESDL=2"), the -sUSE_SDL=2 flag is not being passed to emscripten. This is confirmed with verbose output:

$ cilly --merge ../asteroids/*.c --gcc=emcc --out=merge.c -sUSE_SDL=2 --verbose -v
...
Warning: Unknown argument -sUSE_SDL=2
... 
emcc -D_GNUCC -E -v -DCIL=1 ../asteroids/main.c -o /tmp/cil-dLmzC0mL.i

Expected result

The emcc command:

emcc -D_GNUCC -E -v -DCIL=1 ../asteroids/main.c -o /tmp/cil-dLmzC0mL.i

Should be:

emcc -D_GNUCC -E -v -DCIL=1 ../asteroids/main.c -o /tmp/cil-dLmzC0mL.i -sUSE_SDL=2
stilscher commented 1 year ago

See #138