Details
-
Type:
Bug
-
Status: Done
-
Priority:
Medium
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 3.6.7
-
Component/s: Building and Installing
-
Labels:None
Description
When building with musl libc on Alpine Linux the following build error happens:
<pre>
ncopa-desktop:~/src/cfengine-core$ make
Making all in libcompat
CC generic_at.lo
In file included from ../libutils/platform.h:358:0,
from generic_at.c:25:
/usr/include/linux/if.h:71:2: error: expected identifier before numeric constant
IFF_UP = 1<<0, /* sysfs */
^
In file included from /usr/include/linux/route.h:26:0,
from ../libutils/platform.h:378,
from generic_at.c:25:
/usr/include/linux/if.h:169:8: error: redefinition of 'struct ifmap'
struct ifmap {
^
...
</pre>
Problem is that linux/*.h headers are used instead of net/route.h, netinet/in.h and netinet/ip.h.
The criteria for using net/.h and netinet/.h on linux is: @# if defined(_GLIBC) || defined(BIONIC_)@
None of those are defined with musl libc.
I propose to use AC_CHECK_HEADERS for each header and do @#if defined HAVE_NET_ROUTE_H@ instead of assume GNU or bionic:
<pre>
diff --git a/configure.ac b/configure.ac
index eb5dc6f..38bd295 100644
— a/configure.ac
+++ b/configure.ac
@@ -596,6 +596,8 @@ AC_CHECK_HEADERS(sys/jail.h, [], [], [AC_INCLUDES_DEFAULT
- include <sys/param.h>
#endif
])
+AC_CHECK_HEADERS(net/route.h netinet/in.h netinet/ip.h)
+
AC_HEADER_STDC
AC_HEADER_TIME
diff --git a/libutils/platform.h b/libutils/platform.h
index da2f433..6c3fbcd 100644
— a/libutils/platform.h
+++ b/libutils/platform.h
@@ -370,13 +370,21 @@ union mpinfou
#endif
#ifdef _linux_
-
- if defined(_GLIBC) || defined(BIONIC_)
+# ifdef HAVE_NET_ROUTE_H
- if defined(_GLIBC) || defined(BIONIC_)
- include <net/route.h>
- include <netinet/in.h>
- include <netinet/ip.h>
- else
- include <linux/route.h>
+# endif
+
+# ifdef HAVE_NETINET_IN_H
+# include <netinet/in.h>
+# else - include <linux/in.h>
+# endif
+
+# ifdef HAVE_NETINET_IP_H
+# include <netinet/ip.h>
+# else - include <linux/ip.h>
- endif
#endif
</pre>
With the above patch it builds with musl libc.
You might be able to reproduce in debian with CC=musl-gcc