tde_setup_architecture_flags: Add test for liner flag -pie or -ztype=pie.

Signed-off-by: Denis Kozadaev <denis@dilos.org>
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 4e0406ce01)
pull/95/head
Denis Kozadaev 1 year ago committed by Slávek Banko
parent 570dbf6e74
commit 1af8cf3511
Signed by: SlavekB
GPG Key ID: 608F5293A04BE668

@ -16,6 +16,7 @@
#################################################
include( CheckCXXCompilerFlag )
include( CheckLinkerFlag OPTIONAL )
include( TDEVersion )
@ -2843,7 +2844,29 @@ macro( tde_setup_architecture_flags )
check_cxx_compiler_flag( -fPIE HAVE_PIE_SUPPORT )
if( HAVE_PIE_SUPPORT )
set( TDE_PIE_CFLAGS -fPIE )
set( TDE_PIE_LDFLAGS -pie )
if( ${CMAKE_VERSION} VERSION_LESS "3.18" )
execute_process(COMMAND "${CMAKE_LINKER}" --help
OUTPUT_VARIABLE __linker_help
ERROR_VARIABLE __linker_help)
if( "${__linker_help}" MATCHES "-pie" )
set( LINKER_PIE_SUPPORT 1 )
elseif( "${__linker_help}" MATCHES "type=type.*pie" )
set( LINKER_ZTYPE_PIE_SUPPORT 1 )
endif( )
unset(__linker_help)
else( )
check_linker_flag(CXX -pie LINKER_PIE_SUPPORT)
if( NOT LINKER_PIE_SUPPORT )
check_linker_flag(CXX -ztype=pie LINKER_ZTYPE_PIE_SUPPORT)
endif()
endif()
if( LINKER_PIE_SUPPORT )
set( TDE_PIE_LDFLAGS -pie )
endif( LINKER_PIE_SUPPORT )
if( LINKER_ZTYPE_PIE_SUPPORT )
set( TDE_PIE_LDFLAGS -ztype=pie )
endif( LINKER_ZTYPE_PIE_SUPPORT )
endif( HAVE_PIE_SUPPORT )
set( _reproducible_cxxflags

Loading…
Cancel
Save