Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SOVERSION computation logic in CMake to match libtool's #1976

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jaimergp
Copy link

@jaimergp jaimergp commented Sep 18, 2023

Closes #1857

It also adds MACHO_{COMPATIBILITY,CURRENT}_VERSION as recommended in CMake docs to match libtool's output. However, these properties require CMake >=3.17. Is it ok to bump it?

Before this PR

Given libarchive 3.6.2, autotools produces:

$ otool -L libarchive.13.dylib 
.../libarchive.13.dylib:
        @rpath/libarchive.13.dylib (compatibility version 20.0.0, current version 20.2.0)
        ....

CMake gives:

$ otool -L libarchive.19.dylib 
.../libarchive.19.dylib:
        @rpath/libarchive.19.dylib (compatibility version 19.0.0, current version 0.0.0)
        ...

Note:

  • Different install name
  • Different compatibility and current versions

After this PR

Both systems should produce the same install name, compatibility and current versions:

$ otool -L libarchive.13.dylib 
.../libarchive.13.dylib:
        @rpath/libarchive.13.dylib (compatibility version 20.0.0, current version 20.2.0)
        ....

@jaimergp jaimergp changed the title Fix SOVERSION computation logic in CMake Fix SOVERSION computation logic in CMake to match libtool's Sep 18, 2023
CMakeLists.txt Show resolved Hide resolved
Copy link
Contributor

@evelikov evelikov left a comment

Choose a reason for hiding this comment

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

Was speaking to a friend a few months back about the different DSO across autotools/cmake builds. Big thanks for taking a stab at this.

Few things worth* nothing:

  • decreasing the DSO version is usually a bad idea, although
  • Arch, Fedora, Gentoo, Debian - and maybe more linux distros - use the autotools build
  • others would need to either rebuild or have a local symlink hack until they can rebuild

With this PR my Arch box shows identical SONAME (yay) although the filename still differs libarchive.so.13.7.3 (autotools) vs libarchive.so.13 (cmake). Can we fix that as well please?

Looking at the PR itself - please squash the commits into one.

@jaimergp
Copy link
Author

jaimergp commented Oct 13, 2023

With this PR my Arch box shows identical SONAME (yay) although the filename still differs libarchive.so.13.7.3 (autotools) vs libarchive.so.13 (cmake). Can we fix that as well please?

I think last commit fixes that, but it feels a bit hacky? Not sure if there's a better way.

Note this produces the same files in both platforms:

Linux:

$PREFIX/lib/libarchive.so -> libarchive.so.13
$PREFIX/lib/libarchive.so.13 -> libarchive.so.13.7.3
$PREFIX/lib/libarchive.so.13.7.3
$ objdump -p libarchive.so.13.7.3 | grep SONAME
  SONAME               libarchive.so.13

macOS:

$PREFIX/lib/libarchive.13.7.3.dylib
$PREFIX/lib/libarchive.13.dylib -> libarchive.13.7.3.dylib
$PREFIX/lib/libarchive.dylib -> libarchive.13.7.3.dylib
$ otool -L libarchive.13.7.3.dylib 
libarchive.13.7.3.dylib:
        @rpath/libarchive.13.dylib (compatibility version 21.0.0, current version 21.3.0)

Not sure if we want the "full soversion" in macOS too, but there's a symlink so 🤷

@evelikov
Copy link
Contributor

I think last commit fixes that

Confirmed that it fixes that over here.

Note this produces the same files in both platforms

IMHO that's fine.

CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
@kientzle
Copy link
Contributor

decreasing the DSO version is usually a bad idea, although

Reiterating: the library version number can NEVER decrease. Making the version numbers the same is a good idea, but that must be done by increasing the lower value.

@evelikov
Copy link
Contributor

Updating the autotools version will lead to massive rebuilds in most linux distros. They are well suited for that, although I would request that maintainers add a clear NOTE either way - cmake downrev or autotools uprev - in the release notes.

Thanks in advance

Co-authored-by: isuruf <isuruf@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Different soname versions when built using autotools and cmake
4 participants