Skip to content

Cannot build from source on openbsd 7.4 #457

Open

Description

@minrk

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.

Activity

  1. minrk commented on Feb 23, 2024

    @minrk
    Author

    forgot to include the diagnostic info:

          Python: 3.10.13
          platform: OpenBSD-7.4-arm64-aarch64-64bit-ELF
          machine: arm64
          bits: 64
          pip: n/a
          setuptools: 69.1.0
          scikit-build: 0.17.6
          PEP517_BUILD_BACKEND=setuptools.build_meta
          =============================DEBUG ASSISTANCE=============================
    
      An error occurred while building with CMake.
        Command:
          /usr/local/bin/cmake --build . --target install --config Release --
        Install target:
          install
        Source directory:
          /tmp/pip-install-kjsyd9hs/cmake_53a116a403e347e2803e32ebc0544c72
        Working directory:
          /tmp/pip-install-kjsyd9hs/cmake_53a116a403e347e2803e32ebc0544c72/_skbuild/
    openbsd-7.4-arm64-3.10/cmake-build
      Please check the install target is valid and see CMake's output for more infor
    mation.
    
  2. jcfr commented on Mar 27, 2024

    @jcfr
    Contributor

    While investigating this issue, I took some notes:


    Reviewing the change log associated with CMake 3.28.21, it is mentioned:

    Source: Restore compilation on OpenBSD

    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 through MR-90863, it also does not seem related to this issue.

    Footnotes

    1. https://discourse.cmake.org/t/cmake-3-28-2-available-for-download/9961 ↩

    2. https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9085 ↩

    3. https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9086 ↩

  3. gershnik commented on Feb 23, 2026

    @gershnik

    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 -lrt is certain to fail on various clang based systems out there including OpenBSD.

    if(UNIX AND (NOT APPLE AND NOT CMAKE_SYSTEM_NAME STREQUAL "FreeBSD"))
    # Since CMAKE_C_FLAGS and CMAKE_EXE_LINKER_FLAGS arguments contain spaces, we generate an initial
    # cache file.
    file(WRITE "${CMAKE_BINARY_DIR}/initial-cache.txt"
    "set(CMAKE_C_FLAGS \"-D_POSIX_C_SOURCE=199506L -D_POSIX_SOURCE=1 -D_SVID_SOURCE=1 -D_BSD_SOURCE=1\" CACHE STRING \"Initial cache\" FORCE)
    set(CMAKE_EXE_LINKER_FLAGS \"-lstdc++ -lgcc -lrt\" CACHE STRING \"Initial cache\" FORCE)
    ")
    set(_cmake_args
    CMAKE_ARGS -C "${CMAKE_BINARY_DIR}/initial-cache.txt"
    )
    endif()

  4. henryiii commented on Feb 23, 2026

    @henryiii
    Contributor

    Do you know what it should be? We can change it.

  5. gershnik commented on Feb 23, 2026

    @gershnik

    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.

  6. minrk commented on Feb 23, 2026

    @minrk
    Author

    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?

  7. henryiii commented on Feb 23, 2026

    @henryiii
    Contributor

    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.

  8. gershnik commented on Feb 24, 2026

    @gershnik

    Great, that seems the best outcome!

    As an aside, if it was meant to say "if Linux" then the canonical thing would have been:

    if (CMAKE_SYSTEM_NAME STREQUAL "Linux")

    Or perhaps there is even a more targeted way to know the intended Python platform tag via some CMake variable.

  9. henryiii commented on Feb 28, 2026

    @henryiii
    Contributor

    Could you see if 4.2.3 works?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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