Skip to content

Conversation

@sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Nov 16, 2024

Because some possible dependencies of these libraries have -mt variants (specifically png and harfbuzz) we also needs to declare -mt variant of these libraries.

The reason for this is a little complex: When we find the set of transitive dependencies of given library we select the correct variant of each library. This means that if we are building with -pthread then we select and include the -mt variants of all dependencies. However if libsdl2_image or libsdl2_ttf themselves then need to be built we end up building them without -pthread which means that emcc subprocesses will try to select and build the single threaded variants of the dependencies. This is mostly a serious problem because we don't allow for nested calls to emcc (we assume all dependencies have been already built before we try to build a given library and the we error out with EM_CACHE_IS_LOCKED if that is not the case).

Testing this fix requires the cache to be setup just right so I'm not sure its worth it.

Fixes: #22941, #20204

Because some possible dependencies of these libraries have `-mt`
variants (specifically png and harfbuzz) we also needs to declare `-mt`
variant of these libraries.

The reason for this is a little complex: When we find the set of
transitive dependencies of given library we select the correct variant
of each library.  This means that if we are building with `-pthread`
then we select and include the `-mt` variants of all dependencies.
However if libsdl2_image or libsdl2_ttf themselves then need to be built
we end up building them without `-pthread` which means that emcc
subprocesses will try to select and build the single threaded variants
of the dependencies.  This is mostly a serious problem because we don't
allow for nested calls to emcc (we assume all dependencies have been
already built before we try to build a given library and the we error
out with `EM_CACHE_IS_LOCKED` if that is not the case).

Testing this fix requires the cache to be setup just right so I'm not
sure its worth it.

Fixes: emscripten-core#22941, emscripten-core#20204
@sbc100 sbc100 requested a review from kripken November 18, 2024 18:41
@sbc100 sbc100 enabled auto-merge (squash) November 18, 2024 19:33
Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm % question

restore_and_set_up()
self.run_process([EMBUILDER, 'build', 'sdl2_image:formats=png,jpg', '--force'])
self.assertExists(os.path.join(config.CACHE, 'sysroot', 'lib', 'wasm32-emscripten', 'libSDL2_image_jpg-png.a'))
self.assertExists(os.path.join(config.CACHE, 'sysroot', 'lib', 'wasm32-emscripten', 'libSDL2_image-jpg-png.a'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the _ => - change needed, or for aesthetics? If it isn't needed then maybe it isn't worth it, as users might have hardcoded CI commands about it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tend to use - for all our variants (not _) so this is just for consistency.

The precise names of these variants should not be hardcoded anywhere.. if it were I think that would be a bug.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just worry about a user that has

cp libSDL2_image_jpg-png.a $OUT_DIR

in their CI workflow. This change would make them need to rename.

But if you are confident that is unlikely, and we haven't had issues with such changes in the past, sgtm as is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would be very unlikely yes. The consider those derived names (not the basename, but the extended name containing the variants) to be an internal detail that should not be relied on.

@sbc100 sbc100 merged commit 26b1978 into emscripten-core:main Nov 18, 2024
28 checks passed
@sbc100 sbc100 deleted the sdl2_image_fix branch November 18, 2024 22:00
sbc100 pushed a commit that referenced this pull request Jan 6, 2025
I added support for multi threading (-pthread) to the sdl2_mixer port. 
For me this was kind of new but I did try to follow the prinziples of
the sdl2_image adn sdl2_ttf
(#22946) changes.

I also changed the "_" to "-" for consistency.
@caiiiycuk caiiiycuk mentioned this pull request Jan 18, 2025
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.

File "C:\emsdk-main\upstream\emscripten\tools\cache.py", line 68, in lock acquire_cache_lock(reason)

2 participants