Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 810937 - =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=]
Summary: =sys-fs/udev-249-r2[static-libs] fails to compile with gcc -ftracer : ../syst...
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo systemd Team
URL: https://gcc.gnu.org/bugzilla/show_bug...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-29 16:53 UTC by Torsten Kaiser
Modified: 2023-09-18 01:23 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
log from failed build (build.log,842.35 KB, text/x-log)
2021-08-29 16:53 UTC, Torsten Kaiser
Details
build.log with -O2 -ftracer (build.log,851.34 KB, text/plain)
2021-08-29 17:30 UTC, Torsten Kaiser
Details
build.log with gcc-11 (build.log,833.73 KB, text/plain)
2021-08-29 18:10 UTC, Torsten Kaiser
Details
floppym's build log with gcc-11.2.0 (build.log.gz,37.38 KB, application/gzip)
2021-08-29 19:14 UTC, Mike Gilbert
Details
floppym's emerge --info sys-devel/gcc (emerge-info.txt,7.30 KB, text/plain)
2021-08-29 19:16 UTC, Mike Gilbert
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Torsten Kaiser 2021-08-29 16:53:22 UTC
Created attachment 736660 [details]
log from failed build

After the recent news about the end of eudev, I tried to switch to udev. But the compile failed with the following message:

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 -O3 -fomit-frame-pointer -fweb -frename-registers -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


emerge --info:
Portage 3.0.20 (python 3.9.6-final-0, default/linux/amd64/17.1/desktop/plasma, gcc-10.3.0, glibc-2.33-r1, 5.10.27-gentoo x86_64)
=================================================================
System uname: Linux-5.10.27-gentoo-x86_64-Intel-R-_Core-TM-_i5-6600_CPU_@_3.30GHz-with-glibc2.33
KiB Mem:    16284344 total,   2182864 free
KiB Swap:   33554364 total,  33550748 free
Timestamp of repository gentoo: Sun, 29 Aug 2021 16:30:01 +0000
Head commit of repository gentoo: 700dbede45a2affc636e593559eefd4e34acf4b7
sh bash 5.1_p8
ld GNU ld (Gentoo 2.36.1 p5) 2.36.1
app-shells/bash:          5.1_p8::gentoo
dev-java/java-config:     2.3.1::gentoo
dev-lang/perl:            5.34.0::gentoo
dev-lang/python:          2.7.18_p11::gentoo, 3.8.11::gentoo, 3.9.6_p1::gentoo
dev-lang/rust:            1.53.0::gentoo
dev-util/cmake:           3.20.5::gentoo
sys-apps/baselayout:      2.7::gentoo
sys-apps/openrc:          0.43.5::gentoo
sys-apps/sandbox:         2.24::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r5::gentoo
sys-devel/automake:       1.16.3-r1::gentoo
sys-devel/binutils:       2.36.1-r2::gentoo
sys-devel/gcc:            9.3.0-r2::gentoo, 10.3.0-r2::gentoo
sys-devel/gcc-config:     2.4::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.3::gentoo
sys-kernel/linux-headers: 5.10::gentoo (virtual/os-headers)
sys-libs/glibc:           2.33-r1::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-verify-metamanifest: yes
    sync-rsync-extra-opts: 
    sync-rsync-verify-jobs: 1
    sync-rsync-verify-max-age: 24

local
    location: /var/ebuilds
    masters: gentoo
    priority: 0

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-pipe -march=skylake -O3 -fomit-frame-pointer -fweb -frename-registers -ftracer"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /var/bind"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php7.4/ext-active/ /etc/php/cgi-php7.4/ext-active/ /etc/php/cli-php7.4/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-pipe -march=skylake -O3 -fomit-frame-pointer -fweb -frename-registers -ftracer"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--with-bdeps y --jobs=4 --load-average=6 --keep-going"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs buildpkg compressdebug config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch parallel-install pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="en_GB.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="de en"
MAKEOPTS="-j4"
PKGDIR="/var/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="7zip S3TC X a52 aac aalib ace acpi activities aff aften aio alisp alsa altenburgcards amarok amd64 amr amrnb amrr amrwb animgif ao ap apache2 apng aqua_theme archive async audacious audiofile autoipd avahi bash-completion bcel bcp bdf beagle bigpatch binfilter bittorrent bl blas blender-game bluetooth bonusscripts boost branding bzip2 c++ cairo calendar caps carbone_theme cblas-external cdda cdio cdparanoia cdr cgi chm chroot cifsupcall cisco classic cli client clucene cmdctrl cmdsubmenu compress connectionstatus conntrack consolekit contactnotes corefonts cpio cpufreq crypt cryptsetup cscope css ctype cups curl cutterlimit cutterqueue cuttime cvs cvsgraph cxx dar64 dbase dbm dbus dbx dc1394 dec_av2 declarative demo device-mapper dhcpcd divx djvu dlz dmi dmx dnotify doc domainkeys dot dpmod dri dts dv dvbplayer dvd dvdarchive dvdchapjump dvdr dvdread dvi ecc editor egl elf elogind emboss eme-free emoticon encode enscript equalizer evdev ewf excel exif exiv2 expat extensions extra extra-algorithms extra-cardsets extraengine extras farstream fat fbcon festival ffmpeg fftw file file-icons flac fluidsynth fmod font-server fontconfig fortran fping fpx ftp fts3 fuse g3dvl gbm gd gdbm gecko geoip gif gimp git gkrellm glamor gles gles1 gles2 glib glibc-omitfp glitz glsa glut gmedia gmp gopher gpac gpg gpgme gphoto2 gpm graphics graphviz gs gstreamer gtk gtk3 gudev gui gutenprint gzip harfbuzz hddtemp hdri highlight history html htmlhandbook http httpd hvm hwaccel hwdb ical iceweasel iconv icq icu id3 id3tag ide idea ieee1394 image imagemagick imap infowidget inherit-graph inkjar innodb inotify ipfilter ipsec iptc ipv6 irc irrlicht ithreads jabber jack jad jadetex java java-external java6 jce jemalloc jingle jit jni john jpeg jpeg2k juju jumpplay kde kdecards kdepim kdrive kerberos kexi kipi kmid kpathsea ktts kwallet latex lcms ldap legacy-systray libcaca libglvnd libkms libmpeg2 libnotify libsamplerate libsexy libssh2 libtirpc libvisual libwww liemikuutio lights livebuffer llvm logrotate logviewer loop-playback lua lucene lyx lzma lzo mad magic mail mailwrapper mainmenuhooks maps masquerade math matroska maya-shaderlibrary mbox mbrola md5sum mdev mdnsresponder-compat meanwhile menu-plugin menubar menuorg metric mhash mikmod mime mimencode minizip mixer mjpeg mmap mng modplug motif mounts-check mozdevelop mozdom mozilla mp2 mp3 mp4 mp4live mpd mpeg mpeg2 mpg123 mplayer mppe-mppc mpu401 mschap msn mtp multilib multiprocess musepack music mysql mysqli mythtv nagios-dns nagios-ntp nagios-ping nagios-ssh nat native-exceptions ncurses net netjack netlink netmeeting network network-cron networkmanager nfs nfsidmap nfsv4 nfsv41 nls nntp normalize nova nptl nsplugin nspr nss ntfs nuv objc odbc offensive ogg ogg123 ole openexr opengl openmp openssh openssl openvpn osmesa p2p pam pango pascal pcap pcre pcre16 pda pdf pdo perl php physfs pim pixmaps pkcs11 plasma player plotutils pmu png policykit posix postfix postproc postscript povray ppds pptp printsupport pth pulseaudio python qemu qml qt3support qt5 query-browser quicktime radio rar raw rc5 rdesktop readline realmedia remix replaygain restrict-javascript rle rpc rss rtc rtmp rtsp samba sasl sbig scanner screen screencast script scrypt sdk sdl sdl-image sdl-sound sdlaudio seamonkey search seccomp secure-delete semantic-desktop sensord server shared-dricore shorten shout sid signatures simplexml skins smime smp smtp sndfile sockets socks5 solver songs soprano sortrecords sound soundex sounds sox speech speedo speex spell split-usr sql sqlite sqlite3 ssl startup-notification stats stemmer stlport stream strongswan_plugins_aesni strongswan_plugins_gcm strongswan_plugins_rdrand submenu subtitles subversion suhosin svg svgz swat sylpheed sysfs syslog system-bootstrap system-cairo system-harfbuzz system-icu system-jpeg system-libevent system-libvncserver system-libvpx system-sqlite systray sysvipc szip t1lib taglib tagwriting tb4 tcpd teletext tetex tex texteffect textures tftp tga themes theora thesaurus threads threadsafe tidy tiff timercmd timerinfo tk tls toolbar tools tor-hardening tordns tracepath traceroute transcode trayicon truetype tta ttxtsubs twolame udev udisks ui unicode unlock-notify upower usb userfiles utils uudeview uuencode v4l v4l2 valgrind vamp vcd vcdx vdr video vim-syntax virgl visualization vlm vnc vncviewer voice volctrl vorbis vorbis-psy vpx wav wavpack wayland web webdav webinterface webkit widgets wifi winpopup wireshark wma wmf wmp wxwidgets x264 x265 xa xanim xattr xcb xcf xcomposite xephyr xetex xext xface xforms xfs xft xhtml xine xinerama xkb xml xmp xnest xorg xosd xplanet xpm xrandr xrender xscreensaver xsl xslt xv xvfb xvid xvmc xvnc yahoo yv12 zip zlib zrtp zvbi" ABI_X86="64" ADA_TARGET="gnat_2018" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" APACHE2_MPMS="worker" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev" KERNEL="linux" L10N="de en" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-3 php7-4" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_9" PYTHON_TARGETS="python3_8 python3_9" RUBY_TARGETS="ruby26" USERLAND="GNU" VIDEO_CARDS="dummy v4l virgl intel i965" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, LC_ALL, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RUSTFLAGS
Comment 1 Mike Gilbert gentoo-dev 2021-08-29 17:13:08 UTC
I am unable to reproduce this. Could you please see if it works with more conservative CFLAGS?
Comment 2 Torsten Kaiser 2021-08-29 17:28:11 UTC
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
Comment 3 Torsten Kaiser 2021-08-29 17:30:35 UTC
Created attachment 736675 [details]
build.log with -O2 -ftracer

... I will continue to experiment with other flags.
Comment 4 Torsten Kaiser 2021-08-29 17:41:21 UTC
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.
Comment 5 Mike Gilbert gentoo-dev 2021-08-29 17:46:09 UTC
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.
Comment 6 Torsten Kaiser 2021-08-29 18:10:35 UTC
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.
Comment 7 Tee KOBAYASHI 2021-08-29 18:47:04 UTC
Possibly related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98444
Comment 8 Torsten Kaiser 2021-08-29 18:54:19 UTC
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.
Comment 9 Mike Gilbert gentoo-dev 2021-08-29 19:03:59 UTC
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
Comment 10 Mike Gilbert gentoo-dev 2021-08-29 19:14:37 UTC
Created attachment 736702 [details]
floppym's build log with gcc-11.2.0

Here's my build log for comparision.
Comment 11 Mike Gilbert gentoo-dev 2021-08-29 19:16:31 UTC
Created attachment 736705 [details]
floppym's emerge --info sys-devel/gcc
Comment 12 Mike Gilbert gentoo-dev 2021-08-29 19:31:54 UTC
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.
Comment 13 Torsten Kaiser 2021-08-29 19:34:03 UTC
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.
Comment 14 Mike Gilbert gentoo-dev 2021-08-29 19:47:12 UTC
(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).
Comment 15 Mike Gilbert gentoo-dev 2021-08-29 19:53:11 UTC
I can reproduce the issue with USE=static-libs CFLAGS="-O2 -ftracer".
Comment 16 Mike Gilbert gentoo-dev 2021-08-29 19:57:21 UTC
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.
Comment 17 Mike Gilbert gentoo-dev 2023-09-18 01:23:25 UTC
We no longer support static libs for udev.