From ba09a7c5d919ea1ade1c103a98fda1bfdd7a2f7c Mon Sep 17 00:00:00 2001 From: Steven Bellock Date: Wed, 6 Mar 2024 09:37:37 -0800 Subject: [PATCH] Make x86 flags conditional Fix #337. Signed-off-by: Steven Bellock --- CMakeLists.txt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a505b4e7..3acf698c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,10 +156,17 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux") if(TOOLCHAIN STREQUAL "GCC") SET(CMAKE_C_COMPILER gcc) - ADD_COMPILE_OPTIONS(-std=c99 -g -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -ffunction-sections -fdata-sections -fno-common -maccumulate-outgoing-args -mno-red-zone -Wno-address -fpie -fno-asynchronous-unwind-tables -flto -DUSING_LTO -Wno-maybe-uninitialized -Wno-uninitialized -Wno-builtin-declaration-mismatch -Wno-nonnull-compare) + ADD_COMPILE_OPTIONS(-std=c99 -g -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -ffunction-sections -fdata-sections -fno-common -Wno-address -fpie -fno-asynchronous-unwind-tables -flto -DUSING_LTO -Wno-maybe-uninitialized -Wno-uninitialized -Wno-builtin-declaration-mismatch -Wno-nonnull-compare) if(GCOV STREQUAL "ON") ADD_COMPILE_OPTIONS(--coverage -fprofile-arcs -ftest-coverage) endif() + if (ARCH STREQUAL "x64") + ADD_COMPILE_OPTIONS(-mno-red-zone) + endif() + if (ARCH STREQUAL "x64" OR "ia32") + ADD_COMPILE_OPTIONS(-maccumulate-outgoing-args) + endif() + SET(MBEDTLS_FLAGS "") SET(OPENSSL_FLAGS -include base.h -Wno-error=maybe-uninitialized -Wno-error=format -Wno-format -Wno-error=unused-but-set-variable) SET(CMOCKA_FLAGS -std=gnu99 -Wpedantic -Wall -Wshadow -Wmissing-prototypes -Wcast-align -Werror=address -Wstrict-prototypes -Werror=strict-prototypes -Wwrite-strings -Werror=write-strings -Werror-implicit-function-declaration -Wpointer-arith -Werror=pointer-arith -Wdeclaration-after-statement -Werror=declaration-after-statement -Wreturn-type -Werror=return-type -Wuninitialized -Werror=uninitialized -Werror=strict-overflow -Wstrict-overflow=2 -Wno-format-zero-length -Wmissing-field-initializers -Wformat-security -Werror=format-security -fno-common -Wformat -fno-common -fstack-protector-strong) @@ -315,10 +322,13 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux") SET(CMAKE_C_LINK_EXECUTABLE " -o -Wl,--start-group -Wl,--end-group") - elseif(TOOLCHAIN STREQUAL "CLANG") SET(CMAKE_C_COMPILER clang) ADD_COMPILE_OPTIONS(-g -fshort-wchar -fno-strict-aliasing -Wall -Wno-array-bounds -ffunction-sections -fdata-sections -fno-common -mno-red-zone -Wno-address -fpie -fno-asynchronous-unwind-tables -flto -DUSING_LTO) + if (ARCH STREQUAL "x64") + ADD_COMPILE_OPTIONS(-mno-red-zone) + endif() + SET(MBEDTLS_FLAGS "") SET(OPENSSL_FLAGS -include base.h -Wno-error=maybe-uninitialized -Wno-error=format -Wno-format -Wno-error=unused-but-set-variable) SET(CMOCKA_FLAGS -std=gnu99 -Wpedantic -Wall -Wshadow -Wmissing-prototypes -Wcast-align -Werror=address -Wstrict-prototypes -Werror=strict-prototypes -Wwrite-strings -Werror=write-strings -Werror-implicit-function-declaration -Wpointer-arith -Werror=pointer-arith -Wdeclaration-after-statement -Werror=declaration-after-statement -Wreturn-type -Werror=return-type -Wuninitialized -Werror=uninitialized -Werror=strict-overflow -Wstrict-overflow=2 -Wno-format-zero-length -Wmissing-field-initializers -Wformat-security -Werror=format-security -fno-common -Wformat -fno-common -fstack-protector-strong)