From 0dcfb63cb9793311b4b7ae3a395e0a273ec824b2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 30 Jan 2020 10:06:11 -0500 Subject: [PATCH 1/4] AIX: Revise ExportImportList to build output more incrementally This will allow more steps to be added. --- Modules/Platform/AIX/ExportImportList | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Modules/Platform/AIX/ExportImportList b/Modules/Platform/AIX/ExportImportList index 4f67ef546e..c7f60b5266 100755 --- a/Modules/Platform/AIX/ExportImportList +++ b/Modules/Platform/AIX/ExportImportList @@ -26,9 +26,12 @@ while test "$#" != 0; do done test -n "$out" || die "$usage" -# Collect symbols exported from all object files. +# Build a temporary file that atomically replaces the output later. out_tmp="$out.tmp$$" trap 'rm -f "$out_tmp"' EXIT INT TERM +> "$out_tmp" + +# Collect symbols exported from all object files. for f in "$@"; do dump -tov -X 32_64 "$f" | awk ' @@ -42,7 +45,7 @@ for f in "$@"; do } } ' -done > "$out_tmp" +done >> "$out_tmp" # Generate the export/import file. { From 0ffd54f0947967166fbaf2b92743fb40df96f0b3 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 30 Jan 2020 10:22:56 -0500 Subject: [PATCH 2/4] AIX: Add ExportImportList option to skip the object files --- Modules/Platform/AIX/ExportImportList | 32 +++++++++++++++------------ 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/Modules/Platform/AIX/ExportImportList b/Modules/Platform/AIX/ExportImportList index c7f60b5266..891bce76d9 100755 --- a/Modules/Platform/AIX/ExportImportList +++ b/Modules/Platform/AIX/ExportImportList @@ -5,7 +5,7 @@ # This script is internal to CMake and meant only to be # invoked by CMake-generated build systems on AIX. -usage='usage: ExportImportList -o [-l ] [--] ...' +usage='usage: ExportImportList -o [-l ] [-n] [--] ...' die() { echo "$@" 1>&2; exit 1 @@ -14,10 +14,12 @@ die() { # Process command-line arguments. out='' lib='' +no_objects='' while test "$#" != 0; do case "$1" in -l) shift; lib="$1" ;; -o) shift; out="$1" ;; + -n) no_objects='1' ;; --) shift; break ;; -*) die "$usage" ;; *) break ;; @@ -32,20 +34,22 @@ trap 'rm -f "$out_tmp"' EXIT INT TERM > "$out_tmp" # Collect symbols exported from all object files. -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)] +if test -z "$no_objects"; then + for f in "$@"; do + dump -tov -X 32_64 "$f" | + awk ' + BEGIN { + V["EXPORTED"]=" export" + V["PROTECTED"]=" protected" } - } - ' -done >> "$out_tmp" + /^\[[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" +fi # Generate the export/import file. { From 67f30811ce6b70717c36951650d9e62b16a14260 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 29 Jan 2020 14:49:57 -0500 Subject: [PATCH 3/4] AIX: Improve name of internal symbol export list file --- Modules/Platform/AIX-GNU.cmake | 4 ++-- Modules/Platform/AIX-XL.cmake | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/Platform/AIX-GNU.cmake b/Modules/Platform/AIX-GNU.cmake index 61d213ae49..42e5e364e3 100644 --- a/Modules/Platform/AIX-GNU.cmake +++ b/Modules/Platform/AIX-GNU.cmake @@ -23,8 +23,8 @@ macro(__aix_compiler_gnu lang) # 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 " - " -Wl,-bE:/objects.exp -o " + "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o /exports.exp " + " -Wl,-bE:/exports.exp -o " ) set(CMAKE_${lang}_LINK_EXECUTABLE_WITH_EXPORTS diff --git a/Modules/Platform/AIX-XL.cmake b/Modules/Platform/AIX-XL.cmake index 2a67c4fedb..edaedb4c67 100644 --- a/Modules/Platform/AIX-XL.cmake +++ b/Modules/Platform/AIX-XL.cmake @@ -29,8 +29,8 @@ macro(__aix_compiler_xl lang) # 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${_OBJECTS}" - " -Wl,-bE:/objects.exp -o " + "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o /exports.exp${_OBJECTS}" + " -Wl,-bE:/exports.exp -o " ) set(CMAKE_${lang}_LINK_EXECUTABLE_WITH_EXPORTS From afcd9fe66943259ea9521ff77b32673e0cdf70b2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 30 Jan 2020 09:10:58 -0500 Subject: [PATCH 4/4] AIX: Add an option to disable automatic exports from shared libraries Since commit 0f150b69d3 (AIX: Explicitly compute shared object exports for both XL and GNU, 2019-07-11, v3.16.0-rc1~418^2~2) we always export all symbols from shared libraries by default. Add a new target property called `AIX_EXPORT_ALL_SYMBOLS` that can be explicitly set to OFF to suppress this behavior and export no symbols by default. Fixes: #20290 --- Help/manual/cmake-properties.7.rst | 1 + Help/manual/cmake-variables.7.rst | 1 + Help/prop_tgt/AIX_EXPORT_ALL_SYMBOLS.rst | 12 ++++++++++++ Help/release/dev/aix-no-export-all.rst | 7 +++++++ Help/variable/CMAKE_AIX_EXPORT_ALL_SYMBOLS.rst | 6 ++++++ Modules/Platform/AIX-GNU.cmake | 4 ++-- Modules/Platform/AIX-XL.cmake | 4 ++-- Source/cmCommonTargetGenerator.cxx | 15 +++++++++++++++ Source/cmCommonTargetGenerator.h | 1 + Source/cmMakefileExecutableTargetGenerator.cxx | 3 +++ Source/cmMakefileLibraryTargetGenerator.cxx | 3 +++ Source/cmNinjaNormalTargetGenerator.cxx | 2 ++ Source/cmRulePlaceholderExpander.cxx | 5 +++++ Source/cmRulePlaceholderExpander.h | 1 + Source/cmTarget.cxx | 1 + .../AIXExportExplicit-build-result.txt | 1 + .../AIXExportExplicit-build-stdout.txt | 1 + .../AutoExportDll/AIXExportExplicit.cmake | 7 +++++++ .../RunCMake/AutoExportDll/AIXExportExplicitLib.c | 8 ++++++++ .../AutoExportDll/AIXExportExplicitLib.exp | 1 + .../AutoExportDll/AIXExportExplicitMain.c | 7 +++++++ Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake | 11 +++++++++++ Tests/RunCMake/CMakeLists.txt | 5 ++++- 23 files changed, 102 insertions(+), 5 deletions(-) create mode 100644 Help/prop_tgt/AIX_EXPORT_ALL_SYMBOLS.rst create mode 100644 Help/release/dev/aix-no-export-all.rst create mode 100644 Help/variable/CMAKE_AIX_EXPORT_ALL_SYMBOLS.rst create mode 100644 Tests/RunCMake/AutoExportDll/AIXExportExplicit-build-result.txt create mode 100644 Tests/RunCMake/AutoExportDll/AIXExportExplicit-build-stdout.txt create mode 100644 Tests/RunCMake/AutoExportDll/AIXExportExplicit.cmake create mode 100644 Tests/RunCMake/AutoExportDll/AIXExportExplicitLib.c create mode 100644 Tests/RunCMake/AutoExportDll/AIXExportExplicitLib.exp create mode 100644 Tests/RunCMake/AutoExportDll/AIXExportExplicitMain.c diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index bcf21a55de..fb84378b0c 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -104,6 +104,7 @@ Properties on Targets :maxdepth: 1 /prop_tgt/ADDITIONAL_CLEAN_FILES + /prop_tgt/AIX_EXPORT_ALL_SYMBOLS /prop_tgt/ALIASED_TARGET /prop_tgt/ANDROID_ANT_ADDITIONAL_OPTIONS /prop_tgt/ANDROID_API diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 1bcd9bd4fa..5697574bd2 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -323,6 +323,7 @@ Variables that Control the Build .. toctree:: :maxdepth: 1 + /variable/CMAKE_AIX_EXPORT_ALL_SYMBOLS /variable/CMAKE_ANDROID_ANT_ADDITIONAL_OPTIONS /variable/CMAKE_ANDROID_API /variable/CMAKE_ANDROID_API_MIN diff --git a/Help/prop_tgt/AIX_EXPORT_ALL_SYMBOLS.rst b/Help/prop_tgt/AIX_EXPORT_ALL_SYMBOLS.rst new file mode 100644 index 0000000000..15ddc0b2d9 --- /dev/null +++ b/Help/prop_tgt/AIX_EXPORT_ALL_SYMBOLS.rst @@ -0,0 +1,12 @@ +AIX_EXPORT_ALL_SYMBOLS +---------------------- + +On AIX, CMake automatically exports all symbols from shared libraries, and +from executables with the :prop_tgt:`ENABLE_EXPORTS` target property set. +Explicitly disable this boolean property to suppress the behavior and +export no symbols by default. In this case it is expected that the project +will use other means to export some symbols. + +This property is initialized by the value of +the :variable:`CMAKE_AIX_EXPORT_ALL_SYMBOLS` variable if it is set +when a target is created. diff --git a/Help/release/dev/aix-no-export-all.rst b/Help/release/dev/aix-no-export-all.rst new file mode 100644 index 0000000000..fa9ed8d0fe --- /dev/null +++ b/Help/release/dev/aix-no-export-all.rst @@ -0,0 +1,7 @@ +aix-no-export-all +----------------- + +* The :prop_tgt:`AIX_EXPORT_ALL_SYMBOLS` target property and associated + :variable:`CMAKE_AIX_EXPORT_ALL_SYMBOLS` variable were created to + optionally explicitly disbale automatic export of symbols from shared + libraries on AIX. diff --git a/Help/variable/CMAKE_AIX_EXPORT_ALL_SYMBOLS.rst b/Help/variable/CMAKE_AIX_EXPORT_ALL_SYMBOLS.rst new file mode 100644 index 0000000000..c64dd4892f --- /dev/null +++ b/Help/variable/CMAKE_AIX_EXPORT_ALL_SYMBOLS.rst @@ -0,0 +1,6 @@ +CMAKE_AIX_EXPORT_ALL_SYMBOLS +---------------------------- + +Default value for :prop_tgt:`AIX_EXPORT_ALL_SYMBOLS` target property. +This variable is used to initialize the property on each target as it is +created. diff --git a/Modules/Platform/AIX-GNU.cmake b/Modules/Platform/AIX-GNU.cmake index 42e5e364e3..5a532c7ccb 100644 --- a/Modules/Platform/AIX-GNU.cmake +++ b/Modules/Platform/AIX-GNU.cmake @@ -23,11 +23,11 @@ macro(__aix_compiler_gnu lang) # 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 /exports.exp " + "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o /exports.exp " " -Wl,-bE:/exports.exp -o " ) set(CMAKE_${lang}_LINK_EXECUTABLE_WITH_EXPORTS - "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o -l . " + "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o -l . " " -Wl,-bE: -o ") endmacro() diff --git a/Modules/Platform/AIX-XL.cmake b/Modules/Platform/AIX-XL.cmake index edaedb4c67..2a8c159afb 100644 --- a/Modules/Platform/AIX-XL.cmake +++ b/Modules/Platform/AIX-XL.cmake @@ -29,12 +29,12 @@ macro(__aix_compiler_xl lang) # 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 /exports.exp${_OBJECTS}" + "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o /exports.exp ${_OBJECTS}" " -Wl,-bE:/exports.exp -o " ) set(CMAKE_${lang}_LINK_EXECUTABLE_WITH_EXPORTS - "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o -l . " + "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o -l . " " -Wl,-bE: -o ") unset(_OBJECTS) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index b8d8b96fa6..5ff6f8cee2 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -17,6 +17,7 @@ #include "cmSourceFile.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" +#include "cmTarget.h" cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt) : GeneratorTarget(gt) @@ -216,6 +217,20 @@ std::string cmCommonTargetGenerator::GetManifests(const std::string& config) return cmJoin(manifests, " "); } +std::string cmCommonTargetGenerator::GetAIXExports(std::string const&) +{ + std::string aixExports; + if (this->GeneratorTarget->Target->IsAIX()) { + if (const char* exportAll = + this->GeneratorTarget->GetProperty("AIX_EXPORT_ALL_SYMBOLS")) { + if (cmIsOff(exportAll)) { + aixExports = "-n"; + } + } + } + return aixExports; +} + void cmCommonTargetGenerator::AppendOSXVerFlag(std::string& flags, const std::string& lang, const char* name, bool so) diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index 2796470e5f..b40a2edad4 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -55,6 +55,7 @@ protected: std::string GetDefines(const std::string& l, const std::string& config); std::string GetIncludes(std::string const& l, const std::string& config); std::string GetManifests(const std::string& config); + std::string GetAIXExports(std::string const& config); std::vector GetLinkedTargetDirectories( const std::string& config) const; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 1df54104f2..0471a459e0 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -196,6 +196,8 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule( this->CreateObjectLists(useLinkScript, false, useResponseFileForObjects, buildObjs, depends, useWatcomQuote); + std::string const& aixExports = this->GetAIXExports(this->GetConfigName()); + cmRulePlaceholderExpander::RuleVariables vars; std::string objectDir = this->GeneratorTarget->GetSupportDirectory(); @@ -219,6 +221,7 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule( cmOutputConverter::SHELL); vars.Language = linkLanguage.c_str(); + vars.AIXExports = aixExports.c_str(); vars.Objects = buildObjs.c_str(); vars.ObjectDir = objectDir.c_str(); vars.Target = target.c_str(); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 357e273770..d3f3a4ff0a 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -727,6 +727,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( cmOutputConverter::SHELL); } + std::string const& aixExports = this->GetAIXExports(this->GetConfigName()); + // maybe create .def file from list of objects this->GenDefFile(real_link_commands); @@ -756,6 +758,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( vars.CMTargetType = cmState::GetTargetTypeName(this->GeneratorTarget->GetType()); vars.Language = linkLanguage.c_str(); + vars.AIXExports = aixExports.c_str(); vars.Objects = buildObjs.c_str(); std::string objectDir = this->GeneratorTarget->GetSupportDirectory(); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 437548a364..ffb269ac1b 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -286,6 +286,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile, std::string lang = this->TargetLinkLanguage(config); vars.Language = config.c_str(); + vars.AIXExports = "$AIX_EXPORTS"; if (this->TargetLinkLanguage(config) == "Swift") { vars.SwiftLibraryName = "$SWIFT_LIBRARY_NAME"; @@ -955,6 +956,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement( vars["LINK_FLAGS"] = globalGen->EncodeLiteral(vars["LINK_FLAGS"]); vars["MANIFESTS"] = this->GetManifests(config); + vars["AIX_EXPORTS"] = this->GetAIXExports(config); vars["LINK_PATH"] = frameworkPath + linkPath; std::string lwyuFlags; diff --git a/Source/cmRulePlaceholderExpander.cxx b/Source/cmRulePlaceholderExpander.cxx index 0a1d109d56..5ab1b3ac14 100644 --- a/Source/cmRulePlaceholderExpander.cxx +++ b/Source/cmRulePlaceholderExpander.cxx @@ -85,6 +85,11 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable( return replaceValues.ObjectsQuoted; } } + if (replaceValues.AIXExports) { + if (variable == "AIX_EXPORTS") { + return replaceValues.AIXExports; + } + } if (replaceValues.Defines && variable == "DEFINES") { return replaceValues.Defines; } diff --git a/Source/cmRulePlaceholderExpander.h b/Source/cmRulePlaceholderExpander.h index 8f361967b1..09e8a3b1c0 100644 --- a/Source/cmRulePlaceholderExpander.h +++ b/Source/cmRulePlaceholderExpander.h @@ -36,6 +36,7 @@ public: const char* TargetVersionMajor; const char* TargetVersionMinor; const char* Language; + const char* AIXExports; const char* Objects; const char* Target; const char* LinkLibraries; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a0c217b7d5..d0b6f10495 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -491,6 +491,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, } if (impl->TargetType == cmStateEnums::SHARED_LIBRARY || impl->TargetType == cmStateEnums::EXECUTABLE) { + initProp("AIX_EXPORT_ALL_SYMBOLS"); initProp("WINDOWS_EXPORT_ALL_SYMBOLS"); } diff --git a/Tests/RunCMake/AutoExportDll/AIXExportExplicit-build-result.txt b/Tests/RunCMake/AutoExportDll/AIXExportExplicit-build-result.txt new file mode 100644 index 0000000000..d197c913c2 --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/AIXExportExplicit-build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/AutoExportDll/AIXExportExplicit-build-stdout.txt b/Tests/RunCMake/AutoExportDll/AIXExportExplicit-build-stdout.txt new file mode 100644 index 0000000000..760ba3ce3b --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/AIXExportExplicit-build-stdout.txt @@ -0,0 +1 @@ +ERROR: Undefined symbol: .AIXNotExported diff --git a/Tests/RunCMake/AutoExportDll/AIXExportExplicit.cmake b/Tests/RunCMake/AutoExportDll/AIXExportExplicit.cmake new file mode 100644 index 0000000000..d23b1724ac --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/AIXExportExplicit.cmake @@ -0,0 +1,7 @@ +enable_language(C) + +set(CMAKE_AIX_EXPORT_ALL_SYMBOLS OFF) +add_library(AIXExportExplicitLib SHARED AIXExportExplicitLib.c) +add_executable(AIXExportExplicitMain AIXExportExplicitMain.c) +target_link_options(AIXExportExplicitLib PRIVATE LINKER:-bE:${CMAKE_CURRENT_SOURCE_DIR}/AIXExportExplicitLib.exp) +target_link_libraries(AIXExportExplicitMain PRIVATE AIXExportExplicitLib) diff --git a/Tests/RunCMake/AutoExportDll/AIXExportExplicitLib.c b/Tests/RunCMake/AutoExportDll/AIXExportExplicitLib.c new file mode 100644 index 0000000000..58fd5acc8b --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/AIXExportExplicitLib.c @@ -0,0 +1,8 @@ +int AIXNotExported(void) +{ + return 0; +} +int AIXExportedSymbol(void) +{ + return 0; +} diff --git a/Tests/RunCMake/AutoExportDll/AIXExportExplicitLib.exp b/Tests/RunCMake/AutoExportDll/AIXExportExplicitLib.exp new file mode 100644 index 0000000000..9eb7bf89cc --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/AIXExportExplicitLib.exp @@ -0,0 +1 @@ +AIXExportedSymbol diff --git a/Tests/RunCMake/AutoExportDll/AIXExportExplicitMain.c b/Tests/RunCMake/AutoExportDll/AIXExportExplicitMain.c new file mode 100644 index 0000000000..ad9c8ecd0f --- /dev/null +++ b/Tests/RunCMake/AutoExportDll/AIXExportExplicitMain.c @@ -0,0 +1,7 @@ +extern int AIXNotExported(void); +extern int AIXExportedSymbol(void); + +int main(void) +{ + return AIXNotExported() + AIXExportedSymbol(); +} diff --git a/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake index 6c9be4bb13..75130f2714 100644 --- a/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake +++ b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake @@ -55,3 +55,14 @@ if(EXPORTS) message(SEND_ERROR "\"${EXPORTS_DEF}\" has been updated.") endif() endif() + +function(run_AIXExportExplicit) + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/AIXExpotExplicit-build") + run_cmake(AIXExportExplicit) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OUTPUT_MERGE TRUE) + run_cmake_command(AIXExportExplicit-build ${CMAKE_COMMAND} --build . --config Debug) +endfunction() +if(CMAKE_SYSTEM_NAME STREQUAL "AIX") + run_AIXExportExplicit() +endif() diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index ad70a34569..e9f8bca57c 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -614,7 +614,10 @@ endif() add_RunCMake_test_group(CPack "${cpack_tests}") # add a test to make sure symbols are exported from a shared library # for MSVC compilers CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS property is used -add_RunCMake_test(AutoExportDll -DCMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID}) +add_RunCMake_test(AutoExportDll + -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} + -DCMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID} + ) add_RunCMake_test(AndroidMK)