Repository navigation
Cannot build from source on openbsd 7.4 #457
Copy link
Copy link
Open
Description
I've been testing out pyzmq's updated build system on scikit-build-core (great experience so far!).
openbsd doesn't have wheels, so this package attempts to build cmake, which in turn requires system-installed cmake (it would be super nice if #33 could be solved, so I didn't need to install cmake to get cmake).
Currently, building the cmake wheel fails with:
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc - broken
CMake Error at /usr/local/share/cmake/Modules/CMakeTestCCompiler.cmake:67 (mes
sage):
The C compiler
"/usr/bin/cc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: '/tmp/pip-install-kjsyd9hs/cmake_53a116a403e347e2803e32ebc0544
c72/_skbuild/openbsd-7.4-arm64-3.10/cmake-build/CMakeProject-build/CMakeFiles/CM
akeScratch/TryCompile-vovk2d'
Run Build Command(s): /usr/local/bin/cmake -E env VERBOSE=1 /usr/bin/make
-f Makefile cmTC_eda68/fast
/usr/bin/make -f CMakeFiles/cmTC_eda68.dir/build.make CMakeFiles/cmTC_eda
68.dir/build
Building C object CMakeFiles/cmTC_eda68.dir/testCCompiler.c.o
/usr/bin/cc -D_POSIX_C_SOURCE=199506L -D_POSIX_SOURCE=1 -D_SVID_SOURCE=1
-D_BSD_SOURCE=1 -MD -MT CMakeFiles/cmTC_eda68.dir/testCCompiler.c.o -MF CMakeF
iles/cmTC_eda68.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_eda68.dir/testCCompil
er.c.o -c /tmp/pip-install-kjsyd9hs/cmake_53a116a403e347e2803e32ebc0544c72/_skbu
ild/openbsd-7.4-arm64-3.10/cmake-build/CMakeProject-build/CMakeFiles/CMakeScratc
h/TryCompile-vovk2d/testCCompiler.c
Linking C executable cmTC_eda68
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_eda68.dir/link.t
xt --verbose=1
/usr/bin/cc -D_POSIX_C_SOURCE=199506L -D_POSIX_SOURCE=1 -D_SVID_SOURCE=1 -
D_BSD_SOURCE=1 -lstdc++ -lgcc -lrt CMakeFiles/cmTC_eda68.dir/testCCompiler.c.o
-o cmTC_eda68 -Wl,-rpath-link,/usr/X11R6/lib:/usr/local/lib:/home/vm
a5/build/bundled/lib
ld: error: unable to find library -lgcc
ld: error: unable to find library -lrt
cc: error: linker command failed with exit code 1 (use -v to see invocatio
n)
I don't know why cmake is looking for libgcc and librt, which don't make sense on openbsd, so I don't know if that's an issue for cmake itself or this package. FWIW, building my package after lowering the cmake requirement in my pyproject.toml to accept the system cmake (3.27.5) doesn't have this issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
minrk commentedon Feb 23, 2024
forgot to include the diagnostic info:
jcfr commentedon Mar 27, 2024
While investigating this issue, I took some notes:
Reviewing the change log associated with CMake 3.28.21, it is mentioned:
After review the associated merge request
MR-90852, it does not seem related to this issue.Reviewing the commit history, I also noticed Kitware/CMake@e527c2d (
LinkerId: Fix detection of linker tool for Clang on OpenBSD) introduced throughMR-90863, it also does not seem related to this issue.Footnotes
https://discourse.cmake.org/t/cmake-3-28-2-available-for-download/9961 ↩
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9085 ↩
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9086 ↩
gershnik commentedon Feb 23, 2026
The problem is in the code below. The check on line 278 is deeply wrong. Saying "any Unix which is not an Apple one or FreeBSD must use these exact flags", which contain
-lstdc++ -lgcc -lrtis certain to fail on various clang based systems out there including OpenBSD.cmake-python-distributions/CMakeLists.txt
Lines 278 to 288 in 6d23b00
henryiii commentedon Feb 23, 2026
Do you know what it should be? We can change it.
gershnik commentedon Feb 23, 2026
Well this depends on why all these flags were added to begin with. Which, unfortunately, I couldn't figure out from the GitHub history (perhaps my GitHub-foo is lacking). Generally, CMake is perfectly capable of building itself and discovering libraries it needs on all extant Unix systems. It seems that some issue at some point forced the developers to add these overrides, but what was the issue and on which system(s)? If I knew I could suggest a more robust check.
minrk commentedon Feb 23, 2026
fwiw, added in #97 and revised to allow freebsd in #117.
Maybe it can just be removed now, if it was related to building on manylinux1?
henryiii commentedon Feb 23, 2026
There's a blame button in the UI, which in this case tracks it back to e4dd1d5; where it moved when manylinux1 was dropped, you can blame again and that probably would follow back to #97 as above. I'd say it's quite likely it can be removed and is only a manylinux1 artifact.
gershnik commentedon Feb 24, 2026
Great, that seems the best outcome!
As an aside, if it was meant to say "if Linux" then the canonical thing would have been:
Or perhaps there is even a more targeted way to know the intended Python platform tag via some CMake variable.
henryiii commentedon Feb 28, 2026
Could you see if 4.2.3 works?