summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-08-14 13:57:38 +0200
committerThomas Haller <thaller@redhat.com>2020-08-17 15:20:08 +0200
commit407a1f1e986c21f811d41c107bde4666f15f76f7 (patch)
tree56d0f8cd94f5e804e78fcd577401d8168e428586 /m4
parent00e3fc036addc281cc34b432bc7c4b06c7912f80 (diff)
downloadNetworkManager-407a1f1e986c21f811d41c107bde4666f15f76f7.tar.gz
build: disable "-Wstringop-overflow" warning with LTO enabled
No amount of _Pragma was able to disable this warning. In function ‘strncpy’, inlined from ‘_nm_strndup_a_step’ at ./shared/nm-glib-aux/nm-macros-internal.h:1367:3, inlined from ‘nms_keyfile_nmmeta_check_filename’ at src/settings/plugins/keyfile/nms-keyfile-utils.c:61:0: /usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=] 106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); | ^ src/settings/plugins/keyfile/nms-keyfile-utils.c: In function ‘nms_keyfile_nmmeta_check_filename’: src/settings/plugins/keyfile/nms-keyfile-utils.c:44: note: length computed here 44 | len = strlen (filename); | lto1: all warnings being treated as errors Oddly enough, gcc is still emitting the warning even with "-Wno-stringop-overflow", but at least it doesn't break the build.
Diffstat (limited to 'm4')
-rw-r--r--m4/compiler_options.m49
1 files changed, 9 insertions, 0 deletions
diff --git a/m4/compiler_options.m4 b/m4/compiler_options.m4
index 9adc1f14c3..d390a90cf0 100644
--- a/m4/compiler_options.m4
+++ b/m4/compiler_options.m4
@@ -60,11 +60,20 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
CFLAGS_MORE_WARNINGS="-Wall"
+ if test "x$enable_lto" = xyes; then
+ dnl With LTO and optimizations enabled, gcc 10.2.1-1.fc32 is really
+ dnl adamant to warn about correct uses of strncpy. Disable that warning.
+ _CFLAGS_MORE_WARNINGS_DISABLE_LTO="-Wno-stringop-overflow"
+ else
+ _CFLAGS_MORE_WARNINGS_DISABLE_LTO=
+ fi
+
if test "x$set_more_warnings" = xerror; then
CFLAGS_MORE_WARNINGS="$CFLAGS_MORE_WARNINGS -Werror"
fi
for option in \
+ $_CFLAGS_MORE_WARNINGS_DISABLE_LTO \
-Wextra \
-Wdeclaration-after-statement \
-Wfloat-equal \