teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0001-build-sys-Detect-whether-struct-statx-is-defined-in-.patch

ff6046
From 79df4db3fd122f5040bdf2225c3047375de3b0d2 Mon Sep 17 00:00:00 2001
ff6046
From: Filipe Brandenburger <filbranden@google.com>
ff6046
Date: Sun, 15 Jul 2018 22:43:35 -0700
ff6046
Subject: [PATCH] build-sys: Detect whether struct statx is defined in
ff6046
 sys/stat.h
ff6046
MIME-Version: 1.0
ff6046
Content-Type: text/plain; charset=UTF-8
ff6046
Content-Transfer-Encoding: 8bit
ff6046
ff6046
Starting with glibc 2.27.9000-36.fc29, include file sys/stat.h will have a
ff6046
definition for struct statx, in which case include file linux/stat.h should be
ff6046
avoided, in order to prevent a duplicate definition.
ff6046
ff6046
    In file included from ../src/basic/missing.h:18,
ff6046
		     from ../src/basic/util.h:28,
ff6046
		     from ../src/basic/hashmap.h:10,
ff6046
		     from ../src/shared/bus-util.h:12,
ff6046
		     from ../src/libsystemd/sd-bus/bus-creds.c:11:
ff6046
    /usr/include/linux/stat.h:99:8: error: redefinition of ‘struct statx’
ff6046
     struct statx {
ff6046
	    ^~~~~
ff6046
    In file included from /usr/include/sys/stat.h:446,
ff6046
		     from ../src/basic/util.h:19,
ff6046
		     from ../src/basic/hashmap.h:10,
ff6046
		     from ../src/shared/bus-util.h:12,
ff6046
		     from ../src/libsystemd/sd-bus/bus-creds.c:11:
ff6046
    /usr/include/bits/statx.h:36:8: note: originally defined here
ff6046
     struct statx
ff6046
	    ^~~~~
ff6046
ff6046
Extend our meson.build to look for struct statx when only sys/stat.h is
ff6046
included and, in that case, do not include linux/stat.h anymore.
ff6046
ff6046
Tested that systemd builds correctly when using a glibc version that includes a
ff6046
definition for struct statx.
ff6046
ff6046
glibc Fedora RPM update:
ff6046
https://src.fedoraproject.org/rpms/glibc/c/28cb5d31fc1e5887912283c889689c47076278ae
ff6046
ff6046
glibc upstream commit:
ff6046
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=fd70af45528d59a00eb3190ef6706cb299488fcd
ff6046
---
ff6046
 meson.build            | 5 +++++
ff6046
 src/basic/missing.h    | 5 ++++-
ff6046
 src/basic/xattr-util.c | 1 -
ff6046
 3 files changed, 9 insertions(+), 2 deletions(-)
ff6046
ff6046
diff --git a/meson.build b/meson.build
ff6046
index 04331dd41a..a0e7240708 100644
ff6046
--- a/meson.build
ff6046
+++ b/meson.build
ff6046
@@ -425,6 +425,7 @@ decl_headers = '''
ff6046
 #include <sys/stat.h>
ff6046
 '''
ff6046
 # FIXME: key_serial_t is only defined in keyutils.h, this is bound to fail
ff6046
+# FIXME: these should use -D_GNU_SOURCE, since that is defined at build time
ff6046
 
ff6046
 foreach decl : ['char16_t',
ff6046
                 'char32_t',
ff6046
@@ -439,6 +440,10 @@ foreach decl : ['char16_t',
ff6046
         conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
ff6046
 endforeach
ff6046
 
ff6046
+conf.set10('HAVE_STRUCT_STATX_IN_SYS_STAT_H', cc.sizeof('struct statx', prefix : '''
ff6046
+#include <sys/stat.h>
ff6046
+''', args : '-D_GNU_SOURCE') > 0)
ff6046
+
ff6046
 foreach decl : [['IFLA_INET6_ADDR_GEN_MODE',         'linux/if_link.h'],
ff6046
                 ['IN6_ADDR_GEN_MODE_STABLE_PRIVACY', 'linux/if_link.h'],
ff6046
                 ['IFLA_VRF_TABLE',                   'linux/if_link.h'],
ff6046
diff --git a/src/basic/missing.h b/src/basic/missing.h
ff6046
index 71a07d0574..14ad3d4914 100644
ff6046
--- a/src/basic/missing.h
ff6046
+++ b/src/basic/missing.h
ff6046
@@ -15,7 +15,6 @@
ff6046
 #include <linux/neighbour.h>
ff6046
 #include <linux/oom.h>
ff6046
 #include <linux/rtnetlink.h>
ff6046
-#include <linux/stat.h>
ff6046
 #include <net/ethernet.h>
ff6046
 #include <stdlib.h>
ff6046
 #include <sys/resource.h>
ff6046
@@ -25,6 +24,10 @@
ff6046
 #include <uchar.h>
ff6046
 #include <unistd.h>
ff6046
 
ff6046
+#if !HAVE_STRUCT_STATX_IN_SYS_STAT_H
ff6046
+#include <linux/stat.h>
ff6046
+#endif
ff6046
+
ff6046
 #if HAVE_AUDIT
ff6046
 #include <libaudit.h>
ff6046
 #endif
ff6046
diff --git a/src/basic/xattr-util.c b/src/basic/xattr-util.c
ff6046
index c5c55ea846..0ee0979837 100644
ff6046
--- a/src/basic/xattr-util.c
ff6046
+++ b/src/basic/xattr-util.c
ff6046
@@ -2,7 +2,6 @@
ff6046
 
ff6046
 #include <errno.h>
ff6046
 #include <fcntl.h>
ff6046
-#include <linux/stat.h>
ff6046
 #include <stdint.h>
ff6046
 #include <stdlib.h>
ff6046
 #include <string.h>