diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2018-10-02 15:34:57 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2018-11-11 16:34:09 (GMT) |
commit | c4b4d8b3a67718e29edb5676273e528dab566672 (patch) | |
tree | ddb8839ae8a5a15b5ffe8dd8190cf873841475da /Modules/Platform | |
parent | 724a0346f7bd424ce0e5db246cee46db9f377a6f (diff) | |
download | CMake-c4b4d8b3a67718e29edb5676273e528dab566672.zip CMake-c4b4d8b3a67718e29edb5676273e528dab566672.tar.gz CMake-c4b4d8b3a67718e29edb5676273e528dab566672.tar.bz2 |
POSITION_INDEPENDENT_CODE: Manage link flags for executables
Fixes: #14983, #16561
Diffstat (limited to 'Modules/Platform')
-rw-r--r-- | Modules/Platform/Android/abi-common.cmake | 4 | ||||
-rw-r--r-- | Modules/Platform/CYGWIN-GNU.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/FreeBSD.cmake | 1 | ||||
-rw-r--r-- | Modules/Platform/Fuchsia.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/Linux-Intel.cmake | 4 | ||||
-rw-r--r-- | Modules/Platform/Linux-PGI.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/NetBSD.cmake | 1 | ||||
-rw-r--r-- | Modules/Platform/SINIX.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/UNIX_SV.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/UnixWare.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/Windows-GNU.cmake | 2 |
11 files changed, 20 insertions, 4 deletions
diff --git a/Modules/Platform/Android/abi-common.cmake b/Modules/Platform/Android/abi-common.cmake index 10fb897..a0b47f4 100644 --- a/Modules/Platform/Android/abi-common.cmake +++ b/Modules/Platform/Android/abi-common.cmake @@ -12,10 +12,6 @@ if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() -if(CMAKE_POSITION_INDEPENDENT_CODE) - string(APPEND _ANDROID_ABI_INIT_EXE_LDFLAGS " -fPIE -pie") -endif() - string(APPEND _ANDROID_ABI_INIT_EXE_LDFLAGS " -Wl,--gc-sections") if(NOT _ANDROID_ABI_INIT_EXE_LDFLAGS_NO_nocopyreloc) diff --git a/Modules/Platform/CYGWIN-GNU.cmake b/Modules/Platform/CYGWIN-GNU.cmake index 784c8c6..f55b80d 100644 --- a/Modules/Platform/CYGWIN-GNU.cmake +++ b/Modules/Platform/CYGWIN-GNU.cmake @@ -27,6 +27,8 @@ macro(__cygwin_compiler_gnu lang) # No -fPIC on cygwin set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "") set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "") + set(CMAKE_${lang}_LINK_OPTIONS_PIE "") + set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "") set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "") # Initialize C link type selection flags. These flags are used when diff --git a/Modules/Platform/FreeBSD.cmake b/Modules/Platform/FreeBSD.cmake index 082e9f6..4a4c00d 100644 --- a/Modules/Platform/FreeBSD.cmake +++ b/Modules/Platform/FreeBSD.cmake @@ -1,6 +1,7 @@ set(CMAKE_DL_LIBS "") set(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC") set(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE") +# PIE link options are managed in Compiler/<compiler>.cmake file set(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib diff --git a/Modules/Platform/Fuchsia.cmake b/Modules/Platform/Fuchsia.cmake index 896da7b..7b33434 100644 --- a/Modules/Platform/Fuchsia.cmake +++ b/Modules/Platform/Fuchsia.cmake @@ -3,6 +3,8 @@ set(FUCHSIA 1) set(CMAKE_DL_LIBS "") set(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC") set(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE") +set(CMAKE_C_LINK_OPTIONS_PIE ${CMAKE_C_COMPILE_OPTIONS_PIE} "-pie") +set(CMAKE_C_LINK_OPTIONS_NO_PIE "-no-pie") set(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") diff --git a/Modules/Platform/Linux-Intel.cmake b/Modules/Platform/Linux-Intel.cmake index f712e2b..ab22b1d 100644 --- a/Modules/Platform/Linux-Intel.cmake +++ b/Modules/Platform/Linux-Intel.cmake @@ -23,6 +23,10 @@ endif() macro(__linux_compiler_intel lang) set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") + if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 13.0) + set(CMAKE_${lang}_LINK_OPTIONS_PIE ${CMAKE_${lang}_COMPILE_OPTIONS_PIE} "-pie") + set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "-no-pie") + endif() set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") diff --git a/Modules/Platform/Linux-PGI.cmake b/Modules/Platform/Linux-PGI.cmake index db032c2..3e7e391 100644 --- a/Modules/Platform/Linux-PGI.cmake +++ b/Modules/Platform/Linux-PGI.cmake @@ -12,6 +12,8 @@ macro(__linux_compiler_pgi lang) # Shared library compile and link flags. set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "") + set(CMAKE_${lang}_LINK_OPTIONS_PIE "") + set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "") set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS " ") diff --git a/Modules/Platform/NetBSD.cmake b/Modules/Platform/NetBSD.cmake index a8f4cc8..d99cb4a 100644 --- a/Modules/Platform/NetBSD.cmake +++ b/Modules/Platform/NetBSD.cmake @@ -1,6 +1,7 @@ set(CMAKE_DL_LIBS "") set(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC") set(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE") +# PIE link options are managed in Compiler/<compiler>.cmake file set(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib diff --git a/Modules/Platform/SINIX.cmake b/Modules/Platform/SINIX.cmake index c37a113..e44ceef 100644 --- a/Modules/Platform/SINIX.cmake +++ b/Modules/Platform/SINIX.cmake @@ -1,4 +1,6 @@ set(CMAKE_C_COMPILE_OPTIONS_PIC -K PIC) set(CMAKE_C_COMPILE_OPTIONS_PIE "") +set(CMAKE_C_LINK_OPTIONS_PIE "") +set(CMAKE_C_LINK_OPTIONS_NO_PIE "") set(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC") include(Platform/UnixPaths) diff --git a/Modules/Platform/UNIX_SV.cmake b/Modules/Platform/UNIX_SV.cmake index 1ec96ae..433daf3 100644 --- a/Modules/Platform/UNIX_SV.cmake +++ b/Modules/Platform/UNIX_SV.cmake @@ -1,5 +1,7 @@ set(CMAKE_C_COMPILE_OPTIONS_PIC -K PIC) set(CMAKE_C_COMPILE_OPTIONS_PIE "") +set(CMAKE_C_LINK_OPTIONS_PIE "") +set(CMAKE_C_LINK_OPTIONS_NO_PIE "") set(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC") set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,-Bexport") include(Platform/UnixPaths) diff --git a/Modules/Platform/UnixWare.cmake b/Modules/Platform/UnixWare.cmake index e649bd2..8c9d430 100644 --- a/Modules/Platform/UnixWare.cmake +++ b/Modules/Platform/UnixWare.cmake @@ -1,5 +1,7 @@ set(CMAKE_C_COMPILE_OPTIONS_PIC -K PIC) set(CMAKE_C_COMPILE_OPTIONS_PIE "") +set(CMAKE_C_LINK_OPTIONS_PIE "") +set(CMAKE_C_LINK_OPTIONS_NO_PIE "") set(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC") set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-Wl,-Bexport") include(Platform/UnixPaths) diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake index cfb325b..2e854e5 100644 --- a/Modules/Platform/Windows-GNU.cmake +++ b/Modules/Platform/Windows-GNU.cmake @@ -72,6 +72,8 @@ macro(__windows_compiler_gnu lang) # No -fPIC on Windows set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "") set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "") + set(CMAKE_${lang}_LINK_OPTIONS_PIE "") + set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "") set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "") set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS ${__WINDOWS_GNU_LD_RESPONSE}) |