openwrt / packages

Community maintained packages for OpenWrt. Documentation for submitting pull requests is in CONTRIBUTING.md
GNU General Public License v2.0
3.93k stars 3.44k forks source link

nfs-kernel-server: Fails to build with fortify source due to `-Werror=format-nonliteral`; [FIX] workaround is `PKG_FORTIFY_SOURCE:=0`, in 22.03. #19004

Open dreirund opened 2 years ago

dreirund commented 2 years ago

Maintainer:

@tripolar

Environment:

Description:

After a make clean, a make -j6 fails in above configuration on package/feeds/packages/nfs-kernel-server when fortify source is selected. An explicit run of
make -j1 V=sc package/feeds/packages/nfs-kernel-server/compile
fails with staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-11.2.0_musl_eabi/include/fortify/stdio.h:101:9: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]:

[...]
ccache_cc -DHAVE_CONFIG_H -I. -I../../support/include  -I/[...]/openwrt-22.03/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/usr/include/tirpc  -I/[...]/openwrt-22.03/staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-11.2.0_musl_eabi/usr/include -I/[...]/openwrt-22.03/staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-11.2.0_musl_eabi/include/fortify -I/[...]/openwrt-22.03/staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-11.2.0_musl_eabi/include  -pipe  -Wall  -Wextra  -Wstrict-prototypes  -Werror=missing-prototypes  -Werror=missing-declarations  -Werror=format=2  -Werror=undef  -Werror=missing-include-dirs  -Werror=strict-aliasing=2  -Werror=init-self  -Werror=implicit-function-declaration  -Werror=return-type  -Werror=switch  -Werror=overflow  -Werror=parentheses  -Werror=aggregate-return  -Werror=unused-result  -fno-strict-aliasing  -Werror=format-overflow=2 -Werror=int-conversion -Werror=incompatible-pointer-types -Werror=misleading-indentation -Wno-cast-function-type -O3 -pipe -g0 -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -mfloat-abi=hard -ffile-prefix-map=/[...]/openwrt-22.03/build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/nfs-utils-2.5.4=nfs-utils-2.5.4 -DPIC -fpic -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -Wno-error=implicit-function-declaration -Wno-error=strict-prototypes -Wno-error=incompatible-pointer-types -Wno-error=format-security -Wno-error=undef -Wno-error=missing-include-dirs  -MT client.o -MD -MP -MF .deps/client.Tpo -c -o client.o client.c
In file included from ../../support/include/sockaddr.h:27,
                 from client.c:22:
../../../../../staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-11.2.0_musl_eabi/include/fortify/stdio.h: In function 'snprintf':
../../../../../staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-11.2.0_musl_eabi/include/fortify/stdio.h:101:9: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
  101 |         return __orig_snprintf(__s, __n, __f, __builtin_va_arg_pack());
      |         ^~~~~~
../../../../../staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-11.2.0_musl_eabi/include/fortify/stdio.h: In function 'sprintf':
../../../../../staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-11.2.0_musl_eabi/include/fortify/stdio.h:110:17: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
  110 |                 __r = __orig_snprintf(__s, __b, __f, __builtin_va_arg_pack());
      |                 ^~~
../../../../../staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-11.2.0_musl_eabi/include/fortify/stdio.h:114:17: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
  114 |                 __r = __orig_sprintf(__s, __f, __builtin_va_arg_pack());
      |                 ^~~
cc1: some warnings being treated as errors
make[6]: *** [Makefile:476: client.o] Error 1
make[6]: Leaving directory '/[...]/openwrt-22.03/build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/nfs-utils-2.5.4/support/export'
make[5]: *** [Makefile:409: all] Error 2
make[5]: Leaving directory '/[...]/openwrt-22.03/build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/nfs-utils-2.5.4/support/export'
make[4]: *** [Makefile:435: all-recursive] Error 1
make[4]: Leaving directory '/[...]/openwrt-22.03/build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/nfs-utils-2.5.4/support'
make[3]: *** [Makefile:474: all-recursive] Error 1
make[3]: Leaving directory '/[...]/openwrt-22.03/build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/nfs-utils-2.5.4'
make[2]: *** [Makefile:210: /[...]/openwrt-22.03/build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/nfs-utils-2.5.4/.built] Error 2
make[2]: Leaving directory '/[...]/openwrt-22.03/feeds/packages/net/nfs-kernel-server'
time: package/feeds/packages/nfs-kernel-server/compile#1.22#0.27#10.44
    ERROR: package/feeds/packages/nfs-kernel-server failed to build.
[...]

Inspired by issue #18884 I tried to add PKG_FORTIFY_SOURCE:=0 to package/feeds/packages/nfs-kernel-server/Makefile, and having done so nfs-kernel-server builds. Patch.

I think the cleaner solution would be to switch off that the warning triggers an error, but I don't know how to do that specifically for that package.

dreirund commented 2 years ago

Should be fixed by #19245.