From d334fafe25f7cca5e5c6e5c89ab5f01e5111f9a7 Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Thu, 10 Nov 2022 21:41:37 +0000 Subject: [PATCH 1/2] Fix #2205, Enforce strict cast alignment on arch --- cmake/sample_defs/arch_build_custom.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/sample_defs/arch_build_custom.cmake b/cmake/sample_defs/arch_build_custom.cmake index a7ebb1a6b..11a73d3cb 100644 --- a/cmake/sample_defs/arch_build_custom.cmake +++ b/cmake/sample_defs/arch_build_custom.cmake @@ -32,7 +32,7 @@ add_compile_options( -Wstrict-prototypes # Warn about missing prototypes -Wwrite-strings # Warn if not treating string literals as "const" -Wpointer-arith # Warn about suspicious pointer operations - -Wcast-align # Warn about casts that increase alignment requirements + -Wcast-align=strict # Warn about casts that increase alignment requirements -Werror # Treat warnings as errors (code should be clean) -Wno-format-truncation # Inhibit printf-style format truncation warnings -Wno-stringop-truncation # Inhibit string operation truncation warnings From b84dfbbdfcaebcc6f47ff1799a66a2122efe564a Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 23 Nov 2022 12:52:17 -0500 Subject: [PATCH 2/2] Hotfix #2205, apply strict cast-align to native builds only The -Wcast-align=strict option only works with certain versions of gcc. This moves it to the "native" custom options, so it will not be used on cross builds. --- cmake/sample_defs/arch_build_custom.cmake | 1 - cmake/sample_defs/arch_build_custom_native.cmake | 11 +++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 cmake/sample_defs/arch_build_custom_native.cmake diff --git a/cmake/sample_defs/arch_build_custom.cmake b/cmake/sample_defs/arch_build_custom.cmake index 11a73d3cb..194ec5b80 100644 --- a/cmake/sample_defs/arch_build_custom.cmake +++ b/cmake/sample_defs/arch_build_custom.cmake @@ -32,7 +32,6 @@ add_compile_options( -Wstrict-prototypes # Warn about missing prototypes -Wwrite-strings # Warn if not treating string literals as "const" -Wpointer-arith # Warn about suspicious pointer operations - -Wcast-align=strict # Warn about casts that increase alignment requirements -Werror # Treat warnings as errors (code should be clean) -Wno-format-truncation # Inhibit printf-style format truncation warnings -Wno-stringop-truncation # Inhibit string operation truncation warnings diff --git a/cmake/sample_defs/arch_build_custom_native.cmake b/cmake/sample_defs/arch_build_custom_native.cmake new file mode 100644 index 000000000..89c069d4b --- /dev/null +++ b/cmake/sample_defs/arch_build_custom_native.cmake @@ -0,0 +1,11 @@ +# +# Example arch_build_custom.cmake +# ------------------------------- +# +# On native builds only, add strict cast alignment warnings +# This requires a newer version of gcc +# +add_compile_options( + -Wcast-align=strict # Warn about casts that increase alignment requirements +) +