emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.61k stars 3.28k forks source link

Some ports pkgconfig files missing #17903

Open vcaputo opened 1 year ago

vcaputo commented 1 year ago

Version of emscripten/emsdk: emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.6 () Debian clang version 14.0.6-2 Target: wasm32-unknown-emscripten Thread model: posix InstalledDir: /usr/bin

Failing command line in full: autotools based configure of a small SDL2+SDL2_mixer+GL using game (https://git.pengaru.com/cgit/sars/.git/tree/configure.ac):

EM_CACHE=/home/vc/sars/build-emscripten/emscripten-cache EM_FROZEN_CACHE=  CFLAGS='-sUSE_SDL=2 -sUSE_SDL_MIXER=2 -sLLD_REPORT_UNDEFINED=0 -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 -sFULL_ES2 -sALLOW_MEMORY_GROWTH=1' emconfigure ../src/configure --host=asmjs-unknown-emscripten

This fails to locate any of SDL2, SDL2_mixer, or gl via pkgconfig. The configure.ac is using the common PKG_CHECK_MODULES() macro in the obvious manner:

PKG_CHECK_MODULES(SDL2, sdl2) ... PKG_CHECK_MODULES(SDL2_MIXER, SDL2_mixer) ... PKG_CHECK_MODULES(GL, gl)

I was able to work around this by adding minimal .pc stub files at /home/vc/sars/build-emscripten/emscripten-cache/sysroot/lib/pkgconfig/{sdl2.pc,SDL2_mixer.pc,gl.c}, as I'm somewhat familiar with how pkgconfig works and it doesn't look like emscripten actually needs anything substantial in those files. It's basically just a "satisfy configure's pkg-config invocations" step.

But for someone just following instructions this would probably be very frustrating. There's a lot of magic going on here with -sUSE_SDL=2 -sUSE_SDL_MIXER=2 and it seems like a bug for those to not produce the pkgconfig stubs. There was an sdl.pc stub produced, but not the others.

If this is already fixed feel free to close and sorry for the noise. I'm using the emscripten version installed by Debian Testing, which may be old knowing Debian.

I just wanted to get this written down before I forget, in case it's a pending problem waiting for someone else to lose hair over.

sbc100 commented 1 year ago

Yes, I agree that the -sUSE_SDL=2 and -sUSE_SDL_MIXER=2 flags are kind of magical. It would probably make sense if they would also install/produce corresponding .pc files in the correct place. Patches would be most welcome to make that happen.

robtaylor commented 1 year ago

HI, I'm hitting this also. using embuilder for libz, i see i get a libz in sysroot/lib/wasm32-emscripten, but i get no corresponding pkgconfig file in sysroot/lib/pkgconfig.

Happy to help fix this if someone can point me in the direction of the magic thats building libz!

robtaylor commented 1 year ago

ok, i think i can explain what needs to be done. in ports/zlib.py in build, the equivalent functionality to: https://github.com/madler/zlib/blob/04f42ceca40f73e2978b50e93806c2a18c1281fc/configure#L897 needs to be added, and the generated file installed into sysroot/lib/pkgconfig

sbc100 commented 1 year ago

I think the simplest solution (for now) would be to add zlib.pc under system/lib/pkgconfig.

robtaylor commented 1 year ago

Updated my PR now