From a17f6eff4382a9461b412897709e86a58a29c920 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 30 Jan 2020 09:41:51 -0500 Subject: [PATCH] AIX: Restore pre-3.16 undocumented method to suppress exports with XL In commit 0f150b69d3 (AIX: Explicitly compute shared object exports for both XL and GNU, 2019-07-11, v3.16.0-rc1~418^2~2) we dropped use of the old `CMAKE_XL_CreateExportList` cache entry for XL exports. However, some people were setting the value to an empty string as a way to disable automatic export of symbols. Restore this behavior when the option is explicitly set to an empty string. Issue: #20290 --- Modules/Platform/AIX-XL.cmake | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Modules/Platform/AIX-XL.cmake b/Modules/Platform/AIX-XL.cmake index 64b0bc196c..2a67c4fedb 100644 --- a/Modules/Platform/AIX-XL.cmake +++ b/Modules/Platform/AIX-XL.cmake @@ -18,14 +18,24 @@ macro(__aix_compiler_xl lang) set(CMAKE_${lang}_LINK_FLAGS "-Wl,-bnoipath") + set(_OBJECTS " ") + if(DEFINED CMAKE_XL_CreateExportList AND CMAKE_XL_CreateExportList STREQUAL "") + # Prior to CMake 3.16, CMAKE_XL_CreateExportList held the path to the XL CreateExportList tool. + # Users could set it to an empty value to skip automatic exports in favor of manual -bE: flags. + # Preserve that behavior for compatibility (even though it was undocumented). + set(_OBJECTS "") + endif() + # Construct the export list ourselves to pass only the object files so # that we export only the symbols actually provided by the sources. set(CMAKE_${lang}_CREATE_SHARED_LIBRARY - "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o /objects.exp " + "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o /objects.exp${_OBJECTS}" " -Wl,-bE:/objects.exp -o " ) set(CMAKE_${lang}_LINK_EXECUTABLE_WITH_EXPORTS "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o -l . " " -Wl,-bE: -o ") + + unset(_OBJECTS) endmacro()