From 281fbff42f6f6b460f541bf5ae1142f622f314d0 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Fri, 11 Oct 2019 17:16:03 -0300 Subject: [PATCH] Fix build on xenial - xenial's cmake version (3.5.1) builds everything fine and test suite passes, so lower the minimum to that. - add a hack for xenial's kernel header & glibc version breaking if both net/if.h and linux/if.h get included. The only thing we actually need from net/if.h that linux/if.h doesn't have is `if_nametoindex`, so just hack that definition in for xenial's specific glibc/kernel header versions. --- CMakeLists.txt | 3 +-- llarp/net/net.cpp | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd9567a1d..86b8f389c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,4 @@ -# Lowest version - android ndk 3.6.0 -cmake_minimum_required(VERSION 3.6.0) +cmake_minimum_required(VERSION 3.5.1) # xenial's cmake version find_program(CCACHE_PROGRAM ccache) if(CCACHE_PROGRAM) diff --git a/llarp/net/net.cpp b/llarp/net/net.cpp index bb7c0738f..4d8485cff 100644 --- a/llarp/net/net.cpp +++ b/llarp/net/net.cpp @@ -9,7 +9,20 @@ #ifndef ANDROID #include #endif -#include + +// Work around for broken glibc/linux header definitions in xenial that makes +// including both net/if.h (which we need for if_nametoindex) and linux/if.h +// (which tuntap.h includes) impossible. When we stop supporting xenial we can +// remove this mess and just include net/if.h here. +#if defined(Linux) && __GLIBC__ == 2 && __GLIBC_MINOR__ == 23 +# include +# if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0) && LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0) +# define _NET_IF_H 1 +# include +extern "C" unsigned int if_nametoindex (const char *__ifname) __THROW; +# endif +#else +# include #endif #include