This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake".
The branch, master has been updated via c3d9d800157a8fe2c0478d7e054544b99694c240 (commit) via 76a540bab5f05e4d523ce1b0480b0ee6424c676b (commit) via 84ddeb8fa50cf16c53a48d1ccb92d067ed973d14 (commit) via e29ccfcafb8a57d73bd876e5f83f587396fca246 (commit) via c2c3d22504728e0763c3d0e88333a34d24457fb6 (commit) via 9f5c2040bfd41a2c87624cec3d9504cf477c9fc3 (commit) via 0f150b69d3a01c3c5b4a96d10334eb2703ba237f (commit) via a5bf4e7921e5ac1abbe8fd71a597a8b37e6f08d2 (commit) via 9cb5f040d7bd2a73d6510f2de38ddf03e4e7498a (commit) from 09b4dfb92aab0b13d3df70ff974d4208386d55f0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c3d9d800157a8fe2c0478d7e054544b99694c240 commit c3d9d800157a8fe2c0478d7e054544b99694c240 Merge: 76a540b c2c3d22 Author: Brad King <brad.k...@kitware.com> AuthorDate: Tue Jul 16 14:30:30 2019 +0000 Commit: Kitware Robot <kwro...@kitware.com> CommitDate: Tue Jul 16 10:30:38 2019 -0400 Merge topic 'aix-explicit-exports' c2c3d22504 Tests: Drop RunCMake workaround for AIX ld warnings about GNU atexit 9f5c2040bf AIX: Explicitly compute executable exports for both XL and GNU 0f150b69d3 AIX: Explicitly compute shared object exports for both XL and GNU a5bf4e7921 AIX: Drop redundant -brtl flags 9cb5f040d7 XL: De-duplicate shared object creation flags Acked-by: Kitware Robot <kwro...@kitware.com> Merge-request: !3556 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=76a540bab5f05e4d523ce1b0480b0ee6424c676b commit 76a540bab5f05e4d523ce1b0480b0ee6424c676b Merge: 09b4dfb 84ddeb8 Author: Brad King <brad.k...@kitware.com> AuthorDate: Tue Jul 16 14:28:44 2019 +0000 Commit: Kitware Robot <kwro...@kitware.com> CommitDate: Tue Jul 16 10:28:54 2019 -0400 Merge topic 'doc-ENABLE_EXPORTS' 84ddeb8fa5 Help: Clarify ENABLE_EXPORTS per-platform link behavior e29ccfcafb Help: Simplify CMAKE_ENABLE_EXPORTS documentation Acked-by: Kitware Robot <kwro...@kitware.com> Merge-request: !3560 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=84ddeb8fa50cf16c53a48d1ccb92d067ed973d14 commit 84ddeb8fa50cf16c53a48d1ccb92d067ed973d14 Author: Brad King <brad.k...@kitware.com> AuthorDate: Tue Jul 16 09:56:52 2019 -0400 Commit: Brad King <brad.k...@kitware.com> CommitDate: Tue Jul 16 10:09:40 2019 -0400 Help: Clarify ENABLE_EXPORTS per-platform link behavior Spell out the behavior on each platform in a bullet list. diff --git a/Help/prop_tgt/ENABLE_EXPORTS.rst b/Help/prop_tgt/ENABLE_EXPORTS.rst index 581c2b9..daef78b 100644 --- a/Help/prop_tgt/ENABLE_EXPORTS.rst +++ b/Help/prop_tgt/ENABLE_EXPORTS.rst @@ -7,16 +7,21 @@ Normally an executable does not export any symbols because it is the final program. It is possible for an executable to export symbols to be used by loadable modules. When this property is set to true CMake will allow other targets to "link" to the executable with the -:command:`TARGET_LINK_LIBRARIES` command. On all platforms a target-level +:command:`target_link_libraries` command. On all platforms a target-level dependency on the executable is created for targets that link to it. -For DLL platforms an import library will be created for the exported -symbols and then used for linking. All Windows-based systems -including Cygwin are DLL platforms. For non-DLL platforms that -require all symbols to be resolved at link time, such as macOS, the -module will "link" to the executable using a flag like -``-bundle_loader``. For other non-DLL platforms the link rule is simply -ignored since the dynamic loader will automatically bind symbols when -the module is loaded. +Handling of the executable on the link lines of the loadable modules +varies by platform: + +* On Windows-based systems (including Cygwin) an "import library" is + created along with the executable to list the exported symbols. + Loadable modules link to the import library to get the symbols. + +* On macOS, loadable modules link to the executable itself using the + ``-bundle_loader`` flag. + +* On other platforms, loadable modules are simply linked without + referencing the executable since the dynamic loader will + automatically bind symbols when the module is loaded. This property is initialized by the value of the variable :variable:`CMAKE_ENABLE_EXPORTS` if it is set when a target is created. https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e29ccfcafb8a57d73bd876e5f83f587396fca246 commit e29ccfcafb8a57d73bd876e5f83f587396fca246 Author: Brad King <brad.k...@kitware.com> AuthorDate: Tue Jul 16 09:47:15 2019 -0400 Commit: Brad King <brad.k...@kitware.com> CommitDate: Tue Jul 16 10:09:06 2019 -0400 Help: Simplify CMAKE_ENABLE_EXPORTS documentation In real projects the variable form should rarely be used because the decision to export symbols from an executable is very specific. Remove its main description, which duplicates the `ENABLE_EXPORTS` target property, and simply reference the property instead. diff --git a/Help/variable/CMAKE_ENABLE_EXPORTS.rst b/Help/variable/CMAKE_ENABLE_EXPORTS.rst index 7ec4d63..8848da1 100644 --- a/Help/variable/CMAKE_ENABLE_EXPORTS.rst +++ b/Help/variable/CMAKE_ENABLE_EXPORTS.rst @@ -1,22 +1,8 @@ CMAKE_ENABLE_EXPORTS -------------------- -Specify whether an executable exports symbols for loadable modules. +Specify whether executables export symbols for loadable modules. -Normally an executable does not export any symbols because it is the -final program. It is possible for an executable to export symbols to -be used by loadable modules. When this property is set to true CMake -will allow other targets to ``link`` to the executable with the -:command:`TARGET_LINK_LIBRARIES` command. On all platforms a target-level -dependency on the executable is created for targets that link to it. -For DLL platforms an import library will be created for the exported -symbols and then used for linking. All Windows-based systems -including Cygwin are DLL platforms. For non-DLL platforms that -require all symbols to be resolved at link time, such as macOS, the -module will ``link`` to the executable using a flag like -``-bundle_loader``. For other non-DLL platforms the link rule is simply -ignored since the dynamic loader will automatically bind symbols when -the module is loaded. - -This variable is used to initialize the target property -:prop_tgt:`ENABLE_EXPORTS` for executable targets. +This variable is used to initialize the :prop_tgt:`ENABLE_EXPORTS` target +property for executable targets when they are created by calls to the +:command:`add_executable` command. See the property documentation for details. https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c2c3d22504728e0763c3d0e88333a34d24457fb6 commit c2c3d22504728e0763c3d0e88333a34d24457fb6 Author: Brad King <brad.k...@kitware.com> AuthorDate: Fri Jul 12 16:24:20 2019 -0400 Commit: Brad King <brad.k...@kitware.com> CommitDate: Mon Jul 15 13:27:16 2019 -0400 Tests: Drop RunCMake workaround for AIX ld warnings about GNU atexit Drop the filtering added by commit e22c45d4c9 (Tests: Teach RunCMake to ignore AIX ld warnings about GNU atexit, 2018-02-28, v3.12.0-rc1~419^2~6). It is no longer needed now that we compute our own exports on AIX and do not get these warnings when using shared libraries. diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index e730d6e..568bdf8 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -144,8 +144,6 @@ function(run_cmake test) "|Error kstat returned" "|Hit xcodebuild bug" "|[^\n]*xcodebuild[^\n]*warning: file type[^\n]*is based on missing file type" - "|ld: 0711-224 WARNING: Duplicate symbol: .__init_aix_libgcc_cxa_atexit" - "|ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information" "|[^\n]*is a member of multiple groups" "|[^\n]*from Time Machine by path" "|[^\n]*Bullseye Testing Technology" https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9f5c2040bfd41a2c87624cec3d9504cf477c9fc3 commit 9f5c2040bfd41a2c87624cec3d9504cf477c9fc3 Author: Brad King <brad.k...@kitware.com> AuthorDate: Fri Jul 12 12:55:55 2019 -0400 Commit: Brad King <brad.k...@kitware.com> CommitDate: Mon Jul 15 13:27:16 2019 -0400 AIX: Explicitly compute executable exports for both XL and GNU On AIX, symbols in executables must be exported in order to be visible to modules (plugins) they load via `dlopen`. Prior to policy `CMP0065`, CMake linked all executables with flags to export symbols, but the NEW behavior for that policy is to do so only for executables that have the `ENABLE_EXPORTS` target property set. In both cases, CMake has always used the AIX linker option `-bexpall` option to export symbols from executables. This has worked fairly well with the XL compiler, but with the GNU compiler it works only for C ABI symbols. The reason is that `-bexpall` does not export symbols starting in `_` but the GNU C++ ABI mangles all symbols with a leading `_`. Therefore we have only supported C ABI plugins with the GNU compiler on AIX. Some projects have tried to work around this by replacing `-bexpall` with `-bexpfull`, but the latter often exports symbols that we do not want exported. Avoid using `-bexpall` for executables by instead using by our own internal `ExportImportList` script to compute symbol export lists from the object files to be linked into an executable. Pass the explicitly computed export list to the AIX linker's `-bE:...` option. We already do this for shared object exports. Issue: #19163 diff --git a/Modules/Platform/AIX-GNU.cmake b/Modules/Platform/AIX-GNU.cmake index beb928b..cec71a1 100644 --- a/Modules/Platform/AIX-GNU.cmake +++ b/Modules/Platform/AIX-GNU.cmake @@ -18,7 +18,7 @@ macro(__aix_compiler_gnu lang) set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-blibpath:") set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") string(APPEND CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS " -Wl,-G,-bnoipath") - set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,-bexpall") + set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,-bexpall") # CMP0065 old behavior set(CMAKE_${lang}_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH 1) set(CMAKE_${lang}_LINK_FLAGS "-Wl,-bnoipath") @@ -32,4 +32,8 @@ macro(__aix_compiler_gnu lang) "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <OBJECT_DIR>/objects.exp <OBJECTS>" "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" ) + + set(CMAKE_${lang}_LINK_EXECUTABLE_WITH_EXPORTS + "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <OBJECT_DIR>/objects.exp <OBJECTS>" + "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") endmacro() diff --git a/Modules/Platform/AIX-XL.cmake b/Modules/Platform/AIX-XL.cmake index 569edf7..52292bd 100644 --- a/Modules/Platform/AIX-XL.cmake +++ b/Modules/Platform/AIX-XL.cmake @@ -18,7 +18,7 @@ macro(__aix_compiler_xl lang) set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-blibpath:") set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-G -Wl,-bnoipath") # -shared - set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,-bexpall") + set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,-bexpall") # CMP0065 old behavior set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS " ") set(CMAKE_SHARED_MODULE_${lang}_FLAGS " ") @@ -30,4 +30,8 @@ macro(__aix_compiler_xl lang) "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <OBJECT_DIR>/objects.exp <OBJECTS>" "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" ) + + set(CMAKE_${lang}_LINK_EXECUTABLE_WITH_EXPORTS + "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <OBJECT_DIR>/objects.exp <OBJECTS>" + "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") endmacro() diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c807f6d..a2c0503 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -2754,6 +2754,13 @@ std::string cmGeneratorTarget::GetCreateRuleVariable( case cmStateEnums::MODULE_LIBRARY: return "CMAKE_" + lang + "_CREATE_SHARED_MODULE"; case cmStateEnums::EXECUTABLE: + if (this->IsExecutableWithExports()) { + std::string linkExeWithExports = + "CMAKE_" + lang + "_LINK_EXECUTABLE_WITH_EXPORTS"; + if (this->Makefile->IsDefinitionSet(linkExeWithExports)) { + return linkExeWithExports; + } + } return "CMAKE_" + lang + "_LINK_EXECUTABLE"; default: break; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 0f730c9..4ffd6e0 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1515,8 +1515,10 @@ std::string cmLocalGenerator::GetLinkLibsCMP0065( } CM_FALLTHROUGH; case cmPolicies::OLD: - // OLD behavior is to always add the flags - add_shlib_flags = true; + // OLD behavior is to always add the flags, except on AIX where + // we compute symbol exports if ENABLE_EXPORTS is on. + add_shlib_flags = + !(tgt.Target->IsAIX() && tgt.GetPropertyAsBool("ENABLE_EXPORTS")); break; case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_ALWAYS: @@ -1525,8 +1527,10 @@ std::string cmLocalGenerator::GetLinkLibsCMP0065( cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0065)); CM_FALLTHROUGH; case cmPolicies::NEW: - // NEW behavior is to only add the flags if ENABLE_EXPORTS is on - add_shlib_flags = tgt.GetPropertyAsBool("ENABLE_EXPORTS"); + // NEW behavior is to only add the flags if ENABLE_EXPORTS is on, + // except on AIX where we compute symbol exports. + add_shlib_flags = + !tgt.Target->IsAIX() && tgt.GetPropertyAsBool("ENABLE_EXPORTS"); break; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 773487e..9290d27 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -171,6 +171,7 @@ public: bool IsGeneratorProvided; bool HaveInstallRule; bool IsDLLPlatform; + bool IsAIX; bool IsAndroid; bool IsImportedTarget; bool ImportedGloballyVisible; @@ -219,6 +220,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, impl->IsGeneratorProvided = false; impl->HaveInstallRule = false; impl->IsDLLPlatform = false; + impl->IsAIX = false; impl->IsAndroid = false; impl->IsImportedTarget = (vis == VisibilityImported || vis == VisibilityImportedGlobally); @@ -229,6 +231,10 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, impl->IsDLLPlatform = !impl->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX").empty(); + // Check whether we are targeting AIX. + impl->IsAIX = + (impl->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME") == "AIX"); + // Check whether we are targeting an Android platform. impl->IsAndroid = (impl->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME") == "Android"); @@ -1664,6 +1670,11 @@ bool cmTarget::IsDLLPlatform() const return impl->IsDLLPlatform; } +bool cmTarget::IsAIX() const +{ + return impl->IsAIX; +} + bool cmTarget::IsImported() const { return impl->IsImportedTarget; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d9e87b8..a808bb4 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -180,6 +180,9 @@ public: //! Return whether or not the target is for a DLL platform. bool IsDLLPlatform() const; + //! Return whether or not we are targeting AIX. + bool IsAIX() const; + bool IsImported() const; bool IsImportedGloballyVisible() const; diff --git a/Tests/RunCMake/CMP0065/RunCMakeTest.cmake b/Tests/RunCMake/CMP0065/RunCMakeTest.cmake index 254a4ec..e86b50e 100644 --- a/Tests/RunCMake/CMP0065/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0065/RunCMakeTest.cmake @@ -1,8 +1,11 @@ include(RunCMake) run_cmake(OLDBad1) -run_cmake(OLDBad2) -run_cmake(NEWBad) +if(NOT CMAKE_SYSTEM_NAME STREQUAL "AIX") + # Tests with ENABLE_EXPORTS ON. For AIX we do not use the flags at all. + run_cmake(OLDBad2) + run_cmake(NEWBad) +endif() run_cmake(NEWGood) run_cmake(WARN-OFF) run_cmake(WARN-ON) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 735ad5f..c952b1a 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -120,7 +120,7 @@ add_RunCMake_test(CMP0081) # CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS variable, which both the VS and Xcode # generators ignore. The policy will have no effect on those generators. if(NOT CMAKE_GENERATOR MATCHES "Visual Studio|Xcode") - add_RunCMake_test(CMP0065) + add_RunCMake_test(CMP0065 -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}) endif() if(CMAKE_GENERATOR MATCHES "Make") add_RunCMake_test(Make -DMAKE_IS_GNU=${MAKE_IS_GNU}) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0f150b69d3a01c3c5b4a96d10334eb2703ba237f commit 0f150b69d3a01c3c5b4a96d10334eb2703ba237f Author: Brad King <brad.k...@kitware.com> AuthorDate: Thu Jul 11 20:32:59 2019 -0400 Commit: Brad King <brad.k...@kitware.com> CommitDate: Mon Jul 15 13:27:16 2019 -0400 AIX: Explicitly compute shared object exports for both XL and GNU On AIX, symbols in shared objects must be exported in order to be visible to dependents (similar to Windows). The AIX linker provides a `-bE:...` option to specify a file listing symbols to be exported. Compilers offer some features to help: * When the XL compiler is invoked with its `-qmkshrobj`/`-G` options for creating shared objects (without/with runtime linking), it recognizes when no explicit `-bE:...` linker option is specified and runs a `CreateExportList` tool provided with the compiler to compute one from the object files. Since commit d468a2c2cb (XL: Avoid copying archives into shared libraries that link them, 2011-04-07, v2.8.5~153^2) CMake runs `CreateExportList` explicitly to ensure it only looks at the object files and not any library files. * When the GNU compiler is invoked with its `-shared` option for creating shared objects, its internal `collect2` tool recognizes when no explicit `-bE:...` linker option is specified and computes one itself from the object files. However, it sometimes includes extra symbols such as `.__init_aix_libgcc_cxa_atexit`. Introduce our own internal `ExportImportList` script to compute symbol export lists from object files. Use a basic implementation for now: it can be extended as needed later. Update our shared library creation rules to run the script explicitly for both the XL and GNU compilers. Issue: #19163 diff --git a/Modules/Platform/AIX-GNU.cmake b/Modules/Platform/AIX-GNU.cmake index c3b7922..beb928b 100644 --- a/Modules/Platform/AIX-GNU.cmake +++ b/Modules/Platform/AIX-GNU.cmake @@ -25,4 +25,11 @@ macro(__aix_compiler_gnu lang) if(CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 7 OR CMAKE_SYSTEM_VERSION VERSION_LESS 7.1) unset(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY) 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 <OBJECT_DIR>/objects.exp <OBJECTS>" + "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" + ) endmacro() diff --git a/Modules/Platform/AIX-XL.cmake b/Modules/Platform/AIX-XL.cmake index 0933a78..569edf7 100644 --- a/Modules/Platform/AIX-XL.cmake +++ b/Modules/Platform/AIX-XL.cmake @@ -24,25 +24,10 @@ macro(__aix_compiler_xl lang) set(CMAKE_${lang}_LINK_FLAGS "-Wl,-bnoipath") - # Find the CreateExportList program that comes with this toolchain. - find_program(CMAKE_XL_CreateExportList - NAMES CreateExportList - DOC "IBM XL CreateExportList tool" + # 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 <OBJECT_DIR>/objects.exp <OBJECTS>" + "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" ) - - # CMAKE_XL_CreateExportList is part of the AIX XL compilers but not the linux ones. - # If we found the tool, we'll use it to create exports, otherwise stick with the regular - # create shared library compile line. - if (CMAKE_XL_CreateExportList) - # The compiler front-end passes all object files, archive files, and shared - # library files named on the command line to CreateExportList to create a - # list of all symbols to be exported from the shared library. This causes - # all archive members to be copied into the shared library whether they are - # needed or not. Instead we run the tool 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_XL_CreateExportList} <OBJECT_DIR>/objects.exp <OBJECTS>" - "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" - ) - endif() endmacro() diff --git a/Modules/Platform/AIX/ExportImportList b/Modules/Platform/AIX/ExportImportList new file mode 100755 index 0000000..c17378c --- /dev/null +++ b/Modules/Platform/AIX/ExportImportList @@ -0,0 +1,48 @@ +#!/bin/sh +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# This script is internal to CMake and meant only to be +# invoked by CMake-generated build systems on AIX. + +usage='usage: ExportImportList -o <out-file> [--] <objects>...' + +die() { + echo "$@" 1>&2; exit 1 +} + +# Process command-line arguments. +out='' +while test "$#" != 0; do + case "$1" in + -o) shift; out="$1" ;; + --) shift; break ;; + -*) die "$usage" ;; + *) break ;; + esac + shift +done +test -n "$out" || die "$usage" + +# Collect symbols exported from all object files. +out_tmp="$out.tmp$$" +trap 'rm -f "$out_tmp"' EXIT INT TERM +for f in "$@"; do + dump -tov -X 32_64 "$f" | + awk ' + BEGIN { + V["EXPORTED"]=" export" + V["PROTECTED"]=" protected" + } + /^\[[0-9]+\]\tm +[^ ]+ +\.(text|data|bss) +[^ ]+ +(extern|weak) +(EXPORTED|PROTECTED| ) / { + if (!match($NF,/^(\.|__sinit|__sterm|__[0-9]+__)/)) { + print $NF V[$(NF-1)] + } + } + ' +done > "$out_tmp" + +# Generate the export/import file. +{ + sort -u "$out_tmp" +} > "$out" https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a5bf4e7921e5ac1abbe8fd71a597a8b37e6f08d2 commit a5bf4e7921e5ac1abbe8fd71a597a8b37e6f08d2 Author: Brad King <brad.k...@kitware.com> AuthorDate: Fri Jul 12 09:08:28 2019 -0400 Commit: Brad King <brad.k...@kitware.com> CommitDate: Mon Jul 15 13:26:56 2019 -0400 AIX: Drop redundant -brtl flags We removed `-brtl` in commit bce7a2a3a5 (AIX: Do not use -brtl to create shared libraries, 2013-03-11, v2.8.11~103^2~1) but it was added again by commit f254276fc1 (AIX,HP-UX: Fix RPATH handling when CMP0065 is set to NEW, 2015-12-11, v3.4.2~4^2). Since the latter commit we initialize the `CMAKE_{SHARED,MODULE}_LINKER_FLAGS` to use the `-brtl` linker flag. This is unnecessary because we already use the `-G` linker flag which implies `-brtl`. The latter commit also moved `-brtl` to `CMAKE_EXE_LINKER_FLAGS` from flags that were always included in executable link lines with CMP0065 OLD behavior and are not part of the change intended by CMP0065. Leave this for now as we've always enabled runtime linking for executables (and implicitly done so via -G for shared libraries and modules). Issue: #13997 Issue: #19163 diff --git a/Modules/Platform/AIX-GNU.cmake b/Modules/Platform/AIX-GNU.cmake index 0abbb61..c3b7922 100644 --- a/Modules/Platform/AIX-GNU.cmake +++ b/Modules/Platform/AIX-GNU.cmake @@ -11,8 +11,6 @@ set(__AIX_COMPILER_GNU 1) # # By default, runtime linking is enabled. All shared objects specified on the command line # will be listed, even if there are no symbols referenced, in the output file. -string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " -Wl,-brtl") -string(APPEND CMAKE_MODULE_LINKER_FLAGS_INIT " -Wl,-brtl") string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " -Wl,-brtl") diff --git a/Modules/Platform/AIX-XL.cmake b/Modules/Platform/AIX-XL.cmake index 06a806b..0933a78 100644 --- a/Modules/Platform/AIX-XL.cmake +++ b/Modules/Platform/AIX-XL.cmake @@ -11,8 +11,6 @@ set(__AIX_COMPILER_XL 1) # # By default, runtime linking is enabled. All shared objects specified on the command line # will be listed, even if there are no symbols referenced, in the output file. -string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " -Wl,-brtl") -string(APPEND CMAKE_MODULE_LINKER_FLAGS_INIT " -Wl,-brtl") string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " -Wl,-brtl") https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9cb5f040d7bd2a73d6510f2de38ddf03e4e7498a commit 9cb5f040d7bd2a73d6510f2de38ddf03e4e7498a Author: Brad King <brad.k...@kitware.com> AuthorDate: Fri Jul 12 08:52:41 2019 -0400 Commit: Brad King <brad.k...@kitware.com> CommitDate: Mon Jul 15 07:45:04 2019 -0400 XL: De-duplicate shared object creation flags The XL `-qmkshrobj` flag creates shared objects on all platforms. Move the flag out of the per-platform modules into the per-compiler module for XL. diff --git a/Modules/Compiler/XL.cmake b/Modules/Compiler/XL.cmake index a9cec11..fc71ab4 100644 --- a/Modules/Compiler/XL.cmake +++ b/Modules/Compiler/XL.cmake @@ -18,6 +18,8 @@ macro(__compiler_xl lang) set(CMAKE_${lang}_RESPONSE_FILE_FLAG "-qoptfile=") set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-qoptfile=") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-qmkshrobj") + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,") set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",") diff --git a/Modules/Platform/Apple-XL-C.cmake b/Modules/Platform/Apple-XL-C.cmake index 2aeb132..e4fc3dd 100644 --- a/Modules/Platform/Apple-XL-C.cmake +++ b/Modules/Platform/Apple-XL-C.cmake @@ -1,4 +1,3 @@ -set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-qmkshrobj") set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle") # Enable shared library versioning. diff --git a/Modules/Platform/Apple-XL-CXX.cmake b/Modules/Platform/Apple-XL-CXX.cmake index f8e1906..ea330c8 100644 --- a/Modules/Platform/Apple-XL-CXX.cmake +++ b/Modules/Platform/Apple-XL-CXX.cmake @@ -1,4 +1,3 @@ -set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-qmkshrobj") set(CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS "-bundle") # Enable shared library versioning. diff --git a/Modules/Platform/Linux-XL-C.cmake b/Modules/Platform/Linux-XL-C.cmake index d595e44..ef0c52b 100644 --- a/Modules/Platform/Linux-XL-C.cmake +++ b/Modules/Platform/Linux-XL-C.cmake @@ -1,2 +1 @@ -set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-qmkshrobj") set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,-export-dynamic") diff --git a/Modules/Platform/Linux-XL-CXX.cmake b/Modules/Platform/Linux-XL-CXX.cmake index 5ceb255..aa57d6e 100644 --- a/Modules/Platform/Linux-XL-CXX.cmake +++ b/Modules/Platform/Linux-XL-CXX.cmake @@ -1,2 +1 @@ -set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-qmkshrobj") set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "-Wl,-export-dynamic") diff --git a/Modules/Platform/Linux-XL-Fortran.cmake b/Modules/Platform/Linux-XL-Fortran.cmake index a878991..d9b4c2d 100644 --- a/Modules/Platform/Linux-XL-Fortran.cmake +++ b/Modules/Platform/Linux-XL-Fortran.cmake @@ -1,2 +1 @@ -set(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "-qmkshrobj") set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "-Wl,-export-dynamic") ----------------------------------------------------------------------- Summary of changes: Help/prop_tgt/ENABLE_EXPORTS.rst | 23 +++++++++------ Help/variable/CMAKE_ENABLE_EXPORTS.rst | 22 +++----------- Modules/Compiler/XL.cmake | 2 ++ Modules/Platform/AIX-GNU.cmake | 15 ++++++++-- Modules/Platform/AIX-XL.cmake | 31 ++++++-------------- Modules/Platform/AIX/ExportImportList | 48 +++++++++++++++++++++++++++++++ Modules/Platform/Apple-XL-C.cmake | 1 - Modules/Platform/Apple-XL-CXX.cmake | 1 - Modules/Platform/Linux-XL-C.cmake | 1 - Modules/Platform/Linux-XL-CXX.cmake | 1 - Modules/Platform/Linux-XL-Fortran.cmake | 1 - Source/cmGeneratorTarget.cxx | 7 +++++ Source/cmLocalGenerator.cxx | 12 +++++--- Source/cmTarget.cxx | 11 +++++++ Source/cmTarget.h | 3 ++ Tests/RunCMake/CMP0065/RunCMakeTest.cmake | 7 +++-- Tests/RunCMake/CMakeLists.txt | 2 +- Tests/RunCMake/RunCMake.cmake | 2 -- 18 files changed, 124 insertions(+), 66 deletions(-) create mode 100755 Modules/Platform/AIX/ExportImportList hooks/post-receive -- CMake _______________________________________________ Cmake-commits mailing list Cmake-commits@cmake.org https://cmake.org/mailman/listinfo/cmake-commits