I'm trying to build uClibc 0.9.27 [1] on x86_64 with the linux kernel 3.10-2-amd64. I can verify that it builds on Ubuntu 12.04.3 with the 3.2.0-49-generic kernel. When running make, it manages to build a lot of object files but eventually reaches CC libc/inet/if_index.os
, complaining with
In file included from /usr/include/linux/kernel.h:4,
from /usr/include/linux/netlink.h:4,
from /usr/include/linux/rtnetlink.h:5,
from libc/inet/netlinkaccess.h:32,
from libc/inet/if_index.c:36:
/usr/include/linux/sysinfo.h:8: error: expected specifier-qualifier-list before '__kernel_long_t'
In file included from /usr/include/linux/rtnetlink.h:6,
from libc/inet/netlinkaccess.h:32,
from libc/inet/if_index.c:36:
/usr/include/linux/if_link.h:317: error: expected specifier-qualifier-list before '__be16'
I verified that the types exist in files that I gather should have been sucked in. In the case of __kernel_long_t
, the include files look like this:
/usr/include/linux/sysinfo.h includes <linux/types.h>
/usr/include/linux/types.h includes <linux/posix_types.h>
/usr/include/linux/posix_types.h includes <asm/posix_types.h>
/usr/include/x86_64-linux-gnu/asm/posix_types.h includes <asm/posix_types_64.h>
/usr/include/x86_64-linux-gnu/asm/posix_types_64.h includes <asm-generic/posix_types.h>
/usr/include/asm-generic/posix_types.h typedefs __kernel_long_t
So, where does that error come from, and how can I fix it?
[1] Yes, I know the newest version is 0.9.33.2, but I need that particular version.
The solution seems to be to backport a newer version of libc/inet/netlinkacces.h
to the older version. The __kernel_long_t
problem goes away by avoiding an include (if necessary, that would have to be patched in kernel_types.h
, because the defines intentionally shadow the include guards of the headers in /usr/include
) and the other type(s) can be properly included by the following patch:
index 417d83a..1b9c857 100644
--- a/libc/inet/netlinkaccess.h
+++ b/libc/inet/netlinkaccess.h
@@ -21,16 +21,7 @@
#include <features.h>
#include <stdint.h>
-#include <sys/types.h>
-
-#define _LINUX_TYPES_H
-typedef uint8_t __u8;
-typedef uint16_t __u16;
-typedef uint32_t __u32;
-typedef uint64_t __u64;
-typedef int32_t __s32;
-#include <linux/rtnetlink.h>
-#include <linux/netlink.h>
+#include <unistd.h>
/* Should prob be a configure option or something */
#ifndef __ASSUME_NETLINK_SUPPORT
This is basically the change between the old netlinkaccess.h
and the one in the newer version (diffing of the preprocessed files suggested by ash hinted me to this).