summaryrefslogtreecommitdiffstats
path: root/Modules/Compiler
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2018-12-13 15:14:59 (GMT)
committerCraig Scott <craig.scott@crascit.com>2018-12-19 08:41:27 (GMT)
commitf255280fd908e4ef1af5eba6230e81b74d339855 (patch)
tree2fcccac786e1b8e967c57e9e9230d30040177a2a /Modules/Compiler
parent3bd814460161f3af682e116aa561efcc30793eff (diff)
downloadCMake-f255280fd908e4ef1af5eba6230e81b74d339855.zip
CMake-f255280fd908e4ef1af5eba6230e81b74d339855.tar.gz
CMake-f255280fd908e4ef1af5eba6230e81b74d339855.tar.bz2
PIE link options: Update strategy to fix performance regression
Fixes: #18700
Diffstat (limited to 'Modules/Compiler')
-rw-r--r--Modules/Compiler/AppleClang-C.cmake3
-rw-r--r--Modules/Compiler/AppleClang-CXX.cmake3
-rw-r--r--Modules/Compiler/Clang.cmake20
-rw-r--r--Modules/Compiler/GNU.cmake19
-rw-r--r--Modules/Compiler/SunPro-C.cmake1
-rw-r--r--Modules/Compiler/SunPro-CXX.cmake1
-rw-r--r--Modules/Compiler/SunPro-Fortran.cmake1
7 files changed, 11 insertions, 37 deletions
diff --git a/Modules/Compiler/AppleClang-C.cmake b/Modules/Compiler/AppleClang-C.cmake
index 8754951..a48adec 100644
--- a/Modules/Compiler/AppleClang-C.cmake
+++ b/Modules/Compiler/AppleClang-C.cmake
@@ -1,9 +1,6 @@
include(Compiler/Clang)
__compiler_clang(C)
-set(CMAKE_C_LINK_OPTIONS_PIE ${CMAKE_C_COMPILE_OPTIONS_PIE} -Xlinker -pie)
-set(CMAKE_C_LINK_OPTIONS_NO_PIE -Xlinker -no_pie)
-
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0)
set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90")
set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90")
diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake
index 54c1388..e5fd647 100644
--- a/Modules/Compiler/AppleClang-CXX.cmake
+++ b/Modules/Compiler/AppleClang-CXX.cmake
@@ -1,9 +1,6 @@
include(Compiler/Clang)
__compiler_clang(CXX)
-set(CMAKE_CXX_LINK_OPTIONS_PIE ${CMAKE_CXX_COMPILE_OPTIONS_PIE} -Xlinker -pie)
-set(CMAKE_CXX_LINK_OPTIONS_NO_PIE -Xlinker -no_pie)
-
if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
endif()
diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake
index 7cee9c7..c3f13f3 100644
--- a/Modules/Compiler/Clang.cmake
+++ b/Modules/Compiler/Clang.cmake
@@ -23,23 +23,9 @@ else()
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE")
# Link options for PIE are already set in 'Compiler/GNU.cmake'
# but clang may require alternate syntax on some platforms
- if (NOT CMAKE_${lang}_FLAG_PIE)
- cmake_check_compiler_flag(${lang} "${CMAKE_${lang}_COMPILE_OPTIONS_PIE};-Xlinker;-pie"
- CMAKE_${lang}_FLAG_XLINKER_PIE)
- if (CMAKE_${lang}_FLAG_XLINKER_PIE)
- set(CMAKE_${lang}_LINK_OPTIONS_PIE ${CMAKE_${lang}_COMPILE_OPTIONS_PIE} "-Xlinker" "-pie")
- else()
- set(CMAKE_${lang}_LINK_OPTIONS_PIE "")
- endif()
- endif()
- if (NOT CMAKE_${lang}_FLAG_NO_PIE)
- cmake_check_compiler_flag(${lang} "-Xlinker;-no_pie"
- CMAKE_${lang}_FLAG_XLINKER_NO_PIE)
- if (CMAKE_${lang}_FLAG_XLINKER_NO_PIE)
- set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "-Xlinker" "-no_pie")
- else()
- set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "")
- endif()
+ if (APPLE)
+ set(CMAKE_${lang}_LINK_OPTIONS_PIE ${CMAKE_${lang}_COMPILE_OPTIONS_PIE} -Xlinker -pie)
+ set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE -Xlinker -no_pie)
endif()
set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=")
diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake
index 688a1b5..6b1bd3a 100644
--- a/Modules/Compiler/GNU.cmake
+++ b/Modules/Compiler/GNU.cmake
@@ -15,23 +15,14 @@ macro(__compiler_gnu lang)
# Feature flags.
set(CMAKE_${lang}_VERBOSE_FLAG "-v")
set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC")
+ set (_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4)
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE")
# Support of PIE at link stage depends on various elements : platform, compiler, linker
- # so the easiest way is to check if compiler supports these flags
- cmake_check_compiler_flag(${lang} "${CMAKE_${lang}_COMPILE_OPTIONS_PIE};-pie"
- CMAKE_${lang}_FLAG_PIE)
- if (CMAKE_${lang}_FLAG_PIE)
- set(CMAKE_${lang}_LINK_OPTIONS_PIE ${CMAKE_${lang}_COMPILE_OPTIONS_PIE} "-pie")
- else()
- set(CMAKE_${lang}_LINK_OPTIONS_PIE "")
- endif()
- cmake_check_compiler_flag(${lang} "-no-pie" CMAKE_${lang}_FLAG_NO_PIE)
- if (CMAKE_${lang}_FLAG_NO_PIE)
- set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "-no-pie")
- else()
- set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "")
- endif()
+ # so to activate it, module CheckPIESupported must be used.
+ set (_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER YES)
+ set(CMAKE_${lang}_LINK_OPTIONS_PIE ${CMAKE_${lang}_COMPILE_OPTIONS_PIE} "-pie")
+ set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "-no-pie")
endif()
if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.0)
set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=")
diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake
index 75b8fe6..c4aba8e 100644
--- a/Modules/Compiler/SunPro-C.cmake
+++ b/Modules/Compiler/SunPro-C.cmake
@@ -7,6 +7,7 @@ set(CMAKE_C_VERBOSE_FLAG "-#")
set(CMAKE_C_COMPILE_OPTIONS_PIC -KPIC)
set(CMAKE_C_COMPILE_OPTIONS_PIE "")
+set(_CMAKE_C_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
set(CMAKE_C_LINK_OPTIONS_PIE "")
set(CMAKE_C_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-KPIC")
diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake
index 662ac30..5ce58b2 100644
--- a/Modules/Compiler/SunPro-CXX.cmake
+++ b/Modules/Compiler/SunPro-CXX.cmake
@@ -7,6 +7,7 @@ set(CMAKE_CXX_VERBOSE_FLAG "-v")
set(CMAKE_CXX_COMPILE_OPTIONS_PIC -KPIC)
set(CMAKE_CXX_COMPILE_OPTIONS_PIE "")
+set(_CMAKE_CXX_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
set(CMAKE_CXX_LINK_OPTIONS_PIE "")
set(CMAKE_CXX_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-KPIC")
diff --git a/Modules/Compiler/SunPro-Fortran.cmake b/Modules/Compiler/SunPro-Fortran.cmake
index e110253..0c93c94 100644
--- a/Modules/Compiler/SunPro-Fortran.cmake
+++ b/Modules/Compiler/SunPro-Fortran.cmake
@@ -4,6 +4,7 @@ set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free")
set(CMAKE_Fortran_COMPILE_OPTIONS_PIC "-KPIC")
set(CMAKE_Fortran_COMPILE_OPTIONS_PIE "")
+set(_CMAKE_Fortran_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
set(CMAKE_Fortran_LINK_OPTIONS_PIE "")
set(CMAKE_Fortran_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-KPIC")