blob: 962463f0b878a99081c9857a073d82e6f45d010e [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001From 75720bff62a84896e9a0654afc7cf9408cf89a38 Mon Sep 17 00:00:00 2001
2From: Filipe Brandenburger <filbranden@google.com>
3Date: Sun, 15 Jul 2018 22:43:35 -0700
4Subject: [PATCH] build-sys: Detect whether struct statx is defined in
5 sys/stat.h
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10Starting with glibc 2.27.9000-36.fc29, include file sys/stat.h will have a
11definition for struct statx, in which case include file linux/stat.h should be
12avoided, in order to prevent a duplicate definition.
13
14 In file included from ../src/basic/missing.h:18,
15 from ../src/basic/util.h:28,
16 from ../src/basic/hashmap.h:10,
17 from ../src/shared/bus-util.h:12,
18 from ../src/libsystemd/sd-bus/bus-creds.c:11:
19 /usr/include/linux/stat.h:99:8: error: redefinition of struct statx
20 struct statx {
21 ^~~~~
22 In file included from /usr/include/sys/stat.h:446,
23 from ../src/basic/util.h:19,
24 from ../src/basic/hashmap.h:10,
25 from ../src/shared/bus-util.h:12,
26 from ../src/libsystemd/sd-bus/bus-creds.c:11:
27 /usr/include/bits/statx.h:36:8: note: originally defined here
28 struct statx
29 ^~~~~
30
31Extend our meson.build to look for struct statx when only sys/stat.h is
32included and, in that case, do not include linux/stat.h anymore.
33
34Tested that systemd builds correctly when using a glibc version that includes a
35definition for struct statx.
36
37glibc Fedora RPM update:
38https://src.fedoraproject.org/rpms/glibc/c/28cb5d31fc1e5887912283c889689c47076278ae
39
40glibc upstream commit:
41https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=fd70af45528d59a00eb3190ef6706cb299488fcd
42---
43
44Upstream-Status: Pending
45Signed-off-by: Khem Raj <raj.khem@gmail.com>
46
47 meson.build | 5 +++++
48 src/basic/missing.h | 5 ++++-
49 src/basic/xattr-util.c | 1 -
50 3 files changed, 9 insertions(+), 2 deletions(-)
51
52Index: git/meson.build
53===================================================================
54--- git.orig/meson.build
55+++ git/meson.build
56@@ -432,6 +432,7 @@ decl_headers = '''
57 #include <sys/stat.h>
58 '''
59 # FIXME: key_serial_t is only defined in keyutils.h, this is bound to fail
60+# FIXME: these should use -D_GNU_SOURCE, since that is defined at build time
61
62 foreach decl : ['char16_t',
63 'char32_t',
64@@ -446,6 +447,10 @@ foreach decl : ['char16_t',
65 conf.set10('HAVE_' + decl.underscorify().to_upper(), have)
66 endforeach
67
68+conf.set10('HAVE_STRUCT_STATX_IN_SYS_STAT_H', cc.sizeof('struct statx', prefix : '''
69+#include <sys/stat.h>
70+''', args : '-D_GNU_SOURCE') > 0)
71+
72 foreach decl : [['IFLA_INET6_ADDR_GEN_MODE', 'linux/if_link.h'],
73 ['IN6_ADDR_GEN_MODE_STABLE_PRIVACY', 'linux/if_link.h'],
74 ['IFLA_VRF_TABLE', 'linux/if_link.h'],
75Index: git/src/basic/missing.h
76===================================================================
77--- git.orig/src/basic/missing.h
78+++ git/src/basic/missing.h
79@@ -15,7 +15,6 @@
80 #include <linux/neighbour.h>
81 #include <linux/oom.h>
82 #include <linux/rtnetlink.h>
83-#include <linux/stat.h>
84 #include <net/ethernet.h>
85 #include <stdlib.h>
86 #include <sys/resource.h>
87@@ -25,6 +24,10 @@
88 #include <uchar.h>
89 #include <unistd.h>
90
91+#if !HAVE_STRUCT_STATX_IN_SYS_STAT_H
92+#include <linux/stat.h>
93+#endif
94+
95 #if HAVE_AUDIT
96 #include <libaudit.h>
97 #endif
98Index: git/src/basic/xattr-util.c
99===================================================================
100--- git.orig/src/basic/xattr-util.c
101+++ git/src/basic/xattr-util.c
102@@ -2,7 +2,6 @@
103
104 #include <errno.h>
105 #include <fcntl.h>
106-#include <linux/stat.h>
107 #include <stdint.h>
108 #include <stdlib.h>
109 #include <string.h>