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

Add SONAME/SOVERSION to generated library #231

Merged
merged 1 commit into from
Dec 19, 2023

Conversation

mbanck
Copy link
Contributor

@mbanck mbanck commented Jan 9, 2022

Fixes #229

@loriab
Copy link
Collaborator

loriab commented Jan 10, 2022

@mbanck
Copy link
Contributor Author

mbanck commented Jan 10, 2022

Well current:revision:age is terribly convoluted and maps to some x.y.z number scheme (see the libxc Gitlab link; the [2:3:0] in libint's configure.ac maps to 2.0.3). It is my understanding that VERSION is supposed to be that x.y.z (see e.g. https://mail.kde.org/pipermail/kde-buildsystem/2008-April/004543.html) and SOVERSION the SONAME number encoded in the library (accessible via objdump -x | grep SONAME), and also the single-number API-level .x ending which gets symlinked.

I didn't realize the top-level configure.ac still has the libint_so_version; as this one did not get bumped for 2.7.1, I guess VERSION should be 2.0.3 then, not 2.0.4 as in this PR.

Also note that libxc does not seem to use ${PROJECT_NAME}_SOVERSION at all in its build system (other than to output it during configuring) and it is setting SOVERSION to ${PROJECT_NAME}_SOMAJOR in https://gitlab.com/libxc/libxc/-/blob/master/CMakeLists.txt#L474 consistent with what this PR is doing.

@mbanck
Copy link
Contributor Author

mbanck commented Jan 10, 2022

One more comment: As configure.ac is (to the best of my knowledge) not being pulled into the exported generated library tarball, it cannot be used by CMake similar to what LibXC does, that information just isn;t available I think.

Also, I guess the future is all-CMake, so this is a stop-gap measure. I would agree that it is pretty brittle if we would have to use it for a long time and always remember to bump the library version in both places, but this sounds like a one-off (or two-off) think, famous last words...

@evaleev
Copy link
Owner

evaleev commented Jan 13, 2022

@mbanck thanks ... I tried to understand what VERSION and SOVERSION are supposed to be (CMake's dox are no bueno) but I am still not sure about the best-practices:

  • It seems to me that since VERSION is for human consumption it is easiest to set it to the project version or to whatever the package maintainers (i.e. you) need it to be. I don't understand why it is set to 2.0.4 then ...
  • I gave up on API/ABI version tracking in this and other projects because it is far too easy to change the ABI (plus it is unrealistic to test ABI, etc.). Libint library's API/ABI is very stable but I cannot guarantee that it has only changed twice (is that what SOVERSION 2 means?) ... also: the SOVERSION implies library configuration (max AM, etc.) so if those change in the future SOVERSION would have to change?

@StefanBruens
Copy link

* I gave up on API/ABI version tracking in this and other projects because it is far too easy to change the ABI (plus it is unrealistic to test ABI, etc.). Libint library's API/ABI is very stable but I cannot guarantee that it has only changed twice (is that what `SOVERSION 2` means?) ... also: the `SOVERSION` implies library configuration (max AM, etc.) so if those change in the future `SOVERSION` would have to change?

SOVERSION is part of the SONAME. It should be bumped at least every time the ABI changes in a not-backwards compatible way. In case symbols are not versioned (e.g. using a linker version script, as is the case here), the SOVERSION should also be bumped every time the ABI is changed in a backwards compatible way (e.g. when adding new functions).

The library configuration is an orhogonal aspect. IMHO each configuration should have a different SONAME, and multiple libraries could be installed in parallel. According to #190, there are 20 different configurations, though only 5 seem to be actually used. E.g. psi4 could link to libint2_gss.

@loriab loriab mentioned this pull request Dec 16, 2023
@evaleev
Copy link
Owner

evaleev commented Dec 19, 2023

@loriab bumping this to revisit in the light of planned use of Libint2_CONFIG_COMPONENTS (see https://github.com/evaleev/libint/pull/259/files#diff-4a7c86a49b4b056d4c5e5adf66bb420b3e9adc79862abebde6f6c4fe358ed9b0R52)

  • presumably SONAME will need to include library configuration ... SONAME does not seem to be controlled directly, need to use VERSION? Should be introduce this mechanism now? (set Libint2_CONFIG_COMPONENTS to its current default, etc.)

@@ -194,7 +194,7 @@ endif()
# shared and static libraries built from the same object files
if (LIBINT2_BUILD_SHARED_AND_STATIC_LIBS)
add_library(libint2 SHARED $<TARGET_OBJECTS:libint2_obj>)
set_target_properties(libint2 PROPERTIES LIBRARY_OUTPUT_NAME int2)
set_target_properties(libint2 PROPERTIES LIBRARY_OUTPUT_NAME int2 VERSION 2.0.4 SOVERSION 2)
Copy link
Owner

Choose a reason for hiding this comment

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

would ${LIBINT_VERSION} would for VERSION?

Choose a reason for hiding this comment

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

As the API/ABI are not strictly controlled for backwards compatibility, the SOVERSION should be the same as the VERSION (better safe than sorry ...). This is the CMake default if SOVERSION is omitted.

set_target_properties(libint2 PROPERTIES
    LIBRARY_OUTPUT_NAME int2
    VERSION ${LIBINT_VERSION}
)

Copy link
Owner

Choose a reason for hiding this comment

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

Thanks. I think SOVERSION 2 is appropriate, the ABI of the library has been stable for many years.

@evaleev
Copy link
Owner

evaleev commented Dec 19, 2023

good starter-level explanation of SONAME and SOVERSION: https://crascit.com/wp-content/uploads/2019/09/Deep-CMake-For-Library-Authors-Craig-Scott-CppCon-2019.pdf

@evaleev evaleev changed the base branch from master to v2.8.x December 19, 2023 16:26
@evaleev evaleev merged commit d9eacb8 into evaleev:v2.8.x Dec 19, 2023
@loriab
Copy link
Collaborator

loriab commented Dec 19, 2023

I don't think this PR thoroughly added SOVERSION (see below for mac/linux with BUILD_SHARED_LIBS=ON). I haven't fully investigated, but the PR may have just caught the build-both-static-and-shared target.

2023-12-19T20:24:34.6214061Z -rwxr-xr-x  2 conda conda  4790576 Dec 19 20:23 libint2.so
2023-12-19T20:24:34.6214631Z lrwxrwxrwx  1 conda conda       15 Dec 19 20:24 libitm.so -> libitm.so.1.0.0
2023-12-19T20:24:34.6215059Z lrwxrwxrwx  1 conda conda       15 Dec 19 20:24 libitm.so.1 -> libitm.so.1.0.0
2023-12-19T20:24:34.6215442Z -rwxrwxr-x  1 conda conda   773744 Nov 12 01:46 libitm.so.1.0.0
2023-12-19T20:33:15.3850370Z -rwxr-xr-x    2 runner  staff    4923120 Dec 19 20:30 libint2.dylib
2023-12-19T20:33:15.3851270Z -rwxrwxr-x    4 runner  staff      75584 Aug 15 11:12 libk5crypto.3.1.dylib
2023-12-19T20:33:15.3902810Z lrwxr-xr-x    1 runner  staff         21 Dec 19 20:33 libk5crypto.3.dylib -> libk5crypto.3.1.dylib
2023-12-19T20:33:15.3952710Z lrwxr-xr-x    1 runner  staff         21 Dec 19 20:33 libk5crypto.dylib -> libk5crypto.3.1.dylib

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.

CMake-built shared library is missing SONAME / library versioning
5 participants