canonical / lightdm

Display Manager
GNU General Public License v3.0
834 stars 138 forks source link

FTBFS on s390x with gcc versions higher than gcc-9 #188

Open gunnarhj opened 3 years ago

gunnarhj commented 3 years ago

The build failure happens on Ubuntu 20.10 and 21.04, and is caused by this warning:

In file included from display-server.h:19,
                 from x-server.h:16,
                 from x-server.c:16:
x-server.c: In function ‘x_server_start’:
logger.h:54:5: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
   54 |     logger_log (LOGGER (self), G_LOG_LEVEL_DEBUG, __VA_ARGS__)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
x-server.c:131:45: note: format string is defined here
  131 |     l_debug (server, "Connecting to XServer %s", x_server_get_address (server));
      |                                             ^~

Possibly it's related to this change:

$ zcat /usr/share/doc/gcc-10-base/NEWS.gz | grep -A 1 Wformat
          o -Wformat-overflow makes full use of string length information
            computed by the strlen optimization pass.

I'm about to work around the issue in hirsute by applying this patch:

--- a/configure.ac
+++ b/configure.ac
@@ -29,7 +29,6 @@
                  -Werror=pointer-arith \
                  -Werror=init-self \
                  -Werror=format-security \
-                 -Werror=format=2 \
                  -Werror=missing-include-dirs"
     WARN_CXXFLAGS="-Wall"
 fi
robert-ancell commented 3 years ago

Hmm, I wonder if gcc is getting confused since l_debug is a macro. It might go away if we replace them with inline functions instead?

gunnarhj commented 3 years ago

I would guess it's simpler than that. I can trigger the warning by just doing:

printf ("Hello %s\n", NULL);

And replacing the line

l_debug (server, "Connecting to XServer %s", x_server_get_address (server));

with

l_debug (server, "Connecting to XServer %s", x_server_get_address (server) ? x_server_get_address (server) : "");

seems to fix it.