Skip to content
This repository has been archived by the owner on Jan 4, 2024. It is now read-only.

wasm-ld: error: unable to find library -lSDL2_mixer #2

Open
ryanpcmcquen opened this issue Oct 17, 2020 · 16 comments
Open

wasm-ld: error: unable to find library -lSDL2_mixer #2

ryanpcmcquen opened this issue Oct 17, 2020 · 16 comments

Comments

@ryanpcmcquen
Copy link

I'm trying to port my game engine using Emscripten:
https://github.com/ryanpcmcquen/basque

The command I am using is:

emcc -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s USE_SDL_MIXER=2 -s USE_SDL_TTF=2 -Wall -Wextra -std=c99 source/basque.c '-Wl,-rpath,$ORIGIN' $(/usr/local/Cellar/emscripten/2.0.7/libexec/system/bin/sdl-config --cflags --libs) -l SDL2_image -l SDL2_mixer -l SDL2_ttf -o basque

And I get this:

emscripten sdl-config called with /usr/local/Cellar/emscripten/2.0.7/libexec/system/bin/sdl-config --cflags --libs
system_libs:INFO: retrieving port: ogg from https://github.com/emscripten-ports/ogg/archive/version_1.zip
system_libs:INFO: unpacking port: ogg
cache:INFO: generating system library: libogg.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libogg.a" for subsequent builds)
root:INFO: building port: ogg
cache:INFO:  - ok
system_libs:INFO: retrieving port: vorbis from https://github.com/emscripten-ports/vorbis/archive/version_1.zip
system_libs:INFO: unpacking port: vorbis
cache:INFO: generating system library: libvorbis.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libvorbis.a" for subsequent builds)
root:INFO: building port: vorbis
cache:INFO:  - ok
system_libs:INFO: retrieving port: sdl2_mixer from https://github.com/emscripten-ports/SDL2_mixer/archive/release-2.0.2.zip
system_libs:INFO: unpacking port: sdl2_mixer
cache:INFO: generating port: libSDL2_mixer_ogg.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2_mixer_ogg.a" for subsequent builds)
root:INFO: building port: sdl2_mixer
cache:INFO:  - ok
system_libs:INFO: retrieving port: freetype from https://github.com/emscripten-ports/FreeType/archive/version_1.zip
system_libs:INFO: unpacking port: freetype
cache:INFO: generating port: libfreetype.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libfreetype.a" for subsequent builds)
cache:INFO:  - ok
system_libs:INFO: retrieving port: sdl2_ttf from https://github.com/emscripten-ports/SDL2_ttf/archive/version_1.zip
system_libs:INFO: unpacking port: sdl2_ttf
cache:INFO: generating port: libSDL2_ttf.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2_ttf.a" for subsequent builds)
cache:INFO:  - ok
system_libs:INFO: retrieving port: sdl2_image from https://github.com/emscripten-ports/SDL2_image/archive/version_4.zip
system_libs:INFO: unpacking port: sdl2_image
cache:INFO: generating port: libSDL2_image.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2_image.a" for subsequent builds)
cache:INFO:  - ok
emcc: warning: ignoring unsupported linker flag: `-rpath` [-Wlinkflags]
cache:INFO: generating system library: libgl.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libgl.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libc.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libc.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libcompiler_rt.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libcompiler_rt.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libc++-noexcept.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libc++-noexcept.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libc++abi-noexcept.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libc++abi-noexcept.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libdlmalloc.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libdlmalloc.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libpthread_stub.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libpthread_stub.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libc_rt_wasm.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libc_rt_wasm.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libsockets.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libsockets.a" for subsequent builds)
cache:INFO:  - ok
wasm-ld: error: unable to find library -lSDL2_mixer
emcc: error: '/usr/local/opt/emscripten/libexec/llvm/bin/wasm-ld -o /var/folders/mh/r7jf7pqj7fbc3267y21r4vsck30y5r/T/emscripten_temp_pzhahgpp/basque.wasm /var/folders/mh/r7jf7pqj7fbc3267y21r4vsck30y5r/T/emscripten_temp_pzhahgpp/basque_0.o /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2_image.a -L/usr/local/Cellar/emscripten/2.0.7/libexec/system/local/lib -lSDL2_mixer /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2_ttf.a -L/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2_image.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2_ttf.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libfreetype.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2_mixer_ogg.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libvorbis.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libogg.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libgl.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libc.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libcompiler_rt.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libc++-noexcept.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libc++abi-noexcept.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libdlmalloc.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libpthread_stub.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libc_rt_wasm.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libsockets.a -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --allow-undefined --import-memory --strip-debug --export-table --export main --export stackSave --export stackRestore --export stackAlloc --export __data_end --export __wasm_call_ctors --export fflush --export __errno_location --export malloc --export free --export memset --export memcpy --export fileno --export setThrew --export realloc --export testSetjmp --export saveSetjmp --export emscripten_GetProcAddress --export strstr -z stack-size=5242880 --initial-memory=16777216 --no-entry --max-memory=16777216 --global-base=1024' failed (1)
@kripken
Copy link
Member

kripken commented Oct 17, 2020

Does removing -l SDL2_mixer fix it? The existing -s USE_SDL_MIXER=2 should be enough to get it linked in (but I'm not sure offhand why that would be an error to include it - sounds like a bug).

@ryanpcmcquen
Copy link
Author

@kripken, weird error when I remove -l SDL2_mixer:

λ emcc -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s USE_SDL_MIXER=2 -s USE_SDL_TTF=2 -Wall -Wextra -std=c99 source/basque.c '-Wl,-rpath,$ORIGIN' $(/usr/local/Cellar/emscripten/2.0.7/libexec/system/bin/sdl-config --cflags --libs) -l SDL2_image -l SDL2_ttf -o basque
emscripten sdl-config called with /usr/local/Cellar/emscripten/2.0.7/libexec/system/bin/sdl-config --cflags --libs
emcc: warning: ignoring unsupported linker flag: `-rpath` [-Wlinkflags]
wasm-ld: error: duplicate symbol: load_music
>>> defined in /var/folders/mh/r7jf7pqj7fbc3267y21r4vsck30y5r/T/emscripten_temp_ra5tnit4/basque_0.o
>>> defined in /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2_mixer_ogg.a(music.c.o)
emcc: error: '/usr/local/opt/emscripten/libexec/llvm/bin/wasm-ld -o /var/folders/mh/r7jf7pqj7fbc3267y21r4vsck30y5r/T/emscripten_temp_ra5tnit4/basque.wasm /var/folders/mh/r7jf7pqj7fbc3267y21r4vsck30y5r/T/emscripten_temp_ra5tnit4/basque_0.o /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2_image.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2_ttf.a -L/usr/local/Cellar/emscripten/2.0.7/libexec/system/lib -L/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2_mixer_ogg.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libvorbis.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2_image.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libogg.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2_ttf.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libfreetype.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libgl.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libc.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libcompiler_rt.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libc++-noexcept.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libc++abi-noexcept.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libdlmalloc.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libpthread_stub.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libc_rt_wasm.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libsockets.a -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --allow-undefined --import-memory --strip-debug --export-table --export main --export stackSave --export stackRestore --export stackAlloc --export __data_end --export __wasm_call_ctors --export fflush --export __errno_location --export malloc --export free --export memset --export memcpy --export fileno --export setThrew --export realloc --export testSetjmp --export saveSetjmp --export emscripten_GetProcAddress --export strstr -z stack-size=5242880 --initial-memory=16777216 --no-entry --max-memory=16777216 --global-base=1024' failed (1)

@ryanpcmcquen
Copy link
Author

That symbol isn't duplicated in the project at least:

Screen Shot 2020-10-19 at 9 55 26 AM

@kripken
Copy link
Member

kripken commented Oct 19, 2020

@ryanpcmcquen from the error, looks like it exists in the library as well as the project. perhaps one of them should be static?

@sbc100 I see we ignore -lSDL2 in emcc, but not -lSDL2_mixer (./emcc tests/hello_world.c -lSDL2 works, but with _mixer it errors unable to find library). Do you know what logic is responsible for that?

@ryanpcmcquen
Copy link
Author

@kripken, thanks I renamed it. Here are the new errors:

λ emcc -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s USE_SDL_MIXER=2 -s USE_SDL_TTF=2 -Wall -Wextra -std=c99 source/basque.c '-Wl,-rpath,$ORIGIN' $(/usr/local/Cellar/emscripten/2.0.7/libexec/system/bin/sdl-config --cflags --libs) -l SDL2_image -l SDL2_ttf -o basque
emscripten sdl-config called with /usr/local/Cellar/emscripten/2.0.7/libexec/system/bin/sdl-config --cflags --libs
emcc: warning: ignoring unsupported linker flag: `-rpath` [-Wlinkflags]
cache:INFO: generating system asset: generated_struct_info.json... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/generated_struct_info.json" for subsequent builds)
cache:INFO:  - ok
error: undefined symbol: __invoke_i32_$struct_FT_CMap_ClassRec_*_i8*_$struct_FT_CharMapRec_*_$struct_FT_CMapRec_** (referenced by top-level compiled C/C++ code)
warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
warning: ___invoke_i32_$struct_FT_CMap_ClassRec_*_i8*_$struct_FT_CharMapRec_*_$struct_FT_CMapRec_** may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: __invoke_i32_$struct_FT_Outline_*_$struct_FT_Outline_Funcs_*_i8* (referenced by top-level compiled C/C++ code)
warning: ___invoke_i32_$struct_FT_Outline_*_$struct_FT_Outline_Funcs_*_i8* may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: __invoke_i32_i8*_$struct_FT_ValidatorRec_* (referenced by top-level compiled C/C++ code)
warning: ___invoke_i32_i8*_$struct_FT_ValidatorRec_* may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: __invoke_void_$struct_FT_ValidatorRec_*_i8*_i8*_i32 (referenced by top-level compiled C/C++ code)
warning: ___invoke_void_$struct_FT_ValidatorRec_*_i8*_i8*_i32 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: __invoke_void_$struct_gray_TWorker_* (referenced by top-level compiled C/C++ code)
warning: ___invoke_void_$struct_gray_TWorker_* may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: emscripten_longjmp_jmpbuf (referenced by top-level compiled C/C++ code)
warning: _emscripten_longjmp_jmpbuf may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
Error: Aborting compilation due to previous errors
emcc: error: '/usr/local/opt/node@12/bin/node /usr/local/Cellar/emscripten/2.0.7/libexec/src/compiler.js /var/folders/mh/r7jf7pqj7fbc3267y21r4vsck30y5r/T/tmpc3o9n55z.txt' failed (1)

λ emcc -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s USE_SDL_MIXER=2 -s USE_SDL_TTF=2 -Wall -Wextra -std=c99 source/basque.c '-Wl,-rpath,$ORIGIN' $(/usr/local/Cellar/emscripten/2.0.7/libexec/system/bin/sdl-config --cflags --libs) -l SDL2_image -l SDL2_mixer -l SDL2_ttf -o basque
emscripten sdl-config called with /usr/local/Cellar/emscripten/2.0.7/libexec/system/bin/sdl-config --cflags --libs
emcc: warning: ignoring unsupported linker flag: `-rpath` [-Wlinkflags]
wasm-ld: error: unable to find library -lSDL2_mixer
emcc: error: '/usr/local/opt/emscripten/libexec/llvm/bin/wasm-ld -o /var/folders/mh/r7jf7pqj7fbc3267y21r4vsck30y5r/T/emscripten_temp_js243kin/basque.wasm /var/folders/mh/r7jf7pqj7fbc3267y21r4vsck30y5r/T/emscripten_temp_js243kin/basque_0.o /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2_image.a -L/usr/local/Cellar/emscripten/2.0.7/libexec/system/local/lib -lSDL2_mixer /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2_ttf.a -L/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2_mixer_ogg.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libvorbis.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libogg.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2_ttf.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libfreetype.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2_image.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libgl.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libc.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libcompiler_rt.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libc++-noexcept.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libc++abi-noexcept.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libdlmalloc.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libpthread_stub.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libc_rt_wasm.a /usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libsockets.a -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --allow-undefined --import-memory --strip-debug --export-table --export main --export stackSave --export stackRestore --export stackAlloc --export __data_end --export __wasm_call_ctors --export fflush --export __errno_location --export malloc --export free --export memset --export memcpy --export fileno --export setThrew --export realloc --export testSetjmp --export saveSetjmp --export emscripten_GetProcAddress --export strstr -z stack-size=5242880 --initial-memory=16777216 --no-entry --max-memory=16777216 --global-base=1024' failed (1)

ryanpcmcquen referenced this issue in ryanpcmcquen/basque Oct 19, 2020
@sbc100
Copy link

sbc100 commented Oct 19, 2020

@ryanpcmcquen from the error, looks like it exists in the library as well as the project. perhaps one of them should be static?

@sbc100 I see we ignore -lSDL2 in emcc, but not -lSDL2_mixer (./emcc tests/hello_world.c -lSDL2 works, but with _mixer it errors unable to find library). Do you know what logic is responsible for that?

Its not so much that -lSDL2 is ignored its more that it is found and used. For -lSDL_mixer the problem is that the internal name that USE_SDL_MIXER builds is libSDL2_mixer_ogg.a.. so to find that library with -l flag you would want to use -lSDL2_mixer_ogg.

@sbc100
Copy link

sbc100 commented Oct 19, 2020

We can probably make this work by add more magic around the -l flag handling.. but in the mean time you could also fix this by only passing -s USE_SDL_MIXER=2 and not -lSDL2_mixer (this might involve hacking the sdl2_mixer_config file).

@ryanpcmcquen
Copy link
Author

@sbc100, I get the following when removing -l SDL2_mixer:

λ emcc -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s USE_SDL_MIXER=2 -s USE_SDL_TTF=2 -Wall -Wextra -std=c99 source/basque.c '-Wl,-rpath,$ORIGIN' $(/usr/local/Cellar/emscripten/2.0.7/libexec/system/bin/sdl-config --cflags --libs) -l SDL2_image -l SDL2_ttf -o basque
emscripten sdl-config called with /usr/local/Cellar/emscripten/2.0.7/libexec/system/bin/sdl-config --cflags --libs
emcc: warning: ignoring unsupported linker flag: `-rpath` [-Wlinkflags]
error: undefined symbol: __invoke_i32_$struct_FT_CMap_ClassRec_*_i8*_$struct_FT_CharMapRec_*_$struct_FT_CMapRec_** (referenced by top-level compiled C/C++ code)
warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
warning: ___invoke_i32_$struct_FT_CMap_ClassRec_*_i8*_$struct_FT_CharMapRec_*_$struct_FT_CMapRec_** may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: __invoke_i32_$struct_FT_Outline_*_$struct_FT_Outline_Funcs_*_i8* (referenced by top-level compiled C/C++ code)
warning: ___invoke_i32_$struct_FT_Outline_*_$struct_FT_Outline_Funcs_*_i8* may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: __invoke_i32_i8*_$struct_FT_ValidatorRec_* (referenced by top-level compiled C/C++ code)
warning: ___invoke_i32_i8*_$struct_FT_ValidatorRec_* may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: __invoke_void_$struct_FT_ValidatorRec_*_i8*_i8*_i32 (referenced by top-level compiled C/C++ code)
warning: ___invoke_void_$struct_FT_ValidatorRec_*_i8*_i8*_i32 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: __invoke_void_$struct_gray_TWorker_* (referenced by top-level compiled C/C++ code)
warning: ___invoke_void_$struct_gray_TWorker_* may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: emscripten_longjmp_jmpbuf (referenced by top-level compiled C/C++ code)
warning: _emscripten_longjmp_jmpbuf may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
Error: Aborting compilation due to previous errors
emcc: error: '/usr/local/opt/node@12/bin/node /usr/local/Cellar/emscripten/2.0.7/libexec/src/compiler.js /var/folders/mh/r7jf7pqj7fbc3267y21r4vsck30y5r/T/tmpl39d5vhf.txt' failed (1)

@sbc100
Copy link

sbc100 commented Oct 19, 2020

Those error are due the fact that one of more of the input libraries has not been rebuilt with the new version of llvm. A completely clean build should take care of those.

@ryanpcmcquen
Copy link
Author

@sbc100, sorry for the noob question ... but how do I clean the build here? I'm not seeing anything in /var I can clear out.

@sbc100
Copy link

sbc100 commented Oct 20, 2020

You need to delete all your object files and libraries... you might also want to clear all the cached emscripten libraries (although you shouldn't need to do this) with emcc --clear-cache.

If that doesn't work the issue could be related to the homebrew package having a version of binaryen and llvm that are not in sync with each other. you might want to see if switching the using emsdk rather than the homebrew package fixes the issue. (If that does fix the issue you might want to file a bug with the homebrew package).

@ryanpcmcquen
Copy link
Author

OK, I deleted all the *.a and *.o files in the emscripten/2.0.7 directory and did emcc --clear-cache, but it is still broken, going to try the emsdk next:

λ emcc -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s USE_SDL_MIXER=2 -s USE_SDL_TTF=2 -Wall -Wextra -std=c99 source/basque.c '-Wl,-rpath,$ORIGIN' $(/usr/local/Cellar/emscripten/2.0.emscripten sdl-config called with /usr/local/Cellar/emscripten/2.0.7/libexec/system/bin/sdl-config --cflags --libs
cache:INFO: generating port: libSDL2.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating port: libSDL2_image.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2_image.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating port: libfreetype.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libfreetype.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating port: libSDL2_ttf.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2_ttf.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libogg.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libogg.a" for subsequent builds)
root:INFO: building port: ogg
cache:INFO:  - ok
cache:INFO: generating system library: libvorbis.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libvorbis.a" for subsequent builds)
root:INFO: building port: vorbis
cache:INFO:  - ok
cache:INFO: generating port: libSDL2_mixer_ogg.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libSDL2_mixer_ogg.a" for subsequent builds)
root:INFO: building port: sdl2_mixer
cache:INFO:  - ok
emcc: warning: ignoring unsupported linker flag: `-rpath` [-Wlinkflags]
cache:INFO: generating system library: libgl.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libgl.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libc.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libc.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libcompiler_rt.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libcompiler_rt.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libc++-noexcept.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libc++-noexcept.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libc++abi-noexcept.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libc++abi-noexcept.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libdlmalloc.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libdlmalloc.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libpthread_stub.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libpthread_stub.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libc_rt_wasm.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libc_rt_wasm.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: libsockets.a... (this will be cached in "/usr/local/Cellar/emscripten/2.0.7/libexec/cache/wasm/libsockets.a" for subsequent builds)
cache:INFO:  - ok
error: undefined symbol: __invoke_i32_$struct_FT_CMap_ClassRec_*_i8*_$struct_FT_CharMapRec_*_$struct_FT_CMapRec_** (referenced by top-level compiled C/C++ code)
warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
warning: ___invoke_i32_$struct_FT_CMap_ClassRec_*_i8*_$struct_FT_CharMapRec_*_$struct_FT_CMapRec_** may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: __invoke_i32_$struct_FT_Outline_*_$struct_FT_Outline_Funcs_*_i8* (referenced by top-level compiled C/C++ code)
warning: ___invoke_i32_$struct_FT_Outline_*_$struct_FT_Outline_Funcs_*_i8* may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: __invoke_i32_i8*_$struct_FT_ValidatorRec_* (referenced by top-level compiled C/C++ code)
warning: ___invoke_i32_i8*_$struct_FT_ValidatorRec_* may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: __invoke_void_$struct_FT_ValidatorRec_*_i8*_i8*_i32 (referenced by top-level compiled C/C++ code)
warning: ___invoke_void_$struct_FT_ValidatorRec_*_i8*_i8*_i32 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: __invoke_void_$struct_gray_TWorker_* (referenced by top-level compiled C/C++ code)
warning: ___invoke_void_$struct_gray_TWorker_* may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: emscripten_longjmp_jmpbuf (referenced by top-level compiled C/C++ code)
warning: _emscripten_longjmp_jmpbuf may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
Error: Aborting compilation due to previous errors
emcc: error: '/usr/local/opt/node@12/bin/node /usr/local/Cellar/emscripten/2.0.7/libexec/src/compiler.js /var/folders/mh/r7jf7pqj7fbc3267y21r4vsck30y5r/T/tmp0mx2lggd.txt' failed (1)

@ryanpcmcquen
Copy link
Author

Success!

λ ~/code/emsdk/upstream/emscripten/emcc -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s USE_SDL_MIXER=2 -s USE_SDL_TTF=2 -Wall -Wextra -std=c99 source/basque.c '-Wl,-rpath,$ORIGIN' $(sdl2-config --cflags --libs) -l SDL2_image -l SDL2_ttf -o basque
shared:INFO: (Emscripten: Running sanity checks)
system_libs:INFO: retrieving port: sdl2 from https://github.com/emscripten-ports/SDL2/archive/version_22.zip
system_libs:INFO: unpacking port: sdl2
cache:INFO: generating port: libSDL2.a... (this will be cached in "/Users/rmcquen/code/emsdk/upstream/emscripten/cache/wasm/libSDL2.a" for subsequent builds)
cache:INFO:  - ok
system_libs:INFO: retrieving port: freetype from https://github.com/emscripten-ports/FreeType/archive/version_1.zip
system_libs:INFO: unpacking port: freetype
cache:INFO: generating port: libfreetype.a... (this will be cached in "/Users/rmcquen/code/emsdk/upstream/emscripten/cache/wasm/libfreetype.a" for subsequent builds)
cache:INFO:  - ok
system_libs:INFO: retrieving port: sdl2_image from https://github.com/emscripten-ports/SDL2_image/archive/version_4.zip
system_libs:INFO: unpacking port: sdl2_image
cache:INFO: generating port: libSDL2_image.a... (this will be cached in "/Users/rmcquen/code/emsdk/upstream/emscripten/cache/wasm/libSDL2_image.a" for subsequent builds)
cache:INFO:  - ok
system_libs:INFO: retrieving port: sdl2_ttf from https://github.com/emscripten-ports/SDL2_ttf/archive/version_1.zip
system_libs:INFO: unpacking port: sdl2_ttf
cache:INFO: generating port: libSDL2_ttf.a... (this will be cached in "/Users/rmcquen/code/emsdk/upstream/emscripten/cache/wasm/libSDL2_ttf.a" for subsequent builds)
cache:INFO:  - ok
system_libs:INFO: retrieving port: ogg from https://github.com/emscripten-ports/ogg/archive/version_1.zip
system_libs:INFO: unpacking port: ogg
cache:INFO: generating system library: libogg.a... (this will be cached in "/Users/rmcquen/code/emsdk/upstream/emscripten/cache/wasm/libogg.a" for subsequent builds)
root:INFO: building port: ogg
cache:INFO:  - ok
system_libs:INFO: retrieving port: vorbis from https://github.com/emscripten-ports/vorbis/archive/version_1.zip
system_libs:INFO: unpacking port: vorbis
cache:INFO: generating system library: libvorbis.a... (this will be cached in "/Users/rmcquen/code/emsdk/upstream/emscripten/cache/wasm/libvorbis.a" for subsequent builds)
root:INFO: building port: vorbis
cache:INFO:  - ok
system_libs:INFO: retrieving port: sdl2_mixer from https://github.com/emscripten-ports/SDL2_mixer/archive/release-2.0.2.zip
system_libs:INFO: unpacking port: sdl2_mixer
cache:INFO: generating port: libSDL2_mixer_ogg.a... (this will be cached in "/Users/rmcquen/code/emsdk/upstream/emscripten/cache/wasm/libSDL2_mixer_ogg.a" for subsequent builds)
root:INFO: building port: sdl2_mixer
cache:INFO:  - ok
emcc: warning: ignoring unsupported linker flag: `-rpath` [-Wlinkflags]

@sbc100 and @kripken thank you so much!

@ryanpcmcquen
Copy link
Author

ryanpcmcquen commented Oct 20, 2020

I think this is safe to close unless we want to handle some parsing for the mixer linking that doesn't include the encoding suffix.

@sbc100
Copy link

sbc100 commented Oct 20, 2020

Also, it does look like there is currently issue with homebrew package with respect the binaryen and llvm versions not quite matching. Perhaps @chenrui333 can help?

@ryanpcmcquen
Copy link
Author

I saw this:
Homebrew/homebrew-core#47869
But I didn't see any open ones so I made a new one.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants