From ac8692197e8ffb24fe7746f9323170920d5dca8a Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Thu, 21 Mar 2024 15:46:09 -0500 Subject: [PATCH] When disabling optimization, also disable _FORTIFY_SOURCE The _FORTIFY_SOURCE feature of gcc and clang cannot be enabled when optimization is disabled. When explicitly disabling it, also disable _FORTIFY_SOURCE if was externally enabled. --- CMakeLists.txt | 2 +- sample/strdup/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f7a7b54..5092f69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -201,7 +201,7 @@ function (add_mimick_test _NAME) if (NOT MSVC) foreach (ARG ${ARGN}) - set_source_files_properties (${ARG} PROPERTIES COMPILE_FLAGS -O0) + set_source_files_properties (${ARG} PROPERTIES COMPILE_FLAGS "-O0 -Wp,-U_FORTIFY_SOURCE") endforeach () endif () diff --git a/sample/strdup/CMakeLists.txt b/sample/strdup/CMakeLists.txt index f04bb9d..594700e 100644 --- a/sample/strdup/CMakeLists.txt +++ b/sample/strdup/CMakeLists.txt @@ -3,7 +3,7 @@ add_executable (strdup_test test.c) target_link_libraries (strdup_test strdup mimick) if (NOT MSVC) - set_source_files_properties (test.c PROPERTIES COMPILE_FLAGS -O0) + set_source_files_properties (test.c PROPERTIES COMPILE_FLAGS "-O0 -Wp,-U_FORTIFY_SOURCE") endif () add_mimick_sample (strdup_test)