diff options
author | Craig Scott <craig.scott@crascit.com> | 2018-12-23 22:22:59 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-12-23 22:23:11 (GMT) |
commit | d480ede35b82c540e9d93b7bb4280014875f6444 (patch) | |
tree | ad2a4fe6eb8525e9ff47e889727cebd1e7c4b9ba /Source | |
parent | 170fcebf2e866ce5266067716025a57c7e7e6ec4 (diff) | |
parent | f255280fd908e4ef1af5eba6230e81b74d339855 (diff) | |
download | CMake-d480ede35b82c540e9d93b7bb4280014875f6444.zip CMake-d480ede35b82c540e9d93b7bb4280014875f6444.tar.gz CMake-d480ede35b82c540e9d93b7bb4280014875f6444.tar.bz2 |
Merge topic 'link-options'
f255280fd9 PIE link options: Update strategy to fix performance regression
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2739
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmCoreTryCompile.cxx | 18 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 10 |
2 files changed, 26 insertions, 2 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 541ae76..f9b494e 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -24,10 +24,18 @@ static std::string const kCMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN = "CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN"; static std::string const kCMAKE_C_COMPILER_TARGET = "CMAKE_C_COMPILER_TARGET"; +static std::string const kCMAKE_C_LINK_NO_PIE_SUPPORTED = + "CMAKE_C_LINK_NO_PIE_SUPPORTED"; +static std::string const kCMAKE_C_LINK_PIE_SUPPORTED = + "CMAKE_C_LINK_PIE_SUPPORTED"; static std::string const kCMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN = "CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN"; static std::string const kCMAKE_CXX_COMPILER_TARGET = "CMAKE_CXX_COMPILER_TARGET"; +static std::string const kCMAKE_CXX_LINK_NO_PIE_SUPPORTED = + "CMAKE_CXX_LINK_NO_PIE_SUPPORTED"; +static std::string const kCMAKE_CXX_LINK_PIE_SUPPORTED = + "CMAKE_CXX_LINK_PIE_SUPPORTED"; static std::string const kCMAKE_ENABLE_EXPORTS = "CMAKE_ENABLE_EXPORTS"; static std::string const kCMAKE_LINK_SEARCH_END_STATIC = "CMAKE_LINK_SEARCH_END_STATIC"; @@ -633,6 +641,16 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, vars.insert(varList.begin(), varList.end()); } + if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0083) == + cmPolicies::NEW) { + // To ensure full support of PIE, propagate cache variables + // driving the link options + vars.insert(kCMAKE_C_LINK_PIE_SUPPORTED); + vars.insert(kCMAKE_C_LINK_NO_PIE_SUPPORTED); + vars.insert(kCMAKE_CXX_LINK_PIE_SUPPORTED); + vars.insert(kCMAKE_CXX_LINK_NO_PIE_SUPPORTED); + } + /* for the TRY_COMPILEs we want to be able to specify the architecture. So the user can set CMAKE_OSX_ARCHITECTURES to i386;ppc and then set CMAKE_TRY_COMPILE_OSX_ARCHITECTURES first to i386 and then to ppc to diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index da48950..8fac039 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2044,8 +2044,14 @@ void cmLocalGenerator::AppendPositionIndependentLinkerFlags( return; } - std::string name = "CMAKE_" + lang + "_LINK_OPTIONS_"; - name += cmSystemTools::IsOn(PICValue) ? "PIE" : "NO_PIE"; + const std::string mode = cmSystemTools::IsOn(PICValue) ? "PIE" : "NO_PIE"; + + std::string supported = "CMAKE_" + lang + "_LINK_" + mode + "_SUPPORTED"; + if (cmSystemTools::IsOff(this->Makefile->GetDefinition(supported))) { + return; + } + + std::string name = "CMAKE_" + lang + "_LINK_OPTIONS_" + mode; auto pieFlags = this->Makefile->GetSafeDefinition(name); if (pieFlags.empty()) { |