emscripten-core / emscripten-core/emscripten
Compilation error with -sUSE_SDL_TTF=2 and -sMAIN_MODULE=2
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
**Version of emscripten/emsdk:**
3.1.41
**Failing command line in full:**
```
$ emcc -pthread -sUSE_SDL=2 -sUSE_SDL_TTF=2 -sMAIN_MODULE=2 main.c
shared:INFO: (Emscripten: Running sanity checks)
cache:INFO: generating system headers: sysroot_install.stamp... (this will be cached in "/Users/amit/dev/rdp-wasm-core/vendor/emsdk/upstream/emscripten/cache/sysroot_install.stamp" for subsequent builds)
cache:INFO: - ok
ports:INFO: retrieving port: freetype from https://github.com/emscripten-ports/FreeType/archive/version_1.zip
ports:INFO: unpacking port: freetype
cache:INFO: generating port: sysroot/lib/wasm32-emscripten/pic/libfreetype.a... (this will be cached in "/Users/amit/dev/rdp-wasm-core/vendor/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/pic/libfreetype.a" for subsequent builds)
system_libs:INFO: compiled 52 inputs
cache:INFO: - ok
ports:INFO: retrieving port: sdl2 from https://github.com/libsdl-org/SDL/archive/release-2.24.2.zip
ports:INFO: unpacking port: sdl2
cache:INFO: generating port: sysroot/lib/wasm32-emscripten/pic/libSDL2-mt.a... (this will be cached in "/Users/amit/dev/rdp-wasm-core/vendor/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/pic/libSDL2-mt.a" for subsequent builds)
system_libs:INFO: compiled 115 inputs
cache:INFO: - ok
ports:INFO: retrieving port: harfbuzz from https://github.com/harfbuzz/harfbuzz/releases/download/3.2.0/harfbuzz-3.2.0.tar.xz
ports:INFO: unpacking port: harfbuzz
cache:INFO: generating port: sysroot/lib/wasm32-emscripten/pic/libharfbuzz-mt.a... (this will be cached in "/Users/amit/dev/rdp-wasm-core/vendor/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/pic/libharfbuzz-mt.a" for subsequent builds)
system_libs:INFO: compiled 55 inputs
cache:INFO: - ok
ports:INFO: retrieving port: sdl2_ttf from https://github.com/libsdl-org/SDL_ttf/archive/release-2.20.2.zip
ports:INFO: unpacking port: sdl2_ttf
cache:INFO: generating port: sysroot/lib/wasm32-emscripten/pic/libSDL2_ttf.a... (this will be cached in "/Users/amit/dev/rdp-wasm-core/vendor/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/pic/libSDL2_ttf.a" for subsequent builds)
Traceback (most recent call last):
File "/Users/amit/dev/rdp-wasm-core/vendor/emsdk/upstream/emscripten/emcc.py", line 4416, in
sys.exit(main(sys.argv))
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/contextlib.py", line 79, in inner
return func(*args, **kwds)
File "/Users/amit/dev/rdp-wasm-core/vendor/emsdk/upstream/emscripten/emcc.py", line 4409, in main
ret = run(args)
File "/Users/amit/dev/rdp-wasm-core/vendor/emsdk/upstream/emscripten/emcc.py", line 1281, in run
linker_inputs = phase_compile_inputs(options, state, newargs, input_files)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/contextlib.py", line 79, in inner
return func(*args, **kwds)
File "/Users/amit/dev/rdp-wasm-core/vendor/emsdk/upstream/emscripten/emcc.py", line 3062, in phase_compile_inputs
compile_source_file(i, input_file)
File "/Users/amit/dev/rdp-wasm-core/vendor/emsdk/upstream/emscripten/emcc.py", line 3040, in compile_source_file
cmd = get_clang_command(input_file)
File "/Users/amit/dev/rdp-wasm-core/vendor/emsdk/upstream/emscripten/emcc.py", line 2974, in get_clang_command
return get_compiler(src_file) + get_cflags(state.orig_args, use_cxx(src_file)) + compile_args + [src_file]
File "/Users/amit/dev/rdp-wasm-core/vendor/emsdk/upstream/emscripten/emcc.py", line 1018, in get_cflags
ports.add_cflags(cflags, settings)
File "/Users/amit/dev/rdp-wasm-core/vendor/emsdk/upstream/emscripten/tools/ports/__init__.py", line 415, in add_cflags
port.get(Ports, settings, shared)
File "/Users/amit/dev/rdp-wasm-core/vendor/emsdk/upstream/emscripten/tools/ports/sdl2.py", line 77, in get
return [shared.cache.get_lib(get_lib_name(settings), create, what='port')]
File "/Users/amit/dev/rdp-wasm-core/vendor/emsdk/upstream/emscripten/tools/cache.py", line 139, in get_lib
return get(name, *args, **kwargs)
File "/Users/amit/dev/rdp-wasm-core/vendor/emsdk/upstream/emscripten/tools/cache.py", line 157, in get
with lock(shortname):
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/contextlib.py", line 117, in __enter__
return next(self.gen)
File "/Users/amit/dev/rdp-wasm-core/vendor/emsdk/upstream/emscripten/tools/cache.py", line 61, in lock
acquire_cache_lock(reason)
File "/Users/amit/dev/rdp-wasm-core/vendor/emsdk/upstream/emscripten/tools/cache.py", line 35, in acquire_cache_lock
assert 'EM_CACHE_IS_LOCKED' not in os.environ, f'attempt to lock the cache while a parent process is holding the lock ({reason})'
AssertionError: attempt to lock the cache while a parent process is holding the lock (sysroot/lib/wasm32-emscripten/pic/libSDL2.a)
emcc: error: Subprocess 1/1 failed (returned 1)! (cmdline: /Users/amit/dev/rdp-wasm-core/vendor/emsdk/upstream/emscripten/emcc -c /Users/amit/dev/rdp-wasm-core/vendor/emsdk/upstream/emscripten/cache/ports/sdl2_ttf/SDL_ttf-release-2.20.2/SDL_ttf.c -o /Users/amit/dev/rdp-wasm-core/vendor/emsdk/upstream/emscripten/cache/ports-builds/sdl2_ttf/SDL_ttf.c.o -g -sSTRICT -sRELOCATABLE -Werror -O2 -I/Users/amit/dev/rdp-wasm-core/vendor/emsdk/upstream/emscripten/cache/ports/sdl2_ttf/SDL_ttf-release-2.20.2 -DTTF_USE_HARFBUZZ=1 -sUSE_SDL=2 -sUSE_FREETYPE -sUSE_HARFBUZZ)
```
I am running on Mac M1 and it seems like some combination of settings to emcc cause the above error.
if I omit only `-sUSE_SDL_TTF=2`, the command works.
i.e. the following command does work:
```
emcc -pthread -sUSE_SDL=2 -sMAIN_MODULE=2 main.c
```
Contributor guide
Assessment
This issue has not been assessed yet.