]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
Build: Let the users override the symbol versioning variant.
authorSergey Kosukhin <sergey.kosukhin@mpimet.mpg.de>
Tue, 12 Mar 2024 19:03:49 +0000 (20:03 +0100)
committerLasse Collin <lasse.collin@tukaani.org>
Tue, 21 May 2024 21:33:56 +0000 (00:33 +0300)
There are cases when the users want to decide themselves whether
they want to have the generic (even on GNU/Linux) or the linux
(even if we do not recommend that) symbol versioning variant.
The former might be needed to circumvent compiler issues (i.e.
the compiler does not support all features that are required
for the linux versioning), the latter might help in overriding
the assumptions made in the configure script.

(This commit was contributed under 0BSD but the author confirmed
that it is fine to backport it to the public domain branches. See
https://github.com/tukaani-project/xz/pull/90#issuecomment-2100185936
and the next two messages.)

(cherry picked from commit f56ed6fac6619b56b005878d3b5210e2f0d721c0)
(cherry picked from commit ce3a9fa94d6092665c3b000dc0dbe9a2900d4df2)

configure.ac

index e2c040706ee8a5783be74aee4d64706a4aa35885..693157c122afdd887189d23fbe3e09d492b2ceae 100644 (file)
@@ -667,52 +667,61 @@ elif test "x$enable_shared" = xno ; then
        enable_symbol_versions=no
        AC_MSG_RESULT([no (not building a shared library)])
 else
-       case "$host_cpu-$host_os" in
-               microblaze*)
-                       # GCC 12 on MicroBlaze doesn't support __symver__
-                       # attribute. It's simplest and safest to use the
-                       # generic version on that platform since then only
-                       # the linker script is needed. The RHEL/CentOS 7
-                       # compatibility symbols don't matter on MicroBlaze.
-                       enable_symbol_versions=generic
-                       ;;
-               *-linux*)
-                       case "$pic_mode-$enable_static" in
-                               default-*)
-                                       # Use symvers if PIC is defined.
-                                       have_symbol_versions_linux=2
-                                       ;;
-                               *-no)
-                                       # Not building static library.
-                                       # Use symvers unconditionally.
-                                       have_symbol_versions_linux=1
-                                       ;;
-                               *)
-                                       AC_MSG_RESULT([])
-                                       AC_MSG_ERROR([
+       if test "x$enable_symbol_versions" = xyes ; then
+               case "$host_cpu-$host_os" in
+                       microblaze*)
+                               # GCC 12 on MicroBlaze doesn't support __symver__
+                               # attribute. It's simplest and safest to use the
+                               # generic version on that platform since then only
+                               # the linker script is needed. The RHEL/CentOS 7
+                               # compatibility symbols don't matter on MicroBlaze.
+                               enable_symbol_versions=generic
+                               ;;
+                       *-linux*)
+                               enable_symbol_versions=linux
+                               ;;
+                       *)
+                               enable_symbol_versions=generic
+                               ;;
+               esac
+       fi
+
+       if test "x$enable_symbol_versions" = xlinux ; then
+               case "$pic_mode-$enable_static" in
+                       default-*)
+                               # Use symvers if PIC is defined.
+                               have_symbol_versions_linux=2
+                               ;;
+                       *-no)
+                               # Not building static library.
+                               # Use symvers unconditionally.
+                               have_symbol_versions_linux=1
+                               ;;
+                       *)
+                               AC_MSG_RESULT([])
+                               AC_MSG_ERROR([
     On GNU/Linux, building both shared and static library at the same time
     is not supported if --with-pic or --without-pic is used.
     Use either --disable-shared or --disable-static to build one type
     of library at a time. If both types are needed, build one at a time,
     possibly picking only src/liblzma/.libs/liblzma.a from the static build.])
-                                       ;;
-                       esac
-                       enable_symbol_versions=linux
-                       AC_DEFINE_UNQUOTED([HAVE_SYMBOL_VERSIONS_LINUX],
-                               [$have_symbol_versions_linux],
-                               [Define to 1 to if GNU/Linux-specific details
-                               are unconditionally wanted for symbol
-                               versioning. Define to 2 to if these are wanted
-                               only if also PIC is defined (allows building
-                               both shared and static liblzma at the same
-                               time with Libtool if neither --with-pic nor
-                               --without-pic is used). This define must be
-                               used together with liblzma_linux.map.])
-                       ;;
-               *)
-                       enable_symbol_versions=generic
-                       ;;
-       esac
+                               ;;
+               esac
+               AC_DEFINE_UNQUOTED([HAVE_SYMBOL_VERSIONS_LINUX],
+                       [$have_symbol_versions_linux],
+                       [Define to 1 to if GNU/Linux-specific details
+                       are unconditionally wanted for symbol
+                       versioning. Define to 2 to if these are wanted
+                       only if also PIC is defined (allows building
+                       both shared and static liblzma at the same
+                       time with Libtool if neither --with-pic nor
+                       --without-pic is used). This define must be
+                       used together with liblzma_linux.map.])
+       elif test "x$enable_symbol_versions" != xgeneric ; then
+               AC_MSG_RESULT([])
+               AC_MSG_ERROR(
+                       [unknown symbol versioning variant '$enable_symbol_versions'])
+       fi
        AC_MSG_RESULT([yes ($enable_symbol_versions)])
 fi