From 3007094fb83e385ab5e9ade08a835ec0d6cfc7b3 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 30 Apr 2021 01:48:01 +0300 Subject: [PATCH] Use -Wl,-z,ignore on illumos. --- CMake/TdSetUpCompiler.cmake | 9 +++------ CMake/illumos.cmake | 15 +++++++-------- tdutils/CMakeLists.txt | 2 +- test/CMakeLists.txt | 2 +- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/CMake/TdSetUpCompiler.cmake b/CMake/TdSetUpCompiler.cmake index 73f74cbdb..148415f9c 100644 --- a/CMake/TdSetUpCompiler.cmake +++ b/CMake/TdSetUpCompiler.cmake @@ -42,11 +42,6 @@ function(td_set_up_compiler) message(FATAL_ERROR "No C++14 support in the compiler. Please upgrade the compiler.") endif() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - if (MSVC) if (CMAKE_CXX_FLAGS_DEBUG MATCHES "/RTC1") string(REPLACE "/RTC1" " " CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") @@ -60,7 +55,9 @@ function(td_set_up_compiler) else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections") - if (NOT ILLUMOS) + if (ILLUMOS) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,ignore") + else() set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections -Wl,--exclude-libs,ALL") endif() endif() diff --git a/CMake/illumos.cmake b/CMake/illumos.cmake index b0b561743..70583d1a8 100644 --- a/CMake/illumos.cmake +++ b/CMake/illumos.cmake @@ -1,11 +1,10 @@ if (CMAKE_SYSTEM_NAME STREQUAL "SunOS") - # - # Determine if the host is running an illumos distribution: - # - execute_process(COMMAND /usr/bin/uname -o OUTPUT_VARIABLE UNAME_O - OUTPUT_STRIP_TRAILING_WHITESPACE) + # + # Determine if the host is running an illumos distribution: + # + execute_process(COMMAND /usr/bin/uname -o OUTPUT_VARIABLE UNAME_O OUTPUT_STRIP_TRAILING_WHITESPACE) - if (UNAME_O STREQUAL "illumos") - set(ILLUMOS 1) - endif() + if (UNAME_O STREQUAL "illumos") + set(ILLUMOS 1) + endif() endif() diff --git a/tdutils/CMakeLists.txt b/tdutils/CMakeLists.txt index 7fe0d9340..71a760b4e 100644 --- a/tdutils/CMakeLists.txt +++ b/tdutils/CMakeLists.txt @@ -360,7 +360,7 @@ if (ANDROID) target_link_libraries(tdutils PRIVATE log) endif() -if (CMAKE_HOST_SYSTEM_NAME MATCHES "NetBSD") +if (CMAKE_SYSTEM_NAME MATCHES "NetBSD") target_link_libraries(tdutils PUBLIC /usr/pkg/gcc5/i486--netbsdelf/lib/libatomic.so) endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ed1893fd3..239eb5d99 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -49,7 +49,7 @@ if (NOT CMAKE_CROSSCOMPILING OR EMSCRIPTEN) add_executable(test-tdutils EXCLUDE_FROM_ALL ${TESTS_MAIN} ${TDUTILS_TEST_SOURCE}) add_executable(test-online EXCLUDE_FROM_ALL online.cpp) add_executable(run_all_tests ${TESTS_MAIN} ${TD_TEST_SOURCE}) - if (CLANG AND NOT CYGWIN AND NOT EMSCRIPTEN AND NOT (CMAKE_HOST_SYSTEM_NAME MATCHES "OpenBSD") AND NOT (CMAKE_SIZEOF_VOID_P EQUAL 4)) + if (CLANG AND NOT CYGWIN AND NOT EMSCRIPTEN AND NOT (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") AND NOT (CMAKE_SIZEOF_VOID_P EQUAL 4)) target_compile_options(test-tdutils PUBLIC -fsanitize=undefined -fno-sanitize=vptr) target_compile_options(run_all_tests PUBLIC -fsanitize=undefined -fno-sanitize=vptr) target_compile_options(test-online PUBLIC -fsanitize=undefined -fno-sanitize=vptr)