blob: e0973af1e90bf196affb36d0969cd245d94e2d4d [file] [log] [blame]
Brad Bishop15ae2502019-06-18 21:44:24 -04001From 3d1307735667758f44378585482fe421db086af8 Mon Sep 17 00:00:00 2001
Brad Bishopc342db32019-05-15 21:57:59 -04002From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@gmail.com>
3Date: Mon, 8 Apr 2019 23:10:43 +0200
4Subject: [PATCH 2/2] Fix build with musl
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9The build issues caused by definition conflicts musl vs linux-libc headers
10(error: redefinition of ...) can be reduced to two headers:
11
121. netinet/if_ether.h <-> linux/if_ether.h: linux-libc header plays well with
13 glibc and musl headers in case libc's variant (netinet/if_ether.h) is
14 included BEFORE linux variant [1]. We add include at two positions:
15 1. shared/nm-default.h: This is a global which used for networkmanager and
16 is included at the very beginning of all c-files.
17 2. libnm-core/nm-utils.h: This file makes it into installation and is used
18 by dependent packages as network-manager-applet
192. net/if_arp. <-> linux/if_ether.h: linux-libc: Unfortunaly these files do
20 not play together in harmony. Therefore the libc variant is included early in
21 shared/nm-default.h and occurances linux/if_arp.h are removed.
22
23Note:
24Be aware that this is still nasty business: We have to trust that musl headers
25define same signatures as linux would do - just because musl-makers consider
Brad Bishop15ae2502019-06-18 21:44:24 -040026linux-libc headers 'notoriously broken for userspace' [2] (search for
Brad Bishopc342db32019-05-15 21:57:59 -040027'error: redefinition of').
28
29[1] http://lists.openembedded.org/pipermail/openembedded-core/2019-March/280440.html
30[2] https://wiki.musl-libc.org/faq.html
31
32Upstream-Status: Pending
33
34Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
35---
36 clients/tui/nmt-device-entry.c | 1 -
37 libnm-core/nm-utils.h | 4 ++++
38 shared/nm-default.h | 3 +++
39 src/devices/nm-device.c | 2 +-
40 src/platform/nm-linux-platform.c | 1 -
41 5 files changed, 8 insertions(+), 3 deletions(-)
42
43diff --git a/clients/tui/nmt-device-entry.c b/clients/tui/nmt-device-entry.c
44index 43fbbc1..3eae286 100644
45--- a/clients/tui/nmt-device-entry.c
46+++ b/clients/tui/nmt-device-entry.c
47@@ -39,7 +39,6 @@
48 #include "nmt-device-entry.h"
49
50 #include <sys/socket.h>
51-#include <linux/if_arp.h>
52
53 #include "nmtui.h"
54
55diff --git a/libnm-core/nm-utils.h b/libnm-core/nm-utils.h
Brad Bishop15ae2502019-06-18 21:44:24 -040056index 2b5baba..f7abab6 100644
Brad Bishopc342db32019-05-15 21:57:59 -040057--- a/libnm-core/nm-utils.h
58+++ b/libnm-core/nm-utils.h
59@@ -25,6 +25,10 @@
60 #error "Only <NetworkManager.h> can be included directly."
61 #endif
62
63+/* include as early as possible for musl */
64+#include <netinet/if_ether.h>
65+/* #include <net/if_arp.h> - uncoment for broken dependents?? */
66+
67 #include <glib.h>
68
69 #include <netinet/in.h>
70diff --git a/shared/nm-default.h b/shared/nm-default.h
Brad Bishop15ae2502019-06-18 21:44:24 -040071index 54e9916..26e9f4e 100644
Brad Bishopc342db32019-05-15 21:57:59 -040072--- a/shared/nm-default.h
73+++ b/shared/nm-default.h
74@@ -211,6 +211,9 @@
75 #endif
76
77 #include <stdlib.h>
78+/* include as early as possible for musl */
79+#include <netinet/if_ether.h>
80+#include <net/if_arp.h>
81
82 /*****************************************************************************/
83
84diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
Brad Bishop15ae2502019-06-18 21:44:24 -040085index bd4fbcc..f70b309 100644
Brad Bishopc342db32019-05-15 21:57:59 -040086--- a/src/devices/nm-device.c
87+++ b/src/devices/nm-device.c
88@@ -24,6 +24,7 @@
89 #include "nm-device.h"
90
91 #include <netinet/in.h>
92+#include <net/if.h>
93 #include <unistd.h>
94 #include <sys/ioctl.h>
95 #include <signal.h>
96@@ -32,7 +33,6 @@
97 #include <arpa/inet.h>
98 #include <fcntl.h>
99 #include <linux/if_addr.h>
100-#include <linux/if_arp.h>
101 #include <linux/rtnetlink.h>
102 #include <linux/pkt_sched.h>
103
104diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
Brad Bishop15ae2502019-06-18 21:44:24 -0400105index d4b0115..22a3a90 100644
Brad Bishopc342db32019-05-15 21:57:59 -0400106--- a/src/platform/nm-linux-platform.c
107+++ b/src/platform/nm-linux-platform.c
Brad Bishop15ae2502019-06-18 21:44:24 -0400108@@ -28,7 +28,6 @@
Brad Bishopc342db32019-05-15 21:57:59 -0400109 #include <libudev.h>
Brad Bishop15ae2502019-06-18 21:44:24 -0400110 #include <linux/fib_rules.h>
Brad Bishopc342db32019-05-15 21:57:59 -0400111 #include <linux/ip.h>
112-#include <linux/if_arp.h>
Brad Bishop15ae2502019-06-18 21:44:24 -0400113 #include <linux/if_bridge.h>
Brad Bishopc342db32019-05-15 21:57:59 -0400114 #include <linux/if_link.h>
115 #include <linux/if_tun.h>
Brad Bishopc342db32019-05-15 21:57:59 -0400116--
Brad Bishop15ae2502019-06-18 21:44:24 -04001172.17.1
Brad Bishopc342db32019-05-15 21:57:59 -0400118