emscripten-core / emscripten-core/emscripten

Build fails due to Unknown archive format on Mac M2

Open
#20,986 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Please include the following in your bug report:

**Version of emscripten/emsdk:**
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.46 (19607820c447a13fd8d0b7680c56148427d6e1b8)
clang version 18.0.0 (https://github.com/llvm/llvm-project 75501f53624de92aafce2f1da698b249a7293dc7)

I was building the C program with ported SDL2, SDL2_image, and SDL2_ttf.

The build command:
```
emcc main.cpp -s WASM=1 -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='["png"]' -s USE_SDL_TTF=2 --preload-file res -o index.js
```

But get error:
```
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
Traceback (most recent call last):
File "/Users/chinyikming/emsdk/upstream/emscripten/emcc.py", line 4465, in
sys.exit(main(sys.argv))
File "/Users/chinyikming/emsdk/python/3.9.2_64bit/lib/python3.9/contextlib.py", line 79, in inner
return func(*args, **kwds)
File "/Users/chinyikming/emsdk/upstream/emscripten/emcc.py", line 4458, in main
ret = run(args)
File "/Users/chinyikming/emsdk/upstream/emscripten/emcc.py", line 1284, in run
linker_inputs = phase_compile_inputs(options, state, newargs, input_files)
File "/Users/chinyikming/emsdk/python/3.9.2_64bit/lib/python3.9/contextlib.py", line 79, in inner
return func(*args, **kwds)
File "/Users/chinyikming/emsdk/upstream/emscripten/emcc.py", line 3140, in phase_compile_inputs
compile_source_file(i, input_file)
File "/Users/chinyikming/emsdk/upstream/emscripten/emcc.py", line 3118, in compile_source_file
cmd = get_clang_command(input_file)
File "/Users/chinyikming/emsdk/upstream/emscripten/emcc.py", line 3052, in get_clang_command
return get_compiler(src_file) + get_cflags(state.orig_args, use_cxx(src_file)) + compile_args + [src_file]
File "/Users/chinyikming/emsdk/upstream/emscripten/emcc.py", line 1021, in get_cflags
ports.add_cflags(cflags, settings)
File "/Users/chinyikming/emsdk/upstream/emscripten/tools/ports/__init__.py", line 416, in add_cflags
port.get(Ports, settings, shared)
File "/Users/chinyikming/emsdk/upstream/emscripten/tools/ports/harfbuzz.py", line 82, in get
ports.fetch_project('harfbuzz', f'https://github.com/harfbuzz/harfbuzz/releases/download/{VERSION}/harfbuzz-{VERSION}.tar.xz', sha512hash=HASH)
File "/Users/chinyikming/emsdk/upstream/emscripten/tools/ports/__init__.py", line 303, in fetch_project
unpack()
File "/Users/chinyikming/emsdk/upstream/emscripten/tools/ports/__init__.py", line 276, in unpack
shutil.unpack_archive(filename=fullpath, extract_dir=fullname)
File "/Users/chinyikming/emsdk/python/3.9.2_64bit/lib/python3.9/shutil.py", line 1241, in unpack_archive
raise ReadError("Unknown archive format '{0}'".format(filename))
shutil.ReadError: Unknown archive format '/Users/chinyikming/emsdk/upstream/emscripten/cache/ports/harfbuzz.2.0.tar.xz'
```

It was solved by setting the `EMSDK_PYTHON` to system-wide python3:
```
export EMSDK_PYTHON=/usr/bin/python3
```
My system-wide python3 version is 3.9.6 and the default `EMSDK_PYTHON` is `3.9.2`.

Solution is from: #982

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.