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.

(cherry picked from commit 407a1f1e98)
This commit is contained in:
Thomas Haller 2020-08-14 13:57:38 +02:00
parent 6f82699ef7
commit aabbd0e8de
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -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 \