openwrt / packages

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

libsoup: Fails to build with fortify source due to `-Werror=format-nonliteral`; [PATCH] `PKG_FORTIFY_SOURCE:=0` makes it build; in 22.03. #19016

Open dreirund opened 2 years ago

dreirund commented 2 years ago

Maintainer:

@flyn-org

Environment:

Description:

make -j6 fails in above configuration on package/feeds/packages/libsoup.
An explicit run of
make -j1 V=sc package/feeds/packages/libsoup/compile
fails in ./configure with
FAILED: libsoup/libsoup-2.4.so.1.11.2.p/soup-auth-ntlm.c.o
and
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]

This error could be mitigated by adding
PKG_FORTIFY_SOURCE:=0
to
package/feeds/packages/libsoup/Makefile.

→ Patch:

--- Makefile.org    2022-07-22 15:51:16.858835397 +0200
+++ Makefile    2022-07-22 15:52:58.328832223 +0200
@@ -20,2 +20,3 @@

+PKG_FORTIFY_SOURCE:=0
 PKG_BUILD_DEPENDS:=glib2/host

Feel free to use that patch or your own way to incorporate that fix.
Or, which I suspect would be the more clean way, not regard the warning as error? (-Wno-error=format-nonliteral somewhere?)

More context of the output of the above failing make run:

[...]
ninja: Entering directory `/[...]/openwrt-22.03/build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/libsoup-2.74.2/openwrt-build'
[1/144] ccache_cc -Ilibsoup/libsoup-2.4.so.1.11.2.p -Ilibsoup -I../libsoup -I. -I.. -I/[...]/openwrt-22.03/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/usr/include/glib-2.0 -I/[...]/openwrt-22.03/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/usr/lib/glib-2.0/include -I/[...]/openwrt-22.03/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/usr/include -I/[...]/openwrt-22.03/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/usr/include/libxml2 -I/[...]/openwrt-22.03/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/usr/lib/libiconv-stub/include -I/[...]/openwrt-22.03/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/usr/lib/libintl-stub/include -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 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c99 -D_DEFAULT_SOURCE -DHAVE_CONFIG_H -Wall -Wmissing-include-dirs -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=aggregate-return -Werror=format=2 -Wstrict-prototypes -Wno-format-zero-length -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/libsoup-2.74.2=libsoup-2.74.2 -DPIC -fpic -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -fPIC -pthread '-DG_LOG_DOMAIN="libsoup"' -DLIBSOUP_COMPILATION -fvisibility=hidden -MD -MQ libsoup/libsoup-2.4.so.1.11.2.p/soup-auth-ntlm.c.o -MF libsoup/libsoup-2.4.so.1.11.2.p/soup-auth-ntlm.c.o.d -o libsoup/libsoup-2.4.so.1.11.2.p/soup-auth-ntlm.c.o -c ../libsoup/soup-auth-ntlm.c
FAILED: libsoup/libsoup-2.4.so.1.11.2.p/soup-auth-ntlm.c.o 
ccache_cc -Ilibsoup/libsoup-2.4.so.1.11.2.p -Ilibsoup -I../libsoup -I. -I.. -I/[...]/openwrt-22.03/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/usr/include/glib-2.0 -I/[...]/openwrt-22.03/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/usr/lib/glib-2.0/include -I/[...]/openwrt-22.03/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/usr/include -I/[...]/openwrt-22.03/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/usr/include/libxml2 -I/[...]/openwrt-22.03/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/usr/lib/libiconv-stub/include -I/[...]/openwrt-22.03/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/usr/lib/libintl-stub/include -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 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c99 -D_DEFAULT_SOURCE -DHAVE_CONFIG_H -Wall -Wmissing-include-dirs -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=aggregate-return -Werror=format=2 -Wstrict-prototypes -Wno-format-zero-length -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/libsoup-2.74.2=libsoup-2.74.2 -DPIC -fpic -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -fPIC -pthread '-DG_LOG_DOMAIN="libsoup"' -DLIBSOUP_COMPILATION -fvisibility=hidden -MD -MQ libsoup/libsoup-2.4.so.1.11.2.p/soup-auth-ntlm.c.o -MF libsoup/libsoup-2.4.so.1.11.2.p/soup-auth-ntlm.c.o.d -o libsoup/libsoup-2.4.so.1.11.2.p/soup-auth-ntlm.c.o -c ../libsoup/soup-auth-ntlm.c
cc1: warning: /[...]/openwrt-22.03/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/usr/lib/libintl-stub/include: No such file or directory [-Wmissing-include-dirs]
In file included from ../libsoup/soup-auth-ntlm.c:15:
/[...]/openwrt-22.03/staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-11.2.0_musl_eabi/include/fortify/stdio.h: In function 'snprintf':
/[...]/openwrt-22.03/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());
      |         ^~~~~~
/[...]/openwrt-22.03/staging_dir/toolchain-arm_cortex-a7+neon-vfpv4_gcc-11.2.0_musl_eabi/include/fortify/stdio.h: In function 'sprintf':
/[...]/openwrt-22.03/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());
      |                 ^~~
/[...]/openwrt-22.03/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());
      |                 ^~~
../libsoup/soup-auth-ntlm.c: In function 'soup_ntlm_parse_challenge':
../libsoup/soup-auth-ntlm.c:757:17: warning: 'g_memdup' is deprecated: Use 'g_memdup2' instead [-Wdeprecated-declarations]
  757 |                 *nonce = g_memdup (chall + NTLM_CHALLENGE_NONCE_OFFSET,
      |                 ^
In file included from /[...]/openwrt-22.03/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/usr/include/glib-2.0/glib.h:82,
                 from ../libsoup/soup-auth-ntlm.c:17:
/[...]/openwrt-22.03/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/usr/include/glib-2.0/glib/gstrfuncs.h:257:23: note: declared here
  257 | gpointer              g_memdup         (gconstpointer mem,
      |                       ^~~~~~~~
../libsoup/soup-auth-ntlm.c:770:17: warning: 'g_memdup' is deprecated: Use 'g_memdup2' instead [-Wdeprecated-declarations]
  770 |                 *target_info = g_memdup (chall + target.offset, target.length);
      |                 ^
In file included from /[...]/openwrt-22.03/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/usr/include/glib-2.0/glib.h:82,
                 from ../libsoup/soup-auth-ntlm.c:17:
/[...]/openwrt-22.03/staging_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/usr/include/glib-2.0/glib/gstrfuncs.h:257:23: note: declared here
  257 | gpointer              g_memdup         (gconstpointer mem,
      |                       ^~~~~~~~
../libsoup/soup-auth-ntlm.c: At top level:
../libsoup/soup-auth-ntlm.c:1340:39: warning: argument 2 of type 'unsigned char[8]' with mismatched bound [-Warray-parameter=]
 1340 | des (guint32 ks[16][2], unsigned char block[8])
      |                         ~~~~~~~~~~~~~~^~~~~~~~
../libsoup/soup-auth-ntlm.c:604:44: note: previously declared as 'unsigned char *'
  604 | static void des                   (DES_KS, unsigned char *);
      |                                            ^~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed.
make[2]: *** [Makefile:79: /[...]/openwrt-22.03/build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/libsoup-2.74.2/.built] Error 1
make[2]: Leaving directory '/[...]/openwrt-22.03/feeds/packages/libs/libsoup'
time: package/feeds/packages/libsoup/compile#2.13#0.30#5.09
    ERROR: package/feeds/packages/libsoup failed to build.
[...]

Full make output: → libsoup.compile.log.

dreirund commented 2 years ago

Should be fixed by #19245.

flyn-org commented 2 years ago

Is it musl code (stdio.h) that is triggering these compiler errors? That sounds like a mismatch between GCC and musl, not a problem with libsoup. I would like to avoid disabling compiler protections.

dreirund commented 2 years ago

@flyn-org wrote:

Is it musl code (stdio.h) that is triggering these compiler errors? That sounds like a mismatch between GCC and musl, not a problem with libsoup.

I have no idea, I don't know almost anything about linking and compilers and such stuff.

I have seen those errors also on a few other packages.