Link libatomic where 64-bit atomics are not native, fixing the piwheels build - #71
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The piwheels build of the 1.0.0 sdist fails on Python 3.11 (Raspberry Pi OS Bookworm, 32-bit). Raspberry Pi OS compiles for armv6 by default, where the 8-byte
std::atomicoperations of the C++ core (the int64 atomics insupermalloc.cpp,clock.hpp,placement.cpp,collision.cpp) have no native instruction and become calls into libatomic:__atomic_load_8,__atomic_store_8,__atomic_fetch_add_8,__atomic_compare_exchange_8.nanobind_add_modulelinks without--no-undefined, so the.solinks fine but cannot be loaded. The_cpp_stubtarget, which runs inALL, imports the freshly built module to regenerate_cpp.pyi, so the build aborts right after linking with an undefined-symbolImportError. The same defect would break any 32-bit ARM user at import time even if the wheel had been produced.Reproduced by cross-compiling the sources with
arm-linux-gnueabihf-g++ -marm -march=armv6+fp -mfpu=vfp -mfloat-abi=hardand loading the result under qemu:Fix
CMakeLists.txtprobes whether a 64-bit atomic links natively (check_cxx_source_compiles) and linksatomicinto_cppwhen it does not. Where libatomic is missing as well, the linker reports it.Verification
libatomic.so.1in NEEDEDdlopenunder qemuThe 1.0.0 sdist also builds cleanly on x86_64 with the current nanobind 3.0.1 and scikit-build-core 1.0.3 in pip build isolation, ruling out the build backend versions as the cause.