forked from tarantool/tarantool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Investigation of GNU libunwind problems on the aarch64-linux-gnu platform drive us to the conclusion that libunwind-1.2.1 provided by major distribution packages is broken. Not to mention that its test suite fails with SEGFAULTs. Last but not least, some distributions, e.g. CentOS 8 (see tarantool#4611) do not provide a libunwind package. Hence, bundle libunwind: bundling is enabled by default on all platforms, except for macOS — a system package can be used if its version is greater or equal than 1.3.0 (minimal version that does not seem to be broken on aarch64-linux-gnu). * Add new submodule: bump it to current master. * Refactor libunwind package search logic out of compiler.cmake. * Add CMake script for building bundled libunwind. * Add CMake script for extracting version of libunwind. * Re-enable backtrace for all RHEL distributions by default. * Remove libunwind from static build. Needed for tarantool#4002 Closes tarantool#4611 NO_DOC=build system NO_TEST=build system
- Loading branch information
1 parent
dbaf03d
commit 7dc9fe4
Showing
12 changed files
with
298 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## feature/build | ||
|
||
* Added bundling of _GNU libunwind_ to support backtrace feature on | ||
_AARCH64_ architecture and distributives that don't provide _libunwind_ | ||
package. | ||
* Re-enabled backtrace feature for all _RHEL_ distributions by default, except | ||
for _AARCH64_ architecture and ancient _GCC_ versions, which lack compiler | ||
features required for backtrace (gh-4611). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#[========================================================================[.rst: | ||
libunwind_build | ||
-------- | ||
Builds the libunwind library. | ||
Result Variables | ||
^^^^^^^^^^^^^^^^ | ||
``LIBUNWIND_INCLUDE_DIR`` | ||
Include directory needed to use libunwind. | ||
``LIBUNWIND_LIBRARIES`` | ||
Libraries needed to link to libunwind. | ||
Cache Variables | ||
^^^^^^^^^^^^^^^ | ||
``LIBUNWIND_INCLUDE_DIR`` | ||
The directory containing ``libunwind.h``. | ||
``LIBUNWIND_LIBRARIES`` | ||
The paths to the libunwind libraries. | ||
#]========================================================================] | ||
|
||
macro(libunwind_build) | ||
set(LIBUNWIND_SOURCE_DIR ${PROJECT_SOURCE_DIR}/third_party/libunwind) | ||
set(LIBUNWIND_BUILD_DIR ${PROJECT_BINARY_DIR}/build/libunwind) | ||
set(LIBUNWIND_BINARY_DIR ${LIBUNWIND_BUILD_DIR}/work) | ||
set(LIBUNWIND_INSTALL_DIR ${LIBUNWIND_BUILD_DIR}/dest) | ||
|
||
include(ExternalProject) | ||
ExternalProject_Add(bundled-libunwind-project | ||
TMP_DIR ${LIBUNWIND_BUILD_DIR}/tmp | ||
STAMP_DIR ${LIBUNWIND_BUILD_DIR}/stamp | ||
SOURCE_DIR ${LIBUNWIND_SOURCE_DIR} | ||
BINARY_DIR ${LIBUNWIND_BINARY_DIR} | ||
INSTALL_DIR ${LIBUNWIND_INSTALL_DIR} | ||
|
||
DOWNLOAD_COMMAND "" | ||
|
||
CONFIGURE_COMMAND | ||
<SOURCE_DIR>/configure | ||
CC=${CMAKE_C_COMPILER} | ||
CXX=${CMAKE_CXX_COMPILER} | ||
--prefix=<INSTALL_DIR> | ||
# Bundled libraries are linked statically. | ||
--disable-shared | ||
# Ditto. | ||
--enable-static | ||
# See https://github.com/libunwind/libunwind/blob/e07b43c02d5cf1ea060c018fdf2e2ad34b7c7d80/configure.ac#L122-L125. | ||
--disable-coredump | ||
# See https://github.com/libunwind/libunwind/blob/e07b43c02d5cf1ea060c018fdf2e2ad34b7c7d80/configure.ac#L130-L133. | ||
--disable-ptrace | ||
# See https://github.com/libunwind/libunwind/blob/e07b43c02d5cf1ea060c018fdf2e2ad34b7c7d80/configure.ac#L138-L141. | ||
--disable-setjmp | ||
# See https://github.com/libunwind/libunwind/blob/e07b43c02d5cf1ea060c018fdf2e2ad34b7c7d80/configure.ac#L143-L145 | ||
--disable-documentation | ||
# See https://github.com/libunwind/libunwind/blob/e07b43c02d5cf1ea060c018fdf2e2ad34b7c7d80/configure.ac#L147-L149 | ||
--disable-tests | ||
# By default libunwind provides a weak alias to | ||
# `backtrace` function: this can lead to a conflict with | ||
# glibc's `backtrace`, see https://github.com/libunwind/libunwind/blob/e07b43c02d5cf1ea060c018fdf2e2ad34b7c7d80/configure.ac#L151-L153 | ||
--disable-weak-backtrace | ||
# See https://github.com/libunwind/libunwind/blob/e07b43c02d5cf1ea060c018fdf2e2ad34b7c7d80/configure.ac#L155-L157 | ||
--disable-unwind-header | ||
# See https://github.com/libunwind/libunwind/blob/e07b43c02d5cf1ea060c018fdf2e2ad34b7c7d80/configure.ac#L302-L317 | ||
--disable-minidebuginfo | ||
# See https://github.com/libunwind/libunwind/blob/e07b43c02d5cf1ea060c018fdf2e2ad34b7c7d80/configure.ac#L319-L334 | ||
--disable-zlibdebuginfo | ||
|
||
LOG_CONFIGURE TRUE | ||
LOG_BUILD TRUE | ||
LOG_INSTALL TRUE | ||
LOG_MERGED_STDOUTERR TRUE | ||
LOG_OUTPUT_ON_FAILURE TRUE | ||
|
||
EXCLUDE_FROM_ALL) | ||
|
||
add_library(bundled-libunwind STATIC IMPORTED GLOBAL) | ||
set_target_properties(bundled-libunwind PROPERTIES | ||
IMPORTED_LOCATION | ||
${LIBUNWIND_INSTALL_DIR}/lib/libunwind.a) | ||
add_dependencies(bundled-libunwind bundled-libunwind-project) | ||
|
||
add_library(bundled-libunwind-platform STATIC IMPORTED GLOBAL) | ||
set_target_properties(bundled-libunwind-platform PROPERTIES | ||
IMPORTED_LOCATION | ||
${LIBUNWIND_INSTALL_DIR}/lib/libunwind-${CMAKE_SYSTEM_PROCESSOR}.a) | ||
add_dependencies(bundled-libunwind-platform bundled-libunwind-project) | ||
|
||
set(LIBUNWIND_INCLUDE_DIR ${LIBUNWIND_INSTALL_DIR}/include) | ||
set(LIBUNWIND_LIBRARIES | ||
${LIBUNWIND_INSTALL_DIR}/lib/libunwind-${CMAKE_SYSTEM_PROCESSOR}.a | ||
${LIBUNWIND_INSTALL_DIR}/lib/libunwind.a) | ||
|
||
message(STATUS "Using bundled libunwind") | ||
|
||
unset(LIBUNWIND_SOURCE_DIR) | ||
unset(LIBUNWIND_BUILD_DIR) | ||
unset(LIBUNWIND_BINARY_DIR) | ||
unset(LIBUNWIND_INSTALL_DIR) | ||
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#[========================================================================[.rst: | ||
FindLibUnwind | ||
-------- | ||
Finds the libunwind library. | ||
Result Variables | ||
^^^^^^^^^^^^^^^^ | ||
``LIBUNWIND_FOUND`` | ||
True if the system has the libunwind library. | ||
``LIBUNWIND_VERSION`` | ||
The version of the libunwind library which was found. | ||
``LIBUNWIND_INCLUDE_DIR`` | ||
Include directory needed to use libunwind. | ||
``LIBUNWIND_LIBRARIES`` | ||
Libraries needed to link to libunwind. | ||
Cache Variables | ||
^^^^^^^^^^^^^^^ | ||
``LIBUNWIND_INCLUDE_DIR`` | ||
The directory containing ``libunwind.h``. | ||
``LIBUNWIND_LIBRARIES`` | ||
The paths to the libunwind libraries. | ||
#]========================================================================] | ||
|
||
include(FindPackageHandleStandardArgs) | ||
include(GetLibUnwindVersion) | ||
|
||
find_package(PkgConfig QUIET) | ||
pkg_check_modules(PC_LIBUNWIND QUIET libunwind) | ||
|
||
find_path(LIBUNWIND_INCLUDE_DIR libunwind.h ${PC_LIBUNWIND_INCLUDE_DIRS}) | ||
if(LIBUNWIND_INCLUDE_DIR) | ||
include_directories(${LIBUNWIND_INCLUDE_DIR}) | ||
endif() | ||
|
||
if(BUILD_STATIC AND NOT APPLE) | ||
set(LIBUNWIND_LIBRARY_NAME libunwind.a) | ||
else() | ||
# Only a dynamic version of libunwind is available on macOS: also, we | ||
# should link against the umbrella framework `System` — otherwise `ld` will | ||
# complain that it cannot link directly with libunwind.tbd. | ||
set(LIBUNWIND_LIBRARY_NAME System unwind) | ||
endif() | ||
find_library(LIBUNWIND_LIBRARY NAMES ${LIBUNWIND_LIBRARY_NAME} | ||
PATHS ${PC_LIBUNWIND_LIBRARY_DIRS}) | ||
|
||
if(APPLE) | ||
set(LIBUNWIND_LIBRARIES ${LIBUNWIND_LIBRARY}) | ||
else() | ||
if(BUILD_STATIC) | ||
set(LIBUNWIND_PLATFORM_LIBRARY_NAME | ||
"libunwind-${CMAKE_SYSTEM_PROCESSOR}.a") | ||
else() | ||
set(LIBUNWIND_PLATFORM_LIBRARY_NAME | ||
"unwind-${CMAKE_SYSTEM_PROCESSOR}") | ||
endif() | ||
find_library(LIBUNWIND_PLATFORM_LIBRARY ${LIBUNWIND_PLATFORM_LIBRARY_NAME} | ||
${PC_LIBUNWIND_LIBRARY_DIRS}) | ||
set(LIBUNWIND_LIBRARIES ${LIBUNWIND_LIBRARY} ${LIBUNWIND_PLATFORM_LIBRARY}) | ||
endif() | ||
|
||
if(BUILD_STATIC) | ||
# libunwind could have been built with liblzma dependency: | ||
# https://github.com/libunwind/libunwind/blob/4feb1152d1c4aaafbb2d504dbe34c6db5b6fe9f2/configure.ac#L302-L317 | ||
pkg_check_modules(PC_LIBLZMA QUIET liblzma) | ||
find_library(LIBLZMA_LIBRARY liblzma.a ${PC_LIBLZMA_LIBRARY_DIRS}) | ||
if(NOT LIBLZMA_LIBRARY STREQUAL "LIBLZMA_LIBRARY-NOTFOUND") | ||
message(STATUS "liblzma found") | ||
set(LIBUNWIND_LIBRARIES ${LIBUNWIND_LIBRARIES} ${LIBLZMA_LIBRARY}) | ||
endif() | ||
# Ditto, | ||
# https://github.com/libunwind/libunwind/blob/4feb1152d1c4aaafbb2d504dbe34c6db5b6fe9f2/configure.ac#L319-L334 | ||
set(LIBUNWIND_LIBRARIES ${LIBUNWIND_LIBRARIES} ZLIB::ZLIB) | ||
endif() | ||
|
||
if(PC_LIBUNWIND_VERSION) | ||
set(LIBUNWIND_VERSION ${PC_LIBUNWIND_VERSION}) | ||
else() | ||
GetLibUnwindVersion(LIBUNWIND_VERSION) | ||
endif() | ||
|
||
find_package_handle_standard_args(GetLIBUNWINDVersion.cmake | ||
VERSION_VAR LIBUNWIND_VERSION | ||
REQUIRED_VARS LIBUNWIND_INCLUDE_DIR LIBUNWIND_LIBRARIES) | ||
|
||
mark_as_advanced(LIBUNWIND_INCLUDE_DIR LIBUNWIND_LIBRARIES) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
function(GetLibUnwindVersion _LIBUNWIND_VERSION) | ||
set(_LIBUNWIND_VERSION_HEADER "${LIBUNWIND_INCLUDE_DIR}/libunwind-common.h") | ||
if(LIBUNWIND_LIBRARY AND EXISTS ${_LIBUNWIND_VERSION_HEADER}) | ||
file(READ ${_LIBUNWIND_VERSION_HEADER} | ||
_LIBUNWIND_VERSION_HEADER_CONTENTS) | ||
string(REGEX MATCH | ||
"#define UNW_VERSION_MAJOR[ \t]+([0-9]+)\n#define UNW_VERSION_MINOR[ \t]+([0-9]+)" | ||
_VERSION_REGEX "${_LIBUNWIND_VERSION_HEADER_CONTENTS}") | ||
set(${_LIBUNWIND_VERSION} "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}" | ||
PARENT_SCOPE) | ||
endif() | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.