]>
Commit | Line | Data |
---|---|---|
aaa616e7 SS |
1 | From 75720bff62a84896e9a0654afc7cf9408cf89a38 Mon Sep 17 00:00:00 2001 |
2 | From: Filipe Brandenburger <filbranden@google.com> | |
3 | Date: Sun, 15 Jul 2018 22:43:35 -0700 | |
4 | Subject: [PATCH] build-sys: Detect whether struct statx is defined in | |
5 | sys/stat.h | |
6 | MIME-Version: 1.0 | |
7 | Content-Type: text/plain; charset=UTF-8 | |
8 | Content-Transfer-Encoding: 8bit | |
9 | ||
10 | Starting with glibc 2.27.9000-36.fc29, include file sys/stat.h will have a | |
11 | definition for struct statx, in which case include file linux/stat.h should be | |
12 | avoided, 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 | ||
31 | Extend our meson.build to look for struct statx when only sys/stat.h is | |
32 | included and, in that case, do not include linux/stat.h anymore. | |
33 | ||
34 | Tested that systemd builds correctly when using a glibc version that includes a | |
35 | definition for struct statx. | |
36 | ||
37 | glibc Fedora RPM update: | |
38 | https://src.fedoraproject.org/rpms/glibc/c/28cb5d31fc1e5887912283c889689c47076278ae | |
39 | ||
40 | glibc upstream commit: | |
41 | https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=fd70af45528d59a00eb3190ef6706cb299488fcd | |
42 | --- | |
43 | meson.build | 5 +++++ | |
44 | src/basic/missing.h | 5 ++++- | |
45 | src/basic/xattr-util.c | 1 - | |
46 | 3 files changed, 9 insertions(+), 2 deletions(-) | |
47 | ||
48 | diff --git a/meson.build b/meson.build | |
49 | index dd904c7148..68423bdfa5 100644 | |
50 | --- a/meson.build | |
51 | +++ b/meson.build | |
52 | @@ -425,6 +425,7 @@ decl_headers = ''' | |
53 | #include <sys/stat.h> | |
54 | ''' | |
55 | # FIXME: key_serial_t is only defined in keyutils.h, this is bound to fail | |
56 | +# FIXME: these should use -D_GNU_SOURCE, since that is defined at build time | |
57 | ||
58 | foreach decl : ['char16_t', | |
59 | 'char32_t', | |
60 | @@ -439,6 +440,10 @@ foreach decl : ['char16_t', | |
61 | conf.set10('HAVE_' + decl.underscorify().to_upper(), have) | |
62 | endforeach | |
63 | ||
64 | +conf.set10('HAVE_STRUCT_STATX_IN_SYS_STAT_H', cc.sizeof('struct statx', prefix : ''' | |
65 | +#include <sys/stat.h> | |
66 | +''', args : '-D_GNU_SOURCE') > 0) | |
67 | + | |
68 | foreach decl : [['IFLA_INET6_ADDR_GEN_MODE', 'linux/if_link.h'], | |
69 | ['IN6_ADDR_GEN_MODE_STABLE_PRIVACY', 'linux/if_link.h'], | |
70 | ['IFLA_VRF_TABLE', 'linux/if_link.h'], | |
71 | diff --git a/src/basic/missing.h b/src/basic/missing.h | |
72 | index 71a07d0574..14ad3d4914 100644 | |
73 | --- a/src/basic/missing.h | |
74 | +++ b/src/basic/missing.h | |
75 | @@ -15,7 +15,6 @@ | |
76 | #include <linux/neighbour.h> | |
77 | #include <linux/oom.h> | |
78 | #include <linux/rtnetlink.h> | |
79 | -#include <linux/stat.h> | |
80 | #include <net/ethernet.h> | |
81 | #include <stdlib.h> | |
82 | #include <sys/resource.h> | |
83 | @@ -25,6 +24,10 @@ | |
84 | #include <uchar.h> | |
85 | #include <unistd.h> | |
86 | ||
87 | +#if !HAVE_STRUCT_STATX_IN_SYS_STAT_H | |
88 | +#include <linux/stat.h> | |
89 | +#endif | |
90 | + | |
91 | #if HAVE_AUDIT | |
92 | #include <libaudit.h> | |
93 | #endif | |
94 | diff --git a/src/basic/xattr-util.c b/src/basic/xattr-util.c | |
95 | index c5c55ea846..0ee0979837 100644 | |
96 | --- a/src/basic/xattr-util.c | |
97 | +++ b/src/basic/xattr-util.c | |
98 | @@ -2,7 +2,6 @@ | |
99 | ||
100 | #include <errno.h> | |
101 | #include <fcntl.h> | |
102 | -#include <linux/stat.h> | |
103 | #include <stdint.h> | |
104 | #include <stdlib.h> | |
105 | #include <string.h> |