From e1f0518de09a54065459a728993563d84fb85a6a Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 12 Jan 2018 11:25:19 -0500 Subject: GNU: Use -fvisibility on AIX when supported Revise the logic from commit v3.7.0-rc1~173^2~2 (GNU: Do not use -fvisibility on AIX or HP-UX, 2016-09-03) to add a version check. The GCC 7 release notes [1] state that visibility support has been added for AIX 7.1 and above. [1] https://gcc.gnu.org/gcc-7/changes.html --- Modules/Platform/AIX-GNU.cmake | 4 +++- Tests/RunCMake/GenerateExportHeader/GEH.cmake | 11 ++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Modules/Platform/AIX-GNU.cmake b/Modules/Platform/AIX-GNU.cmake index 7f08c4a..0abbb61 100644 --- a/Modules/Platform/AIX-GNU.cmake +++ b/Modules/Platform/AIX-GNU.cmake @@ -24,5 +24,7 @@ macro(__aix_compiler_gnu lang) set(CMAKE_${lang}_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH 1) set(CMAKE_${lang}_LINK_FLAGS "-Wl,-bnoipath") - unset(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY) + if(CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 7 OR CMAKE_SYSTEM_VERSION VERSION_LESS 7.1) + unset(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY) + endif() endmacro() diff --git a/Tests/RunCMake/GenerateExportHeader/GEH.cmake b/Tests/RunCMake/GenerateExportHeader/GEH.cmake index cfca8fe..cf81f36 100644 --- a/Tests/RunCMake/GenerateExportHeader/GEH.cmake +++ b/Tests/RunCMake/GenerateExportHeader/GEH.cmake @@ -53,7 +53,16 @@ endif() add_subdirectory(lib_shared_and_static) -add_compiler_export_flags() +if(CMAKE_SYSTEM_NAME MATCHES "AIX" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU" + AND CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY) + # With GNU 7 on AIX, passing -fvisibility=hidden when driving the + # linker for a shared library drops the so init/destruct symbols. + # Just use the modern approach instead of testing the macro. + set(CMAKE_CXX_VISIBILITY_PRESET hidden) + set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) +else() + add_compiler_export_flags() +endif() set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR}) -- cgit v0.12