disable gcc stack protector, segfault on 8.2.0

Make gcc -fstack-protector-strong and associated options controlled by
the cmake option ENABLE_SSP which defaults to OFF.

This option causes a segfault on startup with gcc 8.2.0.
This commit is contained in:
Rafael Kitover 2018-08-10 16:35:49 -07:00
parent 6cbad61f36
commit 65e1ab041d
2 changed files with 21 additions and 11 deletions

View File

@ -69,6 +69,10 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "[xX]86|i[3-9]86|[aA][mM][dD]64")
endif()
endif()
set(SSP_DEFAULT OFF)
option(ENABLE_SSP "Enable gcc stack protector support" ${SSP_DEFAULT})
option(ENABLE_ASM "Enable x86 ASM related options" ${ASM_DEFAULT})
# The ARM ASM core seems to be very buggy, see #98 and #54. Default to it being
@ -396,17 +400,19 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
# check if ssp flags are supported for this version of gcc
if(CMAKE_COMPILER_IS_GNUCXX)
check_cxx_compiler_flag(-fstack-protector-strong F_STACK_PROTECTOR_STRONG_FLAG)
if(ENABLE_SSP)
check_cxx_compiler_flag(-fstack-protector-strong F_STACK_PROTECTOR_STRONG_FLAG)
if(F_STACK_PROTECTOR_STRONG_FLAG)
set(MY_C_FLAGS ${MY_C_FLAGS} -fstack-protector-strong)
if(F_STACK_PROTECTOR_STRONG_FLAG)
set(MY_C_FLAGS ${MY_C_FLAGS} -fstack-protector-strong)
check_cxx_compiler_flag("--param ssp-buffer-size=4" SSP_BUFFER_SIZE_FLAG)
check_cxx_compiler_flag("--param ssp-buffer-size=4" SSP_BUFFER_SIZE_FLAG)
if(SSP_BUFFER_SIZE_FLAG)
# we do not add it to MY_C_FLAGS because this breaks things like CMAKE_REQUIRED_LIBRARIES
# which misinterpret compiler flags without leading dashes
add_compile_options(--param ssp-buffer-size=4)
if(SSP_BUFFER_SIZE_FLAG)
# we do not add it to MY_C_FLAGS because this breaks things like CMAKE_REQUIRED_LIBRARIES
# which misinterpret compiler flags without leading dashes
add_compile_options(--param ssp-buffer-size=4)
endif()
endif()
endif()
@ -457,10 +463,12 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
set(SSP_STATIC ON)
endif()
find_package(SSP)
if(ENABLE_SSP)
find_package(SSP)
if(SSP_LIBRARY)
set(MY_C_LINKER_FLAGS ${MY_C_LINKER_FLAGS} ${SSP_LIBRARY})
if(SSP_LIBRARY)
set(MY_C_LINKER_FLAGS ${MY_C_LINKER_FLAGS} ${SSP_LIBRARY})
endif()
endif()
set(MY_C_LINKER_FLAGS ${MY_C_LINKER_FLAGS} -Wl,-allow-multiple-definition)

View File

@ -146,12 +146,14 @@ Here is the complete list:
| ENABLE_DIRECT3D | Direct3D rendering for wxWidgets (Windows, **NOT IMPLEMENTED!!!**) | ON |
| ENABLE_XAUDIO2 | Enable xaudio2 sound output for wxWidgets (Windows only) | ON |
| ENABLE_OPENAL | Enable OpenAL for the wxWidgets port | OFF |
| ENABLE_SSP | Enable gcc stack protector support (gcc only) | OFF |
| VBAM_STATIC | Try link all libs statically (the following are set to ON if ON) | OFF |
| SDL2_STATIC | Try to link static SDL2 libraries | OFF |
| SFML_STATIC_LIBRARIES | Try to link static SFML libraries | OFF |
| FFMPEG_STATIC | Try to link static ffmpeg libraries | OFF |
| SSP_STATIC | Try to link static gcc stack protector library (gcc only) | OFF except Win32 |
| OPENAL_STATIC | Try to link static OpenAL libraries | OFF |
| SSP_STATIC | Link gcc stack protecter libssp statically (gcc, with ENABLE_SSP) | OFF |
Note for distro packagers, we use the CMake module
[GNUInstallDirs](https://cmake.org/cmake/help/v2.8.12/cmake.html#module:GNUInstallDirs)