Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL_TTF and freetype not building with PTHREADS #13402

Open
cm226 opened this issue Feb 2, 2021 · 2 comments
Open

SDL_TTF and freetype not building with PTHREADS #13402

cm226 opened this issue Feb 2, 2021 · 2 comments

Comments

@cm226
Copy link

cm226 commented Feb 2, 2021

If using SDL2 with threads then sdl2_ttf.py and freetype.py don't compile a -mt version of the library automatically like sdl2.py does.

We found that the linker dosnt seem to complain about linking the non-mt versionf of these librarys, but when using TTF_OpenFont you get heap corruption at runtime.

I changed sdl2.ttf.py and freetype to compile with USE_PTHREADS, linked with those library's and it fixed the heap corruption.

@cm226 cm226 changed the title SDL_TFF and freetype not building with PTHREADS SDL_TTF and freetype not building with PTHREADS Feb 3, 2021
@debevv
Copy link

debevv commented Apr 2, 2022

I can confirm the issue, too
Building with the following flags:

-O3 -pthread -s USE_PTHREADS=1 -s WASM=1 -s PTHREAD_POOL_SIZE=navigator.hardwareConcurrency -s PROXY_TO_PTHREAD -s USE_SDL=2 -s USE_SDL_TTF=2 -s TOTAL_MEMORY=1024MB

produces this error:

wasm-ld: error: --shared-memory is disallowed by sfnt.c.o because it was not compiled with 'atomics' or 'bulk-memory' features.

The solution, as @cm226 advised, is to edit both tools/ports/sdl_ttf2.py and tools/ports/freetype.py by adding the -pthread flag to the build commands (then rebuilding them after emcc --clear-ports)

@kripken
Copy link
Member

kripken commented Apr 4, 2022

A PR to fix this would be great. See tools/ports/sdl2.py for how to handle pthreads in a port.

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

No branches or pull requests

3 participants