Skip to contentSkip to conversation

systemd: Fix build with gcc9

PATCH In review Khem Raj 3 participants 6 messages May 6, 2019 – May 14, 2019

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/2 systemd: Fix build with gcc9

gcc9 throws additional warnings about format string overflow

---
 ...-format-overflow-warnings-with-gcc-9.patch | 41 +++++++++++++++++++
 meta/recipes-core/systemd/systemd_242.bb      |  1 +
 2 files changed, 42 insertions(+)
 create mode 100644 meta/recipes-core/systemd/systemd/0006-Fix-format-overflow-warnings-with-gcc-9.patch
meta/recipes-core/systemd/systemd/0006-Fix-format-overflow-warnings-with-gcc-9.patch new file +41 -0
new file mode 100644
index 0000000000..510ac22150
@@ -0,0 +1,41 @@
+From c8050da8b7b0e59e4d1d0e15a92b9ecad299dbbb Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Mon, 6 May 2019 10:41:15 -0700
+Subject: [PATCH] Fix format-overflow warnings with gcc-9
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+gcc-9 has become a bit stricter and can check all kind of formatted
+input/output functions which causes additional warnings when compiling
+networkd
+
+/src/basic/log.h:104:9: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
+         log_internal_realm(LOG_REALM_PLUS_LEVEL(LOG_REALM, (level)), __VA_ARGS__)
+
+see https://github.com/systemd/systemd/issues/12454
+
+Upstream-Status: Pending
+
+Signed-off-by: Khem Raj <[email protected]>
+---
+ src/network/networkd-link.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
+index 533193ac93..976cbbeaaa 100644
+--- a/src/network/networkd-link.c
++++ b/src/network/networkd-link.c
+@@ -339,7 +339,8 @@ static int link_enable_ipv6(Link *link) {
+         r = sysctl_write_ip_property_boolean(AF_INET6, link->ifname, "disable_ipv6", disabled);
+         if (r < 0)
+                 log_link_warning_errno(link, r, "Cannot %s IPv6 for interface %s: %m",
+-                                       enable_disable(!disabled), link->ifname);
++                                       enable_disable(!disabled),
++                                       (link->ifname) ? link->ifname : "<null>");
+         else
+                 log_link_info(link, "IPv6 successfully %sd", enable_disable(!disabled));
+ 
+-- 
+2.21.0
+
meta/recipes-core/systemd/systemd_242.bb +1 -0
index a6b39d57e8..93c4472bab 100644
@@ -22,6 +22,7 @@ SRC_URI += "file://touchscreen.rules \
            file://0003-implment-systemd-sysv-install-for-OE.patch \
            file://0004-rules-whitelist-hd-devices.patch \
            file://0005-rules-watch-metadata-changes-in-ide-devices.patch \
+           file://0006-Fix-format-overflow-warnings-with-gcc-9.patch \
            file://99-default.preset \
            "
 
Signature · 1 line
2.21.0
author
#1 lore raw

PATCH 2/2 gcc-target: Do not set --with-sysroot and gxx-include-dir paths

These options are not needed on target infact since the defaults would be good enough for compiler to find the relevant headers and libraries from compiler runtime

with gcc9 it starts to strip the sysroot from gxx-include-dir which means it tries to look for gxx headers in localdir

ignoring nonexistent directory "usr/include/c++/9.0.1"
ignoring nonexistent directory "usr/include/c++/9.0.1/arm-yoe-linux-gnueabi" ignoring nonexistent directory "usr/include/c++/9.0.1/backward"

instead of sysroot

Removing these options make it behave normal

---
 meta/recipes-devtools/gcc/gcc-target.inc | 2 --
 1 file changed, 2 deletions(-)
meta/recipes-devtools/gcc/gcc-target.inc +0 -2
index 6270059644..bdc6ff658f 100644
@@ -2,9 +2,7 @@ GCCMULTILIB = "--enable-multilib"
 require gcc-configure-common.inc
 
 EXTRA_OECONF_PATHS = "\
-    --with-sysroot=/ \
     --with-build-sysroot=${STAGING_DIR_TARGET} \
-    --with-gxx-include-dir=${includedir}/c++/${BINV} \
 "
 
 EXTRA_OECONF_append_linuxstdbase = " --enable-clocale=gnu"
Signature · 1 line
2.21.0
#2 lore raw
In reply to Khem Raj
Quoted 4 lines · Khem Raj

...

meta/recipes-core/systemd/systemd/0006-Fix-format-overflow-warnings-with-gcc-9.patch new file +3 -0
+gcc-9 has become a bit stricter and can check all kind of formatted
+input/output functions which causes additional warnings when compiling
+networkd

meta/recipes-core/systemd/systemd/0006-Fix-format-overflow-warnings-with-gcc-9.patch line 35

Quoted 10 lines
meta/recipes-core/systemd/systemd/0006-Fix-format-overflow-warnings-with-gcc-9.patch new file +8 -0
+
+/src/basic/log.h:104:9: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
+         log_internal_realm(LOG_REALM_PLUS_LEVEL(LOG_REALM, (level)), __VA_ARGS__)
...
+         if (r < 0)
+                 log_link_warning_errno(link, r, "Cannot %s IPv6 for interface %s: %m",
+-                                       enable_disable(!disabled), link->ifname);
++                                       enable_disable(!disabled),
++                                       (link->ifname) ? link->ifname : "<null>");
...

The fix doesn't look correct to me:
gcc says it "is null", so checking whether or not it is null doesn't match the error message.

If it is a compiler bug as was at some point mentioned upstream, a better temporary workaround would be to stop making this an error with -Wno-error=format-overflow (untested).

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#3 lore raw

https://github.com/systemd/systemd/commit/c98b3545008d8e984ab456dcf79787418fcbfe13
is the upstream fix, so lets use this instead.

Ross

Quoted 40 lines · Adrian Bunk
Quoted 4 lines · Khem Raj

...

meta/recipes-core/systemd/systemd/0006-Fix-format-overflow-warnings-with-gcc-9.patch new file +3 -0
+gcc-9 has become a bit stricter and can check all kind of formatted
+input/output functions which causes additional warnings when compiling
+networkd

meta/recipes-core/systemd/systemd/0006-Fix-format-overflow-warnings-with-gcc-9.patch line 35

Quoted 10 lines
meta/recipes-core/systemd/systemd/0006-Fix-format-overflow-warnings-with-gcc-9.patch new file +8 -0
+
+/src/basic/log.h:104:9: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
+         log_internal_realm(LOG_REALM_PLUS_LEVEL(LOG_REALM, (level)), __VA_ARGS__)
...
+         if (r < 0)
+                 log_link_warning_errno(link, r, "Cannot %s IPv6 for interface %s: %m",
+-                                       enable_disable(!disabled), link->ifname);
++                                       enable_disable(!disabled),
++                                       (link->ifname) ? link->ifname : "<null>");
...

The fix doesn't look correct to me:
gcc says it "is null", so checking whether or not it is null doesn't match the error message.

If it is a compiler bug as was at some point mentioned upstream, a better temporary workaround would be to stop making this an error with -Wno-error=format-overflow (untested).

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

author
#4 lore raw

you are late to party but its already applied see oe-core/d5e999616e

Quoted 47 lines · Ross

https://github.com/systemd/systemd/commit/c98b3545008d8e984ab456dcf79787418fcbfe13
is the upstream fix, so lets use this instead.

Ross

Quoted 40 lines · Adrian Bunk
Quoted 4 lines · Khem Raj

...

meta/recipes-core/systemd/systemd/0006-Fix-format-overflow-warnings-with-gcc-9.patch new file +3 -0
+gcc-9 has become a bit stricter and can check all kind of formatted
+input/output functions which causes additional warnings when compiling
+networkd

meta/recipes-core/systemd/systemd/0006-Fix-format-overflow-warnings-with-gcc-9.patch line 35

Quoted 10 lines
meta/recipes-core/systemd/systemd/0006-Fix-format-overflow-warnings-with-gcc-9.patch new file +8 -0
+
+/src/basic/log.h:104:9: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
+         log_internal_realm(LOG_REALM_PLUS_LEVEL(LOG_REALM, (level)), __VA_ARGS__)
...
+         if (r < 0)
+                 log_link_warning_errno(link, r, "Cannot %s IPv6 for interface %s: %m",
+-                                       enable_disable(!disabled), link->ifname);
++                                       enable_disable(!disabled),
++                                       (link->ifname) ? link->ifname : "<null>");
...

The fix doesn't look correct to me:
gcc says it "is null", so checking whether or not it is null doesn't match the error message.

If it is a compiler bug as was at some point mentioned upstream, a better temporary workaround would be to stop making this an error with -Wno-error=format-overflow (untested).

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#5 lore raw

Huh I checked git too. Obviously not well enough!

Quoted 51 lines · Khem Raj

you are late to party but its already applied see oe-core/d5e999616e

Quoted 47 lines · Ross

https://github.com/systemd/systemd/commit/c98b3545008d8e984ab456dcf79787418fcbfe13
is the upstream fix, so lets use this instead.

Ross

Quoted 40 lines · Adrian Bunk
Quoted 4 lines · Khem Raj

...

meta/recipes-core/systemd/systemd/0006-Fix-format-overflow-warnings-with-gcc-9.patch new file +3 -0
+gcc-9 has become a bit stricter and can check all kind of formatted
+input/output functions which causes additional warnings when compiling
+networkd

meta/recipes-core/systemd/systemd/0006-Fix-format-overflow-warnings-with-gcc-9.patch line 35

Quoted 10 lines
meta/recipes-core/systemd/systemd/0006-Fix-format-overflow-warnings-with-gcc-9.patch new file +8 -0
+
+/src/basic/log.h:104:9: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
+         log_internal_realm(LOG_REALM_PLUS_LEVEL(LOG_REALM, (level)), __VA_ARGS__)
...
+         if (r < 0)
+                 log_link_warning_errno(link, r, "Cannot %s IPv6 for interface %s: %m",
+-                                       enable_disable(!disabled), link->ifname);
++                                       enable_disable(!disabled),
++                                       (link->ifname) ? link->ifname : "<null>");
...

The fix doesn't look correct to me:
gcc says it "is null", so checking whether or not it is null doesn't match the error message.

If it is a compiler bug as was at some point mentioned upstream, a better temporary workaround would be to stop making this an error with -Wno-error=format-overflow (untested).

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core