Skip to content

Building cmake pybind11 project fails with libatomic link error #257

@mducle

Description

@mducle

I tried to build a project which uses CMake and Pybind11 for pyodide-0.29 on Python 3.13 but get a linker error:

wasm-opt: error while loading shared libraries: libatomic.so.1: cannot open shared object file: No such file or directory
em++: error: error running binaryen executable (wasm-opt). Please check your binaryen installation

I also tested this with the Pybind11/cmake example project where I updated the pybind11 submodule to v3.0.0 and changed the CMakeList.txt file to:

cmake_minimum_required(VERSION 3.4...3.18)
project(cmake_example)

cmake_policy(SET CMP0148 OLD)  # New policy gives error finding Python
if (EMSCRIPTEN)
  set(PYBIND11_USE_CROSSCOMPILING TRUE)
endif()

add_subdirectory(pybind11)
pybind11_add_module(cmake_example src/main.cpp)

# EXAMPLE_VERSION_INFO is defined by setup.py and passed into the C++ code as a
# define (VERSION_INFO) here.
target_compile_definitions(cmake_example
                           PRIVATE VERSION_INFO=${EXAMPLE_VERSION_INFO})

and get the same error.

I think a change in CPython-3.13.1 ( python/cpython#127708 ) might be the issue.

If I use pyodide-0.28 and Python-3.12 then pyodide build works fine.

Output of pyodide config list:

emscripten_version="4.0.9"
python_version="3.13.2"
rustflags="-C link-arg=-sSIDE_MODULE=2 -Z link-native-libraries=yes -Z emscripten-wasm-eh"
cmake_toolchain_file="~/.conda/envs/ems313/lib/python3.13/site-packages/pyodide_build/tools/cmake/Modules/Platform/Emscripten.cmake"
rust_toolchain="nightly-2025-02-01"
rust_emscripten_target_url="https://github.com/pyodide/rust-emscripten-wasm-eh-sysroot/releases/download/emcc-4.0.9_nightly-2025-02-01/emcc-4.0.9_nightly-2025-02-01.tar.bz2"
cflags="-O2 -g0 -fPIC -fwasm-exceptions -sSUPPORT_LONGJMP -I~/.cache/.pyodide-xbuildenv-0.30.9/0.29.0/xbuildenv/pyodide-root/cpython/installs/python-3.13.2/include/python3.13"
cxxflags=""
ldflags="-O2 -g0  -L~/.cache/.pyodide-xbuildenv-0.30.9/0.29.0/xbuildenv/pyodide-root/cpython/installs/python-3.13.2/lib/ -s WASM_BIGINT -fwasm-exceptions -sSUPPORT_LONGJMP -s SIDE_MODULE=1"
meson_cross_file="~/.conda/envs/ems313/lib/python3.13/site-packages/pyodide_build/tools/emscripten.meson.cross"
xbuildenv_path=""
pyodide_abi_version="2025_0"
pyodide_root="~/.cache/.pyodide-xbuildenv-0.30.9/0.29.0/xbuildenv/pyodide-root"
dist_dir="~/.cache/.pyodide-xbuildenv-0.30.9/0.29.0/xbuildenv/pyodide-root/dist"
python_include_dir="~/.cache/.pyodide-xbuildenv-0.30.9/0.29.0/xbuildenv/pyodide-root/cpython/installs/python-3.13.2/include/python3.13"
ignored_build_requirements="patchelf oldest-supported-numpy"
interpreter="~/.cache/.pyodide-xbuildenv-0.30.9/0.29.0/xbuildenv/pyodide-root/dist/python"
package_index="~/.cache/.pyodide-xbuildenv-0.30.9/0.29.0/xbuildenv/pyodide-root/package_index"

I'm using a conda environment created with mamba create -n ems313 python=3.13 pyodide-build

I noticed that one of the recipes project uses a restriction to pybind < 3 but even if I use pybind-2.9.2 I still get the libatomic error (also the macro PYBIND11_USE_CROSSCOMPILING was only introduced in pybind-3 so you have to replace that line with unset(CMAKE_SIZEOF_VOID_P) otherwise you get a Python config failure: Python is 64-bit, chosen compiler is 32-bit error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions