Unverified Commit d71027d2 authored by Noir's avatar Noir Committed by GitHub

Merge pull request #1153

Link against libatomic on 32-bit systems
parents 5ccca5da 7810479a
...@@ -35,6 +35,10 @@ is based on [Keep a Changelog](https://keepachangelog.com). ...@@ -35,6 +35,10 @@ is based on [Keep a Changelog](https://keepachangelog.com).
case or do unexpected things in the latter case. The stringification inspector case or do unexpected things in the latter case. The stringification inspector
now matches precisely on pointer types to stop the compiler from doing now matches precisely on pointer types to stop the compiler from doing
implicit conversions in the first place. implicit conversions in the first place.
- Building executables that link to CAF on 32-bit Linux versions using GCC
failed due to undefined references to `__atomic_fetch` symbols. Adding a CMake
dependency for `caf_core` to libatomic gets executables to compile and link as
expected (#1153).
## [0.18.0-rc.1] - 2020-09-09 ## [0.18.0-rc.1] - 2020-09-09
......
...@@ -5,6 +5,7 @@ project(CAF CXX) ...@@ -5,6 +5,7 @@ project(CAF CXX)
include(CMakeDependentOption) # Conditional default values include(CMakeDependentOption) # Conditional default values
include(CMakePackageConfigHelpers) # For creating .cmake files include(CMakePackageConfigHelpers) # For creating .cmake files
include(CheckCXXSourceCompiles) # For checking whether some C++ features work
include(GNUInstallDirs) # Sets default install paths include(GNUInstallDirs) # Sets default install paths
include(GenerateExportHeader) # Auto-generates dllexport macros include(GenerateExportHeader) # Auto-generates dllexport macros
......
...@@ -194,7 +194,26 @@ caf_core_set_default_properties(libcaf_core_obj libcaf_core) ...@@ -194,7 +194,26 @@ caf_core_set_default_properties(libcaf_core_obj libcaf_core)
caf_export_and_install_lib(core) caf_export_and_install_lib(core)
install(FILES "${CMAKE_BINARY_DIR}/caf/detail/build_config.hpp" install(FILES "${CMAKE_BINARY_DIR}/caf/detail/build_config.hpp"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/caf/detail") DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/caf/detail")
# Check whether we need to link against libatomic.
if(NOT CMAKE_CROSSCOMPILING)
set(snippet "#include <cstdint>
#include <atomic>
std::atomic<uint64_t> x;
int main(int, char**) { return static_cast<int>(x.load()); }")
check_cxx_source_compiles("${snippet}" has_64bit_atomic)
if(NOT has_64bit_atomic)
set(required_libs_backup "${CMAKE_REQUIRED_LIBRARIES}")
list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
check_cxx_source_compiles("${snippet}" has_64bit_atomic_with_libatomic)
set(CMAKE_REQUIRED_LIBRARIES "${required_libs_backup}")
if(NOT has_64bit_atomic_with_libatomic)
message(FATAL_ERROR "Unable to compile code with std::atomic<uint64_t>")
endif()
target_link_libraries(libcaf_core INTERFACE atomic)
endif()
endif()
# -- build unit tests ---------------------------------------------------------- # -- build unit tests ----------------------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment