mirror of
https://git.tukaani.org/xz.git
synced 2025-05-24 07:06:39 +00:00
CMake: With symbol versioning, try to pass --undefined-version to linker
Fixes: https://github.com/tukaani-project/xz/issues/180 Fixes: https://bugs.gentoo.org/956119
This commit is contained in:
parent
377be0ea7a
commit
f023993653
@ -85,6 +85,7 @@ include(CheckSymbolExists)
|
|||||||
include(CheckStructHasMember)
|
include(CheckStructHasMember)
|
||||||
include(CheckCSourceCompiles)
|
include(CheckCSourceCompiles)
|
||||||
include(CheckCCompilerFlag)
|
include(CheckCCompilerFlag)
|
||||||
|
include(CheckLinkerFlag)
|
||||||
include(cmake/tuklib_large_file_support.cmake)
|
include(cmake/tuklib_large_file_support.cmake)
|
||||||
include(cmake/tuklib_integer.cmake)
|
include(cmake/tuklib_integer.cmake)
|
||||||
include(cmake/tuklib_cpucores.cmake)
|
include(cmake/tuklib_cpucores.cmake)
|
||||||
@ -556,6 +557,21 @@ symbol versioning (${SUPPORTED_SYMBOL_VERSIONING_VARIANTS})")
|
|||||||
set(SYMBOL_VERSIONING "generic")
|
set(SYMBOL_VERSIONING "generic")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT SYMBOL_VERSIONING STREQUAL "no")
|
||||||
|
# If features are disabled in liblzma, some symbols may be missing.
|
||||||
|
# LLVM's lld defaults to --no-undefined-version and the build breaks
|
||||||
|
# if not all symbols in the version script exist. That is good for
|
||||||
|
# catching errors like typos, but in our case the downside is too big.
|
||||||
|
# Avoid the problem by using --undefined-version if the linker
|
||||||
|
# supports it.
|
||||||
|
#
|
||||||
|
# GNU ld has had --no-undefined-version for a long time but it's not
|
||||||
|
# the default. The opposite option --undefined-version was only added
|
||||||
|
# in 2022, thus we must use --undefined-version conditionally.
|
||||||
|
check_linker_flag(C "-Wl,--undefined-version"
|
||||||
|
HAVE_LINKER_FLAG_UNDEFINED_VERSION)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(LIBLZMA_API_HEADERS
|
set(LIBLZMA_API_HEADERS
|
||||||
@ -1480,6 +1496,9 @@ elseif(BUILD_SHARED_LIBS AND SYMBOL_VERSIONING STREQUAL "linux")
|
|||||||
# NOTE: Set it explicitly to 1 to make it clear that versioning is
|
# NOTE: Set it explicitly to 1 to make it clear that versioning is
|
||||||
# done unconditionally in the C files.
|
# done unconditionally in the C files.
|
||||||
target_compile_definitions(liblzma PRIVATE HAVE_SYMBOL_VERSIONS_LINUX=1)
|
target_compile_definitions(liblzma PRIVATE HAVE_SYMBOL_VERSIONS_LINUX=1)
|
||||||
|
if(HAVE_LINKER_FLAG_UNDEFINED_VERSION)
|
||||||
|
target_link_options(liblzma PRIVATE "-Wl,--undefined-version")
|
||||||
|
endif()
|
||||||
target_link_options(liblzma PRIVATE
|
target_link_options(liblzma PRIVATE
|
||||||
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma_linux.map"
|
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma_linux.map"
|
||||||
)
|
)
|
||||||
@ -1487,6 +1506,9 @@ elseif(BUILD_SHARED_LIBS AND SYMBOL_VERSIONING STREQUAL "linux")
|
|||||||
LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma_linux.map"
|
LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma_linux.map"
|
||||||
)
|
)
|
||||||
elseif(BUILD_SHARED_LIBS AND SYMBOL_VERSIONING STREQUAL "generic")
|
elseif(BUILD_SHARED_LIBS AND SYMBOL_VERSIONING STREQUAL "generic")
|
||||||
|
if(HAVE_LINKER_FLAG_UNDEFINED_VERSION)
|
||||||
|
target_link_options(liblzma PRIVATE "-Wl,--undefined-version")
|
||||||
|
endif()
|
||||||
target_link_options(liblzma PRIVATE
|
target_link_options(liblzma PRIVATE
|
||||||
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma_generic.map"
|
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/liblzma/liblzma_generic.map"
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user