Debugging Build Failures#

There are several common failures that can occur when building packages with pyodide-build. This guide helps you identify the phase and apply the right fix.

Configuration errors#

CMake: “Could not find toolchain file”#

The CMake toolchain file wasn’t found or passed correctly.

Fix: pyodide-build injects the toolchain automatically. If it doesn’t work:

CMAKE_TOOLCHAIN_FILE=$(pyodide config get cmake_toolchain_file)
pyodide build . -Ccmake.toolchain="$CMAKE_TOOLCHAIN_FILE"

Meson: “Cross file not found” or wrong target architecture#

The Meson cross file wasn’t injected or passed correctly.

Fix:

MESON_CROSS_FILE=$(pyodide config get meson_cross_file)
pyodide build . -Csetup-args=--cross-file="$MESON_CROSS_FILE"

Compilation errors#

“‘something.h’ file not found”#

These may fall into two categories:

  1. system headers that is not supported by Emscripten

  2. a third party header that is not linked properly

If the header is from a system library, search it in the Emscripten repository to check if it’s available. If it’s not available, you need to update your code to use a different approach.

If the header is from a third party library, check if it’s searched and linked properly. As you need a cross-compiled version of the library, you need to check if pkg-config or CMake or other build systems are configured to find the cross-compiled version correctly.

“error: unsupported option ‘-some-config’”#

It means that the Emscripten compiler doesn’t support the option.

Fix: Conditionally disable the flag using the PYODIDE environment variable:

import os
if not os.environ.get("PYODIDE"):
    extra_compile_args.append("-some-config")

“error: use of undeclared identifier” (platform-specific code)#

Code uses platform-specific APIs (Linux, macOS, Windows) that don’t exist in Emscripten.

Fix: Guard with __EMSCRIPTEN__:

#ifdef __EMSCRIPTEN__
// Emscripten-compatible code
#else
// Platform-specific code
#endif

Build system errors#

pip/build isolation failures#

If the build fails during dependency installation in the isolated environment:

Fix: Use --no-isolation and manage dependencies manually:

pip install setuptools numpy cython  # install build deps
pyodide build . --no-isolation

Getting more information#

Verbose output#

Use export EMCC_DEBUG=1 to get more detailed output from the Emscripten compiler.

This can be useful for debugging linker errors and other build issues.

export EMCC_DEBUG=1
pyodide build .

Increase verbosity to see exactly what commands are being run:

# setuptools
pyodide build . -C "--global-option=--verbose"

# Meson
pyodide build . -Csetup-args=-Dwerror=false -Cbuildtype=debug

Check active configuration#

pyodide config list

This shows all active build variables including compiler flags, paths, and versions.

Useful tools#

  • Wasm Binary Toolkit (wabt)wasm-objdump, wasm2wat, and other tools for analyzing .wasm, .so, .a, and .o files. Essential for diagnosing linker errors and symbol issues.

  • Emscripten debugging guide — extensive documentation on debugging options available in Emscripten.

  • Chromium DevTools — use a Chromium-based browser for debugging WebAssembly runtime errors. They have the best Wasm debugging support.

What’s next?#