diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2018-12-13 15:14:59 (GMT) |
---|---|---|
committer | Craig Scott <craig.scott@crascit.com> | 2018-12-19 08:41:27 (GMT) |
commit | f255280fd908e4ef1af5eba6230e81b74d339855 (patch) | |
tree | 2fcccac786e1b8e967c57e9e9230d30040177a2a /Modules/Compiler/GNU.cmake | |
parent | 3bd814460161f3af682e116aa561efcc30793eff (diff) | |
download | CMake-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/GNU.cmake')
-rw-r--r-- | Modules/Compiler/GNU.cmake | 19 |
1 files changed, 5 insertions, 14 deletions
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=") |