cmake: Emulate Libtool's behavior on NetBSD and OpenBSD #1860

pull hebasto wants to merge 4 commits into bitcoin-core:master from hebasto:260601-libtool-abi changing 2 files +66 −28
  1. hebasto commented at 8:56 PM on June 1, 2026: member

    This is a continuation of #1685.

    Additionally, the logic has been factored out into its own module and the documentation has been also improved.

  2. real-or-random added the label build on Jun 2, 2026
  3. real-or-random added the label tweak/refactor on Jun 2, 2026
  4. hebasto commented at 7:15 PM on June 6, 2026: member

    Here are GHA jobs that show ABI versioning: https://github.com/hebasto/secp256k1/actions/runs/27071316706.

    Undrafted.

  5. hebasto marked this as ready for review on Jun 6, 2026
  6. real-or-random commented at 9:26 AM on June 9, 2026: contributor

    Concept ACK

  7. hebasto commented at 10:58 AM on June 9, 2026: member

    @theStack

    Fancy checking the OpenBSD part?

  8. in cmake/LibtoolCompatibleABI.cmake:3 in 8b6087f62e
       0 | @@ -0,0 +1,28 @@
       1 | +# This emulates Libtool to make sure Libtool and CMake agree on the ABI version,
       2 | +# see below "Calculate the version variables" in autotools-aux/ltmain.sh.
       3 | +function(secp256k1_set_libtool_abi_version target current revision age)
    


    real-or-random commented at 11:02 AM on June 9, 2026:

    naming: All other custom functions in cmake/ don't have the secp256k1_ prefix and the filename matches the function name.


    hebasto commented at 12:28 PM on June 9, 2026:

    Thanks! Updated.

  9. real-or-random requested review from Copilot on Jun 9, 2026
  10. ?
    copilot_work_started real-or-random
  11. Copilot commented at 11:06 AM on June 9, 2026: none

    Pull request overview

    This PR refactors CMake-side shared library ABI/version handling into a dedicated module and extends the Libtool-compatibility logic to cover NetBSD and OpenBSD, continuing the work from #1685 to keep Autotools/Libtool and CMake installs consistent.

    Changes:

    • Factor Libtool-compatible ABI version property logic into a new cmake/LibtoolCompatibleABI.cmake module.
    • Update the secp256k1 target to use the new helper function rather than inline platform conditionals.
    • Add NetBSD/OpenBSD-specific versioning behavior intended to match Libtool’s platform rules.

    Reviewed changes

    Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

    File Description
    src/CMakeLists.txt Replaces inline ABI/version property logic with a call into the new Libtool-compatibility module.
    cmake/LibtoolCompatibleABI.cmake New helper implementing per-OS ABI/version property rules (Linux/FreeBSD/NetBSD/OpenBSD/macOS/Windows).

    💡 <a href="/bitcoin-core/secp256k1/new/master?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.

  12. cmake, refactor: Introduce `SetLibtoolAbiVersion` module acf2084aa7
  13. cmake, refactor: Improve documenting in `SetLibtoolAbiVersion` module 8a0f4002c7
  14. cmake: Fix shared library versioning on NetBSD a401c5145a
  15. cmake: Fix shared library versioning on OpenBSD 1eab757207
  16. in cmake/SetLibtoolAbiVersion.cmake:36 in 13a403c6a9 outdated
      31 | +  elseif(APPLE)
      32 | +    math(EXPR _compatibility "${current} + 1")
      33 | +    set_target_properties(${target} PROPERTIES
      34 | +      MACHO_COMPATIBILITY_VERSION ${_compatibility}
      35 | +      MACHO_CURRENT_VERSION ${_compatibility}.${revision}
      36 | +    )
    


    Copilot commented at 11:06 AM on June 9, 2026:

    On Apple, the previous logic always set SOVERSION (computed from current - age) before applying Mach-O version properties. In the new helper function the Apple branch sets only MACHO_* properties, so SOVERSION is no longer set, which can change the installed dylib name/symlink layout and break the goal of keeping Libtool and CMake ABI versioning aligned.


    real-or-random commented at 11:59 AM on June 9, 2026:

    Hm, the LLM has a point:

    For shared libraries, the MACHO_COMPATIBILITY_VERSION and MACHO_CURRENT_VERSION properties can be used to override the compatibility version and current version respectively. Note that SOVERSION will still be used to form the install_name and both SOVERSION and VERSION may also affect the file and symlink names.

    https://cmake.org/cmake/help/latest/prop_tgt/SOVERSION.html


    hebasto commented at 12:27 PM on June 9, 2026:

    Hm, the LLM has a point:

    Indeed. Fixed.

  17. in cmake/LibtoolCompatibleABI.cmake:4 in 13a403c6a9
       0 | @@ -0,0 +1,51 @@
       1 | +# This emulates Libtool to make sure Libtool and CMake agree on the ABI version.
       2 | +# The `version_type` variable is set in autotools-aux/m4/libtool.m4.
       3 | +# For the `major` and `versuffix` variables, see below "Calculate the version
       4 | +# variables" in autotools-aux/ltmain.sh.
    


    Copilot commented at 11:06 AM on June 9, 2026:

    The header comment points readers to autotools-aux/m4/libtool.m4 and autotools-aux/ltmain.sh, but those files are not present in the repository checkout (they are typically generated/installed by autoreconf). Consider clarifying that these files are produced by the Autotools bootstrap step so the references are actionable for someone reading the source tree.


    hebasto commented at 12:28 PM on June 9, 2026:
  18. hebasto force-pushed on Jun 9, 2026
  19. hebasto commented at 12:27 PM on June 9, 2026: member

    The recent feedback has been addressed.

    Here are GHA jobs that show ABI versioning on OpenBSD, NetBSD and macOS: https://github.com/hebasto/secp256k1/actions/runs/27205923502.

  20. real-or-random approved
  21. real-or-random commented at 9:07 AM on June 16, 2026: contributor

    @theStack

    Fancy checking the OpenBSD part? @hebasto I tend to think your custom CI runs are sufficient for testing this change. Let me just merge this.

  22. real-or-random merged this on Jun 16, 2026
  23. real-or-random closed this on Jun 16, 2026

  24. real-or-random added the label needs-changelog on Jun 16, 2026
  25. real-or-random commented at 9:18 AM on June 16, 2026: contributor

    Note for the changelog:

    • OpenBSD and NetBSD CMake: The actual file is now libsecp256k1.so.6.2 instead of libsecp256k1.so.6, and this matches what libtool does.
  26. hebasto deleted the branch on Jun 16, 2026
  27. sedited referenced this in commit 1f3f0a4e22 on Jun 19, 2026
  28. sedited referenced this in commit f6939fd13d on Jun 19, 2026
  29. Kino1994 referenced this in commit 1bb0d0bbaf on Jun 28, 2026
  30. real-or-random referenced this in commit 2af926dc30 on Jul 9, 2026
  31. theStack referenced this in commit 3faf750cdf on Jul 28, 2026
  32. theStack referenced this in commit b77f728a61 on Jul 28, 2026
  33. theStack referenced this in commit f52eb393c4 on Jul 28, 2026
  34. real-or-random referenced this in commit 7151e3b843 on Jul 28, 2026
  35. real-or-random removed the label needs-changelog on Jul 28, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-08-11 21:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me