1From 4bb57da5fb0bb0d7e747b9e325e9ec0876ffc1f9 Mon Sep 17 00:00:00 2001 2From: Fabrice Fontaine <fontaine.fabrice@gmail.com> 3Date: Sat, 31 Jul 2021 16:36:50 +0200 4Subject: [PATCH] add BUILD_WITH_STACK_PROTECTOR option 5 6Add BUILD_WITH_STACK_PROTECTOR to avoid the following build failure with 7toolchains that don't support stack-protector: 8 9/home/buildroot/autobuild/instance-3/output-1/host/opt/ext-toolchain/bin/../lib/gcc/mipsel-buildroot-linux-uclibc/9.3.0/../../../../mipsel-buildroot-linux-uclibc/bin/ld: utils.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xd0): undefined reference to `__stack_chk_fail' 10 11Indeed, support for -fstack-protector-strong can't be detected through 12check_cxx_compiler_flag as some toolchains need to link with -lssp to 13enable SSP support 14 15Fixes: 16 - http://autobuild.buildroot.org/results/ae4635899124c602c70d2b342a76f95c34aa4a3d 17 18Upstream: https://github.com/Exiv2/exiv2/commit/f31c0eba098889899d29b7b0da830aee2b62a7b8 19Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> 20--- 21 CMakeLists.txt | 1 + 22 cmake/compilerFlags.cmake | 4 ++-- 23 2 files changed, 3 insertions(+), 2 deletions(-) 24 25diff --git a/CMakeLists.txt b/CMakeLists.txt 26index 6f0da06a..0746ee14 100644 27--- a/CMakeLists.txt 28+++ b/CMakeLists.txt 29@@ -47,6 +47,7 @@ mark_as_advanced( 30 EXIV2_TEAM_USE_SANITIZERS 31 ) 32 33+option( BUILD_WITH_STACK_PROTECTOR "Build with stack protector" ON ) 34 option( BUILD_WITH_CCACHE "Use ccache to speed up compilations" OFF ) 35 option( BUILD_WITH_COVERAGE "Add compiler flags to generate coverage stats" OFF ) 36 37diff --git a/cmake/compilerFlags.cmake b/cmake/compilerFlags.cmake 38index 35faf501..0a646e50 100644 39--- a/cmake/compilerFlags.cmake 40+++ b/cmake/compilerFlags.cmake 41@@ -33,8 +33,8 @@ if ( MINGW OR UNIX OR MSYS ) # MINGW, Linux, APPLE, CYGWIN 42 endif() 43 if(HAS_FCF_PROTECTION) 44 add_compile_options(-fcf-protection) 45- endif() 46- if(HAS_FSTACK_PROTECTOR_STRONG) 47+ endif() 48+ if(BUILD_WITH_STACK_PROTECTOR AND HAS_FSTACK_PROTECTOR_STRONG) 49 add_compile_options(-fstack-protector-strong) 50 endif() 51 endif() 52-- 532.31.1 54 55