Mailinglist Archive: zypp-devel (18 mails)
| < Previous | Next > |
[zypp-devel] Shared library for libsatsolver
- From: Michael Tremer <michael.tremer@xxxxxxxxxx>
- Date: Thu, 21 Apr 2011 13:06:19 +0200
- Message-id: <1303383979.2356.34.camel@rice-oxley.tremer.info>
Hello guys,
I have been recently talking to Klaus about this and he asked me to post
this on the mailing list.
libsatsolver comes with a static library which is against policies of
several distributions and anyway, not a good way to distribute code.
As the code and especially the ABI is very stable I would say there is
no other reason to keep the library static and do a shared one instead.
Benefits would be a better integration into other distributions and
getting fixes and changes to the distribution without recompiling
bindings, etc.
Additionally, this shared library is versioned.
I attached a patch to this mail and hope it would be committed to the
source repository. There are no issues to expect if the linking is done
properly.
Sincerely,
Michael
Date: Thu, 21 Apr 2011 12:48:41 +0200
Subject: [PATCH] Make libsatsolver{,ext} a versioned shared lib.
Most distributions only do accept shared libraries because of
relro and hardening stuff.
Previously, libsatsolver was statically compiled because the ABI
was assumed to be changed from time to time but has now become
very stable.
Signed-off-by: Michael Tremer <michael.tremer@xxxxxxxxxx>
---
ext/CMakeLists.txt | 6 +++++-
src/CMakeLists.txt | 6 +++++-
tools/CMakeLists.txt | 12 ++++++------
3 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/ext/CMakeLists.txt b/ext/CMakeLists.txt
index 8e71eee..68e1c3c 100644
--- a/ext/CMakeLists.txt
+++ b/ext/CMakeLists.txt
@@ -8,7 +8,11 @@ SET(libsatsolverext_SRCS
${libsatsolverext_SRCS} pool_fileconflicts.c repo_rpmdb.c)
ENDIF (NOT DEBIAN)
-ADD_LIBRARY(satsolverext STATIC ${libsatsolverext_SRCS})
+ADD_LIBRARY(satsolverext SHARED ${libsatsolverext_SRCS})
+SET_TARGET_PROPERTIES(satsolverext PROPERTIES
+ VERSION "${LIBSATSOLVER_MAJOR}.${LIBSATSOLVER_MINOR}"
+ SOVERSION "${LIBSATSOLVER_MAJOR}"
+)
SET(libsatsolverext_HEADERS
pool_fileconflicts.h repo_content.h repo_deltainfoxml.h repo_helix.h
repo_products.h
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9bd0fde..6a14d10 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -6,7 +6,11 @@ SET(libsatsolver_SRCS
transaction.c rules.c problems.c
chksum.c md5.c sha1.c sha2.c satversion.c)
-ADD_LIBRARY(satsolver STATIC ${libsatsolver_SRCS})
+ADD_LIBRARY(satsolver SHARED ${libsatsolver_SRCS})
+SET_TARGET_PROPERTIES(satsolver PROPERTIES
+ VERSION "${LIBSATSOLVER_MAJOR}.${LIBSATSOLVER_MINOR}"
+ SOVERSION "${LIBSATSOLVER_MAJOR}"
+)
SET(libsatsolver_HEADERS
bitmap.h evr.h hash.h policy.h poolarch.h poolvendor.h pool.h
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 79d4890..7696612 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -20,19 +20,19 @@ ADD_EXECUTABLE(rpmmd2solv rpmmd2solv.c)
TARGET_LINK_LIBRARIES(rpmmd2solv toolstuff satsolverext satsolver
${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
ADD_EXECUTABLE(helix2solv helix2solv.c)
-TARGET_LINK_LIBRARIES(helix2solv toolstuff satsolverext satsolver
${EXPAT_LIBRARY})
+TARGET_LINK_LIBRARIES(helix2solv toolstuff satsolverext satsolver
${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
ADD_EXECUTABLE(susetags2solv susetags2solv.c)
-TARGET_LINK_LIBRARIES(susetags2solv toolstuff satsolverext satsolver
${ZLIB_LIBRARY})
+TARGET_LINK_LIBRARIES(susetags2solv toolstuff satsolverext satsolver
${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
ADD_EXECUTABLE(updateinfoxml2solv updateinfoxml2solv.c)
-TARGET_LINK_LIBRARIES(updateinfoxml2solv toolstuff satsolverext satsolver
${EXPAT_LIBRARY})
+TARGET_LINK_LIBRARIES(updateinfoxml2solv toolstuff satsolverext satsolver
${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
ADD_EXECUTABLE(deltainfoxml2solv deltainfoxml2solv.c)
-TARGET_LINK_LIBRARIES(deltainfoxml2solv toolstuff satsolverext satsolver
${EXPAT_LIBRARY})
+TARGET_LINK_LIBRARIES(deltainfoxml2solv toolstuff satsolverext satsolver
${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
ADD_EXECUTABLE(repomdxml2solv repomdxml2solv.c)
-TARGET_LINK_LIBRARIES(repomdxml2solv toolstuff satsolverext satsolver
${EXPAT_LIBRARY})
+TARGET_LINK_LIBRARIES(repomdxml2solv toolstuff satsolverext satsolver
${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
ADD_EXECUTABLE(installcheck installcheck.c)
TARGET_LINK_LIBRARIES(installcheck satsolverext satsolver ${EXPAT_LIBRARY}
${ZLIB_LIBRARY})
@@ -44,7 +44,7 @@ ADD_EXECUTABLE(dumpsolv dumpsolv.c )
TARGET_LINK_LIBRARIES(dumpsolv satsolver)
ADD_EXECUTABLE(mergesolv mergesolv.c )
-TARGET_LINK_LIBRARIES(mergesolv toolstuff satsolverext satsolver)
+TARGET_LINK_LIBRARIES(mergesolv toolstuff satsolverext satsolver
${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
install(TARGETS
mergesolv
--
1.7.4.4
I have been recently talking to Klaus about this and he asked me to post
this on the mailing list.
libsatsolver comes with a static library which is against policies of
several distributions and anyway, not a good way to distribute code.
As the code and especially the ABI is very stable I would say there is
no other reason to keep the library static and do a shared one instead.
Benefits would be a better integration into other distributions and
getting fixes and changes to the distribution without recompiling
bindings, etc.
Additionally, this shared library is versioned.
I attached a patch to this mail and hope it would be committed to the
source repository. There are no issues to expect if the linking is done
properly.
Sincerely,
Michael
From 1f9659b55013f222046b9d161fd5a0f2fc399cb8 Mon Sep 17 00:00:00 2001From: Michael Tremer <michael.tremer@xxxxxxxxxx>
Date: Thu, 21 Apr 2011 12:48:41 +0200
Subject: [PATCH] Make libsatsolver{,ext} a versioned shared lib.
Most distributions only do accept shared libraries because of
relro and hardening stuff.
Previously, libsatsolver was statically compiled because the ABI
was assumed to be changed from time to time but has now become
very stable.
Signed-off-by: Michael Tremer <michael.tremer@xxxxxxxxxx>
---
ext/CMakeLists.txt | 6 +++++-
src/CMakeLists.txt | 6 +++++-
tools/CMakeLists.txt | 12 ++++++------
3 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/ext/CMakeLists.txt b/ext/CMakeLists.txt
index 8e71eee..68e1c3c 100644
--- a/ext/CMakeLists.txt
+++ b/ext/CMakeLists.txt
@@ -8,7 +8,11 @@ SET(libsatsolverext_SRCS
${libsatsolverext_SRCS} pool_fileconflicts.c repo_rpmdb.c)
ENDIF (NOT DEBIAN)
-ADD_LIBRARY(satsolverext STATIC ${libsatsolverext_SRCS})
+ADD_LIBRARY(satsolverext SHARED ${libsatsolverext_SRCS})
+SET_TARGET_PROPERTIES(satsolverext PROPERTIES
+ VERSION "${LIBSATSOLVER_MAJOR}.${LIBSATSOLVER_MINOR}"
+ SOVERSION "${LIBSATSOLVER_MAJOR}"
+)
SET(libsatsolverext_HEADERS
pool_fileconflicts.h repo_content.h repo_deltainfoxml.h repo_helix.h
repo_products.h
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9bd0fde..6a14d10 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -6,7 +6,11 @@ SET(libsatsolver_SRCS
transaction.c rules.c problems.c
chksum.c md5.c sha1.c sha2.c satversion.c)
-ADD_LIBRARY(satsolver STATIC ${libsatsolver_SRCS})
+ADD_LIBRARY(satsolver SHARED ${libsatsolver_SRCS})
+SET_TARGET_PROPERTIES(satsolver PROPERTIES
+ VERSION "${LIBSATSOLVER_MAJOR}.${LIBSATSOLVER_MINOR}"
+ SOVERSION "${LIBSATSOLVER_MAJOR}"
+)
SET(libsatsolver_HEADERS
bitmap.h evr.h hash.h policy.h poolarch.h poolvendor.h pool.h
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 79d4890..7696612 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -20,19 +20,19 @@ ADD_EXECUTABLE(rpmmd2solv rpmmd2solv.c)
TARGET_LINK_LIBRARIES(rpmmd2solv toolstuff satsolverext satsolver
${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
ADD_EXECUTABLE(helix2solv helix2solv.c)
-TARGET_LINK_LIBRARIES(helix2solv toolstuff satsolverext satsolver
${EXPAT_LIBRARY})
+TARGET_LINK_LIBRARIES(helix2solv toolstuff satsolverext satsolver
${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
ADD_EXECUTABLE(susetags2solv susetags2solv.c)
-TARGET_LINK_LIBRARIES(susetags2solv toolstuff satsolverext satsolver
${ZLIB_LIBRARY})
+TARGET_LINK_LIBRARIES(susetags2solv toolstuff satsolverext satsolver
${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
ADD_EXECUTABLE(updateinfoxml2solv updateinfoxml2solv.c)
-TARGET_LINK_LIBRARIES(updateinfoxml2solv toolstuff satsolverext satsolver
${EXPAT_LIBRARY})
+TARGET_LINK_LIBRARIES(updateinfoxml2solv toolstuff satsolverext satsolver
${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
ADD_EXECUTABLE(deltainfoxml2solv deltainfoxml2solv.c)
-TARGET_LINK_LIBRARIES(deltainfoxml2solv toolstuff satsolverext satsolver
${EXPAT_LIBRARY})
+TARGET_LINK_LIBRARIES(deltainfoxml2solv toolstuff satsolverext satsolver
${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
ADD_EXECUTABLE(repomdxml2solv repomdxml2solv.c)
-TARGET_LINK_LIBRARIES(repomdxml2solv toolstuff satsolverext satsolver
${EXPAT_LIBRARY})
+TARGET_LINK_LIBRARIES(repomdxml2solv toolstuff satsolverext satsolver
${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
ADD_EXECUTABLE(installcheck installcheck.c)
TARGET_LINK_LIBRARIES(installcheck satsolverext satsolver ${EXPAT_LIBRARY}
${ZLIB_LIBRARY})
@@ -44,7 +44,7 @@ ADD_EXECUTABLE(dumpsolv dumpsolv.c )
TARGET_LINK_LIBRARIES(dumpsolv satsolver)
ADD_EXECUTABLE(mergesolv mergesolv.c )
-TARGET_LINK_LIBRARIES(mergesolv toolstuff satsolverext satsolver)
+TARGET_LINK_LIBRARIES(mergesolv toolstuff satsolverext satsolver
${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
install(TARGETS
mergesolv
--
1.7.4.4
| < Previous | Next > |