]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Expand support for symbol versioning to also allow multiple functions
authorHans Kristian Rosbach <hk-git@circlestorm.org>
Thu, 29 Dec 2022 12:45:50 +0000 (13:45 +0100)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Mon, 24 Jul 2023 16:33:23 +0000 (18:33 +0200)
with the same name to exist with bindings to different versions.

CMakeLists.txt
configure
zbuild.h

index 003e66db758cfc6397cbb86d188ecb41ba79ce94..8d5d5ae9db92ec6b2595cc9e9dc8e99b6a2c0c7b 100644 (file)
@@ -1140,6 +1140,9 @@ if(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS)
             set_target_properties(zlib PROPERTIES COMPILE_FLAGS "-fno-semantic-interposition")
         endif()
         if(NOT APPLE)
+            if(NOT ZLIB_COMPAT)
+                add_definitions(-DHAVE_SYMVER)
+            endif()
             set_target_properties(zlib PROPERTIES LINK_FLAGS
                 "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib${SUFFIX}.map\"")
         elseif(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}" OR NOT WITH_RPATH)
index 53aa012a99838288f2257d2baf998a13df6a18d5..bb37b96640af99e7d43cb287a1ecd66b0d7592f7 100755 (executable)
--- a/configure
+++ b/configure
@@ -567,6 +567,22 @@ else
   esac
 fi
 
+# Symbol versioning
+case "$uname" in
+  CYGWIN* | Cygwin* | cygwin* | MINGW* | mingw* | MSYS* | msys* | Darwin* | darwin*)
+    echo "Checking for Symbol versioning... No."
+  ;;
+  *)
+    if test $shared -eq 1; then
+      echo "Checking for Symbol versioning... Yes."
+      CFLAGS="${CFLAGS} -DHAVE_SYMVER"
+      SFLAGS="${SFLAGS} -DHAVE_SYMVER"
+    else
+      echo "Checking for Symbol versioning... No."
+    fi
+  ;;
+esac
+
 # Simplify some later conditionals
 case "$uname" in
 Linux* | linux*)
@@ -2029,6 +2045,7 @@ EOF
     ;;
 esac
 
+echo "Uname: $uname"
 echo "ARCH: ${ARCH}"
 echo "Using arch directory: ${ARCHDIR}"
 echo "Architecture-specific static object files:${ARCH_STATIC_OBJS}"
index 2f9dd6b1c0c9b1df59a3c0010997b1d9682f7172..bb964d6c0aa4dfd6e5213200133438412d3f8a9f 100644 (file)
--- a/zbuild.h
+++ b/zbuild.h
 #  define Z_INTERNAL
 #endif
 
+/* Symbol versioning helpers, allowing multiple versions of a function to exist.
+ * Functions using this must also be added to zlib-ng.map for each version.
+ * Double @@ means this is the default for newly compiled applications to link against.
+ * Single @ means this is kept for backwards compatibility.
+ * This is only used for Zlib-ng native API, and only on platforms supporting this.
+ */
+#if defined(HAVE_SYMVER)
+#  define ZSYMVER(func,alias,ver) __asm__(".symver " func ", " alias "@ZLIB_NG_" ver);
+#  define ZSYMVER_DEF(func,alias,ver) __asm__(".symver " func ", " alias "@@ZLIB_NG_" ver);
+#else
+#  define ZSYMVER(func,alias,ver)
+#  define ZSYMVER_DEF(func,alias,ver)
+#endif
+
 #ifndef __cplusplus
 #  define Z_REGISTER register
 #else