aboutsummaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-connectivity/networkmanager/networkmanager/musl/0002-Fix-build-with-musl.patch
blob: 0f43c0c6840788a5fc433cdee73a6ae68f7de16f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
From bacc14089c80ec757025789ff054a05e1f9c088d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@gmail.com>
Date: Mon, 8 Apr 2019 23:10:43 +0200
Subject: [PATCH] Fix build with musl
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The build issues caused by definition conflicts musl vs linux-libc headers
(error: redefinition of ...) can be reduced to two headers:

1. netinet/if_ether.h <-> linux/if_ether.h: linux-libc header plays well with
   glibc and musl headers in case libc's variant (netinet/if_ether.h) is
   included BEFORE linux variant [1]. We add include at two positions:
   1. shared/nm-default.h: This is a global which used for networkmanager and
      is included at the very beginning of all c-files.
   2. libnm-core/nm-utils.h: This file makes it into installation and is used
      by dependent packages as network-manager-applet
2. net/if_arp. <-> linux/if_ether.h: linux-libc: Unfortunaly these files do
   not play together in harmony. Therefore the libc variant is included early in
   shared/nm-default.h and occurances linux/if_arp.h are removed.

Note:
Be aware that this is still nasty business: We have to trust that musl headers
define same signatures as linux would do - just because musl-makers consider
linux-libc headers 'notoriously broken for userspace' [2] (search for
'error: redefinition of').

[1] http://lists.openembedded.org/pipermail/openembedded-core/2019-March/280440.html
[2] https://wiki.musl-libc.org/faq.html

Upstream-Status: Pending

Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>

---
 clients/tui/nmt-device-entry.c   | 1 -
 libnm-core/nm-utils.h            | 4 ++++
 shared/nm-default.h              | 3 +++
 src/devices/nm-device.c          | 2 +-
 src/platform/nm-linux-platform.c | 1 -
 5 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/clients/tui/nmt-device-entry.c b/clients/tui/nmt-device-entry.c
index 692a467..cf9b32e 100644
--- a/clients/tui/nmt-device-entry.c
+++ b/clients/tui/nmt-device-entry.c
@@ -26,7 +26,6 @@
 #include "nmt-device-entry.h"
 
 #include <sys/socket.h>
-#include <linux/if_arp.h>
 
 #include "nmtui.h"
 
diff --git a/libnm-core/nm-utils.h b/libnm-core/nm-utils.h
index 9589c51..b82c5cf 100644
--- a/libnm-core/nm-utils.h
+++ b/libnm-core/nm-utils.h
@@ -10,6 +10,10 @@
     #error "Only <NetworkManager.h> can be included directly."
 #endif
 
+/* include as early as possible for musl */
+#include <netinet/if_ether.h>
+/* #include <net/if_arp.h> - uncoment for broken dependents?? */
+
 #include <glib.h>
 
 #include <netinet/in.h>
diff --git a/shared/nm-default.h b/shared/nm-default.h
index b322f1d..c287dbe 100644
--- a/shared/nm-default.h
+++ b/shared/nm-default.h
@@ -178,6 +178,9 @@
 #endif
 
 #include <stdlib.h>
+/* include as early as possible for musl */
+#include <netinet/if_ether.h>
+#include <net/if_arp.h>
 
 /*****************************************************************************/
 
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 0be05f2..04061f9 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -9,6 +9,7 @@
 #include "nm-device.h"
 
 #include <netinet/in.h>
+#include <net/if.h>
 #include <unistd.h>
 #include <sys/ioctl.h>
 #include <signal.h>
@@ -17,7 +18,6 @@
 #include <arpa/inet.h>
 #include <fcntl.h>
 #include <linux/if_addr.h>
-#include <linux/if_arp.h>
 #include <linux/rtnetlink.h>
 
 #include "nm-std-aux/unaligned.h"
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index b377c85..87af59a 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -14,7 +14,6 @@
 #include <libudev.h>
 #include <linux/fib_rules.h>
 #include <linux/ip.h>
-#include <linux/if_arp.h>
 #include <linux/if_bridge.h>
 #include <linux/if_link.h>
 #include <linux/if_tun.h>