Pārlūkot izejas kodu

Add more debug checks for gcc

Ivan Savenko 1 gadu atpakaļ
vecāks
revīzija
c7fda0dc32
2 mainītis faili ar 3 papildinājumiem un 6 dzēšanām
  1. 3 0
      CMakeLists.txt
  2. 0 6
      Global.h

+ 3 - 0
CMakeLists.txt

@@ -393,6 +393,9 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR NOT WIN32)
 		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=array-bounds") # false positives in boost::multiarray during release build, keep as warning-only
 	endif()
 
+	# For gcc 14+ we can use -fhardened instead
+	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FORTIFY_SOURCE=2 -D_GLIBCXX_ASSERTIONS -fstack-protector-strong -fstack-clash-protection -fcf-protection=full")
+
 	# Fix string inspection with lldb
 	# https://stackoverflow.com/questions/58578615/cannot-inspect-a-stdstring-variable-in-lldb
 	if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")

+ 0 - 6
Global.h

@@ -104,12 +104,6 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
 
 #define _USE_MATH_DEFINES
 
-#ifndef NDEBUG
-// Enable additional debug checks from glibc / libstdc++ when building with enabled assertions
-// Since these defines must be declared BEFORE including glibc header we can not check for __GLIBCXX__ macro to detect that glibc is in use
-#  define _GLIBCXX_ASSERTIONS
-#endif
-
 #include <algorithm>
 #include <any>
 #include <array>