From 7713b8f94e7741b57e914f346d1d6f37270173da Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Thu, 14 Nov 2024 11:04:04 +0200 Subject: [PATCH] Always build with -fhardened if the compiler supports it This enables all manner of highly useful safety checks that we generally want enabled. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 923265171b..dfb0997d8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -421,8 +421,8 @@ if (ENABLE_ASAN OR ENABLE_UBSAN) add_compile_options(-fno-omit-frame-pointer) endif() -# try to ensure some compiler sanity -foreach (flag -fno-strict-overflow -fno-delete-null-pointer-checks) +# try to ensure some compiler sanity and hardening options where supported +foreach (flag -fno-strict-overflow -fno-delete-null-pointer-checks -fhardened) check_c_compiler_flag(${flag} found) if (found) add_compile_options(${flag})