summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-01-30 14:10:58 (GMT)
committerBrad King <brad.king@kitware.com>2020-01-31 14:34:06 (GMT)
commitafcd9fe66943259ea9521ff77b32673e0cdf70b2 (patch)
treedca73be96274dc28f334e990fa58bc8aa972533e /Source
parent67f30811ce6b70717c36951650d9e62b16a14260 (diff)
downloadCMake-afcd9fe66943259ea9521ff77b32673e0cdf70b2.zip
CMake-afcd9fe66943259ea9521ff77b32673e0cdf70b2.tar.gz
CMake-afcd9fe66943259ea9521ff77b32673e0cdf70b2.tar.bz2
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
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCommonTargetGenerator.cxx15
-rw-r--r--Source/cmCommonTargetGenerator.h1
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx3
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx3
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx2
-rw-r--r--Source/cmRulePlaceholderExpander.cxx5
-rw-r--r--Source/cmRulePlaceholderExpander.h1
-rw-r--r--Source/cmTarget.cxx1
8 files changed, 31 insertions, 0 deletions
diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx
index b8d8b96..5ff6f8c 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 2796470..b40a2ed 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<std::string> GetLinkedTargetDirectories(
const std::string& config) const;
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 1df5410..0471a45 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 357e273..d3f3a4f 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 437548a..ffb269a 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 0a1d109..5ab1b3a 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 8f36196..09e8a3b 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 a0c217b..d0b6f10 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");
}