1
0
Fork 0

Add some hardening compiler / linker flags.

This commit is contained in:
John Preston 2021-09-28 18:44:05 +04:00
parent 1dacc0ac4f
commit f3a611c82b
5 changed files with 14 additions and 1 deletions

View file

@ -33,7 +33,7 @@ if (NOT JEMALLOC_FOUND)
include(ExternalProject)
ExternalProject_Add(jemalloc
SOURCE_DIR ${jemalloc_loc}
CONFIGURE_COMMAND cd "${jemalloc_loc}" && CC=clang CXX=clang++ EXTRA_CFLAGS=-fPIE EXTRA_CXXFLAGS=-fPIE ./autogen.sh
CONFIGURE_COMMAND cd "${jemalloc_loc}" && export EXTRA_CFLAGS=-fstack-protector-all\ -fPIC\ -D_FORTIFY_SOURCE=2 && export EXTRA_CXXFLAGS=-fstack-protector-all\ -fPIC\ -D_FORTIFY_SOURCE=2 && CC=clang CXX=clang++ ./autogen.sh
INSTALL_COMMAND :
BUILD_IN_SOURCE 1
BUILD_BYPRODUCTS ${jemalloc_loc}/lib/libjemalloc.a

View file

@ -5,6 +5,7 @@
# https://github.com/desktop-app/legal/blob/master/LEGAL
add_library(linux_glib_helper STATIC)
init_target(linux_glib_helper "(external)")
add_library(desktop-app::linux_glib_helper ALIAS linux_glib_helper)
nice_target_sources(linux_glib_helper ${CMAKE_CURRENT_SOURCE_DIR}

View file

@ -5,6 +5,7 @@
# https://github.com/desktop-app/legal/blob/master/LEGAL
add_library(linux_gtk_helper STATIC)
init_target(linux_gtk_helper "(external)")
add_library(desktop-app::linux_gtk_helper ALIAS linux_gtk_helper)
nice_target_sources(linux_gtk_helper ${CMAKE_CURRENT_SOURCE_DIR}

View file

@ -5,6 +5,7 @@
# https://github.com/desktop-app/legal/blob/master/LEGAL
add_library(linux_wayland_helper STATIC)
init_target(linux_wayland_helper "(external)")
add_library(desktop-app::linux_wayland_helper ALIAS linux_wayland_helper)
nice_target_sources(linux_wayland_helper ${CMAKE_CURRENT_SOURCE_DIR}

View file

@ -6,6 +6,8 @@
target_compile_options(common_options
INTERFACE
-fstack-protector-all
-fstack-clash-protection
-fPIC
$<IF:$<CONFIG:Debug>,,-fno-strict-aliasing>
-pipe
@ -17,9 +19,17 @@ INTERFACE
-Wno-sign-compare
)
target_compile_definitions(common_options
INTERFACE
$<IF:$<CONFIG:Debug>,,_FORTIFY_SOURCE=2>
)
target_link_options(common_options
INTERFACE
-Wl,--as-needed
-Wl,-z,relro
-Wl,-z,now
-pie
)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")