diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-02-17 14:58:16 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-02-25 15:47:50 +0100 |
commit | 119ffd478134d793fb4414a65549acd19e919e0b (patch) | |
tree | 91f81998f26ec91771230b7def53d2e0ce5e4011 /cmake | |
parent | bbf46e38b1d0f70b5c830b3ae2fccf66cf7edb8d (diff) |
CMake: Port the reduce-relocations feature
As reduce-relocations implies bsymbolic_functions, we also add the
-Bsymbolic-functions linker flag.
Also, handle the .dynlist files that are passed to the linker by
bsymbolic_functions.prf in the qmake build.
Change-Id: I535c33fba888596d2f8975b16864bbe9f0a7caa4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtBuild.cmake | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 4c5a7a6019..8deb9b8cbd 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -1573,6 +1573,7 @@ function(qt_add_module target) ### Define Targets: set(is_interface_lib 0) + set(is_shared_lib 0) if(${arg_HEADER_MODULE}) add_library("${target}" INTERFACE) set(is_interface_lib 1) @@ -1580,6 +1581,7 @@ function(qt_add_module target) add_library("${target}" STATIC) elseif(${QT_BUILD_SHARED_LIBS}) add_library("${target}" SHARED) + set(is_shared_lib 1) else() add_library("${target}" STATIC) endif() @@ -1596,6 +1598,19 @@ function(qt_add_module target) ) endif() + if(QT_FEATURE_reduce_relocations AND UNIX AND NOT is_interface_lib) + # On x86 and x86-64 systems with ELF binaries (especially Linux), due to + # a new optimization in GCC 5.x in combination with a recent version of + # GNU binutils, compiling Qt applications with -fPIE is no longer + # enough. + # Applications now need to be compiled with the -fPIC option if the Qt option + # \"reduce relocations\" is active. + target_compile_options(${target} INTERFACE -fPIC) + if(GCC AND is_shared_lib) + target_link_options(${target} PRIVATE LINKER:-Bsymbolic-functions) + endif() + endif() + if (ANDROID) qt_android_apply_arch_suffix("${target}") endif() |