Hide Forgot
I'm working on bug 1298690, which requires to build NSS with the newer gcc compiler 5.3.1 included in devtoolset-4. I'm getting build failures: h_page.c: In function 'overflow_page': h_page.c:985:4: error: ignoring return value of 'fwrite', declared with attribute warn_unused_result [-Werror=unused-result] (void)fwrite(OVMSG, 1, sizeof(OVMSG) - 1, stderr); ^ h_page.c:1000:4: error: ignoring return value of 'fwrite', declared with attribute warn_unused_result [-Werror=unused-result] (void)fwrite(OVMSG, 1, sizeof(OVMSG) - 1, stderr); ^ h_page.c:1026:5: error: ignoring return value of 'fwrite', declared with attribute warn_unused_result [-Werror=unused-result] (void)fwrite(OVMSG, 1, sizeof(OVMSG) - 1, stderr); These are apparently caused by the following combination: - fwrite defined with __wur in /usr/include/stdio.h extern size_t fwrite (__const void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __s) __wur; - __wur defined as __attribute_warn_unused_result__ if __USE_FORTIFY_LEVEL > 2 - default XCFLAGS of RPM builds containing -D_FORTIFY_SOURCE=2
Who knows why RHEL 6 rpm builds enable these fortify features by default? Is it acceptable for RHEL 6 builds to override that and build without it? If not, are we reqiured to use downstream patches that add code that tricks the compiler into believing we're not ignoring the return values? Is there any simpler workaround?
You can use -Wno-error=unused-result, either globally, or for specific targets. In general, the assumption is that you do not build with -Werror.
(In reply to Florian Weimer from comment #2) > You can use -Wno-error=unused-result, either globally, or for specific > targets. > > In general, the assumption is that you do not build with -Werror. The upstream NSS sources have been changed to build with -Werror
Florian, thanks a lot for your help. That compiler option fixes the problem!
FWIW, those warnings can be found in the build.log for the regular RHEL-6 NSS build. So building with -Werror should break that build as well.