Skip to content

Conversation

@sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Nov 3, 2025

This issue was introduces in #25522 when -sRELOCATABLE was removed from `get_base_cflags.

This is a somewhat tricky to reproduce / understand issue with transitive library building:

  1. User attempts to compile program using SDL2 + SDL2_GFX.

  2. emcc attempts to builds all needed libraries in reverse dependency order. And ends up with the follows sequence:

  3. libsdl2-pic

  4. libsdl2_gfx-pic

  5. emcc builds libsdl2-pic

  6. emcc builds libsdl2_gfx-pic. The command that it constructs when building each source file looks like emcc -fPIC gfx.c -sUSE_SDL=2. However because neither -sMAIN_MODULE nor -sRELOCATABLE were specified this emcc command will not try to build the non-PIC version of libsdl2. At this point the compiler will crash with:

    AssertionError: attempt to lock the cache while a parent process is holding the lock (sysroot/lib/wasm32-emscripten/libSDL2.a)

This issue is hard to reproduce because if libsdl2 is already built it will not trigger the issue.

@sbc100 sbc100 requested a review from kripken November 3, 2025 17:27
This issue was introduces in emscripten-core#25522 when `-sRELOCATABLE` was removed
from `get_base_cflags.

This is a somewhat tricky to reproduce / understand issue with
transitive library building:

1. User attempts to compile program using SDL2 + SDL2_GFX.
2. `emcc` attempts to builds all needed libraries in reverse dependency
   order.  And ends up with the follows sequence:
  1. libsdl2-pic
  2. libsdl2_gfx-pic
3. `emcc` builds libsdl2-pic
4. `emcc` builds libsdl2_gfx-pic. The command that it constructs when
   building each source file looks like `emcc -fPIC gfx.c -sUSE_SDL=2`.
   However because neither `-sMAIN_MODULE` nor `-sRELOCATABLE` were
   specified this `emcc` command will not try to build the non-PIC
   version of libsdl2.  At this point the compiler will crash with:

    `AssertionError: attempt to lock the cache while a parent process is holding the lock (sysroot/lib/wasm32-emscripten/libSDL2.a)`

This issue is hard to reproduce because if libsdl2 is already built it
will not trigger the issue.
@sbc100 sbc100 enabled auto-merge (squash) November 3, 2025 22:17
@sbc100 sbc100 merged commit f4734f7 into emscripten-core:main Nov 3, 2025
34 checks passed
@sbc100 sbc100 deleted the trasnitive_pic branch November 3, 2025 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants