Skip to content

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

Open
hebasto wants to merge 4 commits into
bitcoin-core:masterfrom
hebasto:260601-libtool-abi
Open

cmake: Emulate Libtool's behavior on NetBSD and OpenBSD#1860
hebasto wants to merge 4 commits into
bitcoin-core:masterfrom
hebasto:260601-libtool-abi

Conversation

@hebasto

@hebasto hebasto commented Jun 1, 2026

Copy link
Copy Markdown
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.

@hebasto

hebasto commented Jun 6, 2026

Copy link
Copy Markdown
Member Author

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

Undrafted.

@hebasto hebasto marked this pull request as ready for review June 6, 2026 19:15

@real-or-random real-or-random left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK

@hebasto

hebasto commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

@theStack

Fancy checking the OpenBSD part?

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Updated.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +31 to +36
elseif(APPLE)
math(EXPR _compatibility "${current} + 1")
set_target_properties(${target} PROPERTIES
MACHO_COMPATIBILITY_VERSION ${_compatibility}
MACHO_CURRENT_VERSION ${_compatibility}.${revision}
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, the LLM has a point:

Indeed. Fixed.

Comment thread cmake/LibtoolCompatibleABI.cmake Outdated
Comment on lines +1 to +4
# This emulates Libtool to make sure Libtool and CMake agree on the ABI version.
# The `version_type` variable is set in autotools-aux/m4/libtool.m4.
# For the `major` and `versuffix` variables, see below "Calculate the version
# variables" in autotools-aux/ltmain.sh.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hebasto hebasto force-pushed the 260601-libtool-abi branch from 13a403c to 1eab757 Compare June 9, 2026 12:24
@hebasto

hebasto commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants