Summary: | =sys-fs/udev-249-r2[static-libs] fails to compile with gcc -ftracer : ../systemd-249/src/basic/log.h:196:27: error: ‘%s’ directive argument is null [-Werror=format-overflow=] | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Torsten Kaiser <Storklerk> |
Component: | Current packages | Assignee: | Gentoo systemd Team <systemd> |
Status: | RESOLVED WONTFIX | ||
Severity: | normal | CC: | sam, toolchain |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
URL: | https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98444 | ||
See Also: | https://bugs.gentoo.org/show_bug.cgi?id=803338 | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Attachments: |
log from failed build
build.log with -O2 -ftracer build.log with gcc-11 floppym's build log with gcc-11.2.0 floppym's emerge --info sys-devel/gcc |
Description
Torsten Kaiser
2021-08-29 16:53:22 UTC
I am unable to reproduce this. Could you please see if it works with more conservative CFLAGS? Just -O2 -ftracer gets a different error: x86_64-pc-linux-gnu-gcc -Ilibudev.a.p -I. -I../systemd-249 -Isrc/basic -I../systemd-249/src/basic -Isrc/fundamental -I../systemd-249/src/fundamental -Isrc/systemd -I../systemd-249/src/systemd -I../systemd-249/src/libsystemd/sd-bus -I../systemd-249/src/libsystemd/sd-device -I../systemd-249/src/libsystemd/sd-event -I../systemd-249/src/libsystemd/sd-hwdb -I../systemd-249/src/libsystemd/sd-id128 -I../systemd-249/src/libsystemd/sd-journal -I../systemd-249/src/libsystemd/sd-netlink -I../systemd-249/src/libsystemd/sd-network -I../systemd-249/src/libsystemd/sd-resolve -Isrc/shared -I../systemd-249/src/shared -Isrc/libsystemd -I/usr/include/blkid -I/usr/include/libmount -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu99 -Wno-format-signedness -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-result -Wdate-time -Wendif-labels -Werror=format=2 -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=overflow -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=undef -Wfloat-equal -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-prototypes -Wsuggest-attribute=noreturn -Wwrite-strings -Werror=missing-declarations -Werror=missing-prototypes -fdiagnostics-show-option -ffast-math -fno-common -fno-strict-aliasing -fstack-protector -fstack-protector-strong -fvisibility=hidden --param=ssp-buffer-size=4 -ffunction-sections -fdata-sections -Werror=shadow -include config.h -pipe -march=skylake -O2 -ftracer -fPIC -pthread -MD -MQ libudev.a.p/src_shared_bpf-program.c.o -MF libudev.a.p/src_shared_bpf-program.c.o.d -o libudev.a.p/src_shared_bpf-program.c.o -c ../systemd-249/src/shared/bpf-program.c ../systemd-249/src/shared/bpf-program.c: In function ‘bpf_program_serialize_attachment’: ../systemd-249/src/shared/bpf-program.c:390:13: error: ‘%s’ directive argument is null [-Werror=format-overflow=] 390 | r = serialize_item_format( | ^~~~~~~~~~~~~~~~~~~~~~ 391 | f, | ~~ 392 | key, | ~~~~ 393 | "%i %s %s", | ~~~~~~~~~~~ 394 | copy, | ~~~~~ 395 | bpf_cgroup_attach_type_to_string(p->attached_type), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 396 | escaped); | ~~~~~~~~ cc1: some warnings being treated as errors Created attachment 736675 [details]
build.log with -O2 -ftracer
... I will continue to experiment with other flags.
Just removing -ftracer builds, CFLAGS="-pipe -march=skylake -O3 -fomit-frame-pointer -fweb -frename-registers" The errors seems to depends on something between -O2 and -O3. -O2 -ftracer: src/shared/bpf-program.c fails -O3 -ftracer: src/basic/virt.c fails ... but I would guess that the error is real, it just only becomes visible with this additional optimization. It could also be a bug in gcc-10.3.0. I tried using your CFLAGS with gcc-11.2.0, and was unable to reproduce the issue. Created attachment 736678 [details]
build.log with gcc-11
The original system is a stable amd64, so no gcc-11 yet. ;-)
But on another system gcc (Gentoo 11.2.0 p1) 11.2.0 also fails:
../systemd-249/src/shared/bpf-program.c: In function ‘bpf_program_serialize_attachment’:
../systemd-249/src/shared/bpf-program.c:390:13: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
390 | r = serialize_item_format(
| ^~~~~~~~~~~~~~~~~~~~~~
391 | f,
| ~~
392 | key,
| ~~~~
393 | "%i %s %s",
| ~~~~~~~~~~~
394 | copy,
| ~~~~~
395 | bpf_cgroup_attach_type_to_string(p->attached_type),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
396 | escaped);
| ~~~~~~~~
In function ‘bpf_program_serialize_attachment’,
inlined from ‘bpf_program_serialize_attachment_set’ at ../systemd-249/src/shared/bpf-program.c:417:21:
../systemd-249/src/shared/bpf-program.c:390:13: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
390 | r = serialize_item_format(
| ^~~~~~~~~~~~~~~~~~~~~~
391 | f,
| ~~
392 | key,
| ~~~~
393 | "%i %s %s",
| ~~~~~~~~~~~
394 | copy,
| ~~~~~
395 | bpf_cgroup_attach_type_to_string(p->attached_type),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
396 | escaped);
| ~~~~~~~~
cc1: some warnings being treated as errors
From the build.log:
C compiler for the host machine: x86_64-pc-linux-gnu-gcc -m32 (gcc 11.2.0 "x86_64-pc-linux-gnu-gcc (Gentoo 11.2.0 p1) 11.2.0")
C linker for the host machine: x86_64-pc-linux-gnu-gcc -m32 ld.bfd 2.37
... I will try more variations with gcc-11 later.
Possibly related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98444 gcc-11 also fails for me in a very similar way. thoregon ~ # gcc --version gcc (Gentoo 11.2.0 p1) 11.2.0 Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. (At the end of this comment is an idee wrt. reproducibility.) With -O2 -ftracer: FAILED: libudev.a.p/src_shared_bpf-program.c.o x86_64-pc-linux-gnu-gcc -m32 -Ilibudev.a.p -I. -I../systemd-249 -Isrc/basic -I../systemd-249/src/basic -Isrc/fundamental -I../systemd-249/src/fundamental -Isrc/systemd -I../systemd-249/src/systemd -I../systemd-249/src/libsystemd/sd-bus -I../systemd-249/src/libsystemd/sd-device -I../systemd-249/src/libsystemd/sd-event -I../systemd-249/src/libsystemd/sd-hwdb -I../systemd-249/src/libsystemd/sd-id128 -I../systemd-249/src/libsystemd/sd-journal -I../systemd-249/src/libsystemd/sd-netlink -I../systemd-249/src/libsystemd/sd-network -I../systemd-249/src/libsystemd/sd-resolve -Isrc/shared -I../systemd-249/src/shared -Isrc/libsystemd -I/usr/include/blkid -I/usr/include/libmount -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu99 -Wno-format-signedness -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-result -Wdate-time -Wendif-labels -Werror=format=2 -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=overflow -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=undef -Wfloat-equal -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-prototypes -Wsuggest-attribute=noreturn -Wwrite-strings -Werror=missing-declarations -Werror=missing-prototypes -fdiagnostics-show-option -ffast-math -fno-common -fno-strict-aliasing -fstack-protector -fstack-protector-strong -fvisibility=hidden --param=ssp-buffer-size=4 -ffunction-sections -fdata-sections -Werror=shadow -include config.h -O2 -ftracer -fPIC -pthread -MD -MQ libudev.a.p/src_shared_bpf-program.c.o -MF libudev.a.p/src_shared_bpf-program.c.o.d -o libudev.a.p/src_shared_bpf-program.c.o -c ../systemd-249/src/shared/bpf-program.c ../systemd-249/src/shared/bpf-program.c: In function ‘bpf_program_serialize_attachment’: ../systemd-249/src/shared/bpf-program.c:390:13: error: ‘%s’ directive argument is null [-Werror=format-overflow=] 390 | r = serialize_item_format( | ^~~~~~~~~~~~~~~~~~~~~~ 391 | f, | ~~ 392 | key, | ~~~~ 393 | "%i %s %s", | ~~~~~~~~~~~ 394 | copy, | ~~~~~ 395 | bpf_cgroup_attach_type_to_string(p->attached_type), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 396 | escaped); | ~~~~~~~~ cc1: some warnings being treated as errors With -O3 -ftracer: 2 errors (virt.c + bpf-program.c): FAILED: libudev.a.p/src_basic_virt.c.o x86_64-pc-linux-gnu-gcc -m32 -Ilibudev.a.p -I. -I../systemd-249 -Isrc/basic -I../systemd-249/src/basic -Isrc/fundamental -I../systemd-249/src/fundamental -Isrc/systemd -I../systemd-249/src/systemd -I../systemd-249/src/libsystemd/sd-bus -I../systemd-249/src/libsystemd/sd-device -I../systemd-249/src/libsystemd/sd-event -I../systemd-249/src/libsystemd/sd-hwdb -I../systemd-249/src/libsystemd/sd-id128 -I../systemd-249/src/libsystemd/sd-journal -I../systemd-249/src/libsystemd/sd-netlink -I../systemd-249/src/libsystemd/sd-network -I../systemd-249/src/libsystemd/sd-resolve -Isrc/shared -I../systemd-249/src/shared -Isrc/libsystemd -I/usr/include/blkid -I/usr/include/libmount -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu99 -Wno-format-signedness -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-result -Wdate-time -Wendif-labels -Werror=format=2 -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=overflow -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=undef -Wfloat-equal -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-prototypes -Wsuggest-attribute=noreturn -Wwrite-strings -Werror=missing-declarations -Werror=missing-prototypes -fdiagnostics-show-option -ffast-math -fno-common -fno-strict-aliasing -fstack-protector -fstack-protector-strong -fvisibility=hidden --param=ssp-buffer-size=4 -ffunction-sections -fdata-sections -Werror=shadow -include config.h -O3 -ftracer -fPIC -pthread -MD -MQ libudev.a.p/src_basic_virt.c.o -MF libudev.a.p/src_basic_virt.c.o.d -o libudev.a.p/src_basic_virt.c.o -c ../systemd-249/src/basic/virt.c In file included from ../systemd-249/src/basic/macro.h:485, from ../systemd-249/src/basic/alloc-util.h:9, from ../systemd-249/src/basic/virt.c:11: ../systemd-249/src/basic/virt.c: In function ‘detect_vm.part.0’: ../systemd-249/src/basic/log.h:196:27: error: ‘%s’ directive argument is null [-Werror=format-overflow=] 196 | ? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../systemd-249/src/basic/log.h:218:24: note: in expansion of macro ‘log_full_errno_zerook’ 218 | (void) log_full_errno_zerook(level, 0, fmt, ##__VA_ARGS__); \ | ^~~~~~~~~~~~~~~~~~~~~ ../systemd-249/src/basic/log.h:224:28: note: in expansion of macro ‘log_full’ 224 | #define log_debug(...) log_full(LOG_DEBUG, __VA_ARGS__) | ^~~~~~~~ ../systemd-249/src/basic/virt.c:501:9: note: in expansion of macro ‘log_debug’ 501 | log_debug("Found VM virtualization %s", virtualization_to_string(r)); | ^~~~~~~~~ ../systemd-249/src/basic/virt.c:501:44: note: format string is defined here 501 | log_debug("Found VM virtualization %s", virtualization_to_string(r)); | ^~ cc1: some warnings being treated as errors FAILED: libudev.a.p/src_shared_bpf-program.c.o x86_64-pc-linux-gnu-gcc -m32 -Ilibudev.a.p -I. -I../systemd-249 -Isrc/basic -I../systemd-249/src/basic -Isrc/fundamental -I../systemd-249/src/fundamental -Isrc/systemd -I../sys temd-249/src/systemd -I../systemd-249/src/libsystemd/sd-bus -I../systemd-249/src/libsystemd/sd-device -I../systemd-249/src/libsystemd/sd-event -I../systemd-249/src/libsystemd/s d-hwdb -I../systemd-249/src/libsystemd/sd-id128 -I../systemd-249/src/libsystemd/sd-journal -I../systemd-249/src/libsystemd/sd-netlink -I../systemd-249/src/libsystemd/sd-network -I../systemd-249/src/libsystemd/sd-resolve -Isrc/shared -I../systemd-249/src/shared -Isrc/libsystemd -I/usr/include/blkid -I/usr/include/libmount -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu99 -Wno-format-signedness -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-result -Wdate-time -Wendif-labels -Werror=format=2 -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=overflow -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=undef -Wfloat-equal -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-prototypes -Wsuggest-attribute=noreturn -Wwrite-strings -Werror=missing-declarations -Werror=missing-prototypes -fdiagnostics-show-option -ffast-math -fno-common -fno-strict-aliasing -fstack-protector -fstack-protector-strong -fvisibility=hidden --param=ssp-buffer-size=4 -ffunction-sections -fdata-sections -Werror=shadow -include config.h -O3 -ftracer -fPIC -pthread -MD -MQ libudev.a.p/src_shared_bpf-program.c.o -MF libudev.a.p/src_shared_bpf-program.c.o.d -o libudev.a.p/src_shared_bpf-program.c.o -c ../systemd-249/src/shared/bpf-program.c ../systemd-249/src/shared/bpf-program.c: In function ‘bpf_program_serialize_attachment’: ../systemd-249/src/shared/bpf-program.c:390:13: error: ‘%s’ directive argument is null [-Werror=format-overflow=] 390 | r = serialize_item_format( | ^~~~~~~~~~~~~~~~~~~~~~ 391 | f, | ~~ 392 | key, | ~~~~ 393 | "%i %s %s", | ~~~~~~~~~~~ 394 | copy, | ~~~~~ 395 | bpf_cgroup_attach_type_to_string(p->attached_type), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 396 | escaped); | ~~~~~~~~ In function ‘bpf_program_serialize_attachment’, inlined from ‘bpf_program_serialize_attachment_set’ at ../systemd-249/src/shared/bpf-program.c:417:21: ../systemd-249/src/shared/bpf-program.c:390:13: error: ‘%s’ directive argument is null [-Werror=format-overflow=] 390 | r = serialize_item_format( | ^~~~~~~~~~~~~~~~~~~~~~ 391 | f, | ~~ 392 | key, | ~~~~ 393 | "%i %s %s", | ~~~~~~~~~~~ 394 | copy, | ~~~~~ 395 | bpf_cgroup_attach_type_to_string(p->attached_type), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 396 | escaped); | ~~~~~~~~ cc1: some warnings being treated as errors An idee, why it might work on your system: -m32. I'm using a multilib system (just Gentoo's ABI_X86="32 64"), so udev will also get compiled as a 32bit version. And with less registers and other differences gcc might make other inlining decisions and that might trigger this. I was unable to reproduce the problem with gcc-11.2.0 and the following command. ABI_X86=32 CFLAGS="-pipe -march=skylake -O3 -fomit-frame-pointer -fweb -frename-registers -ftracer" ebuild udev-249-r2.ebuild clean compile Created attachment 736702 [details]
floppym's build log with gcc-11.2.0
Here's my build log for comparision.
Created attachment 736705 [details]
floppym's emerge --info sys-devel/gcc
I am unable to reproduce with gcc-10.3.0-r2 and the same ABI_X86 / CFLAGS. Perhaps your GCC has been built with different USE flags, is linked with some different libraries, or is buggy because it was built with aggressive optimizations. Adding toolchain in case they have any insight. It only happens with USE=static-libs (still testing with gcc-11). USE=-static-libs CFLAGS="-O2 -ftracer" ebuild udev-249-r2.ebuild clean compile -> no error USE=static-libs CFLAGS="-O2 -ftracer" ebuild udev-249-r2.ebuild clean compile -> systemd-249/src/shared/bpf-program.c:390:13: error: ‘%s’ directive argument is null [-Werror=format-overflow=] I tried to understand where the error in virt.c comes from, but I got stuck in virt.h: const char *virtualization_to_string(int v) _const_; Where does this function gets defined? "grep -r virtualization_to_string" only finds this prototype and users. I have a custom initramfs with a static cryptsetup, so I also need static-libs in udev. (In reply to Torsten Kaiser from comment #13) > I tried to understand where the error in virt.c comes from, but I got stuck > in virt.h: const char *virtualization_to_string(int v) _const_; > Where does this function gets defined? "grep -r virtualization_to_string" > only finds this prototype and users. At the bottom of virt.c, there is a macro call: DEFINE_STRING_TABLE_LOOKUP(virtualization, int); This macro is defined in src/basic/string-table.h. It defines the virtualization_to_string() and virtualization_from_string() functions (via several other macro calls). I can reproduce the issue with USE=static-libs CFLAGS="-O2 -ftracer". I would suggest reporting this issue upstream. Please be sure to provide the flags that get passed to meson and the CFLAGS that can be used to reproduce the issue. We no longer support static libs for udev. |