fix centos 6 compile

Lucian Cristian luci at createc.ro
Mon Jun 19 19:44:01 CEST 2017


centos 6 has gcc 4.4.7

with some minor modification and the updated kernel from elrepo this is 
working as it should


Regards

-------------- next part --------------
diff -aur WireGuard-0.0.20170613/src/socket.c WireGuard-0.0.20170613-cnt6/src/socket.c
--- WireGuard-0.0.20170613/src/socket.c	2017-06-13 01:18:14.000000000 +0300
+++ WireGuard-0.0.20170613/src/socket.c	2017-06-19 20:36:58.997018769 +0300
@@ -12,6 +12,9 @@
 #include <linux/if_ether.h>
 #include <net/udp_tunnel.h>
 #include <net/ipv6.h>
+#define GCC_VERSION (__GNUC__ * 10000 \
+		    + __GNUC_MINOR__ * 100 \
+		    + __GNUC_PATCHLEVEL__)
 
 static inline int send4(struct wireguard_device *wg, struct sk_buff *skb, struct endpoint *endpoint, u8 ds, struct dst_cache *cache)
 {
@@ -307,7 +310,10 @@
 	struct socket *new4 = NULL;
 	struct udp_port_cfg port4 = {
 		.family = AF_INET,
+/* Test for GCC > 4.4.7 */
+#if GCC_VERSION > 40407
 		.local_ip.s_addr = htonl(INADDR_ANY),
+#endif
 		.local_udp_port = htons(wg->incoming_port),
 		.use_udp_checksums = true
 	};
@@ -316,7 +322,10 @@
 	struct socket *new6 = NULL;
 	struct udp_port_cfg port6 = {
 		.family = AF_INET6,
+/* Test for GCC > 4.4.7 */
+#if GCC_VERSION > 40407
 		.local_ip6 = IN6ADDR_ANY_INIT,
+#endif
 		.local_udp_port = htons(wg->incoming_port),
 		.use_udp6_tx_checksums = true,
 		.use_udp6_rx_checksums = true,
diff -aur WireGuard-0.0.20170613/src/tools/Makefile WireGuard-0.0.20170613-cnt6/src/tools/Makefile
--- WireGuard-0.0.20170613/src/tools/Makefile	2017-06-13 01:18:14.000000000 +0300
+++ WireGuard-0.0.20170613/src/tools/Makefile	2017-06-19 20:19:42.560467226 +0300
@@ -11,6 +11,8 @@
 WITH_BASHCOMPLETION ?=
 WITH_WGQUICK ?=
 WITH_SYSTEMDUNITS ?=
+GCC_EQ_447 := $(shell expr `gcc -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/'` \= 40407)
+
 
 ifeq ($(WITH_BASHCOMPLETION),)
 ifneq ($(strip $(wildcard $(BASHCOMPDIR))),)
@@ -32,7 +34,11 @@
 endif
 
 CFLAGS ?= -O3
+ifeq "$(GCC_EQ_447)" "1"
+CFLAGS += -std=gnu99 -D_GNU_SOURCE
+else
 CFLAGS += -std=gnu11 -D_GNU_SOURCE
+endif
 CFLAGS += -Wall -Wextra
 CFLAGS += -MMD -MP
 CFLAGS += -DRUNSTATEDIR="\"$(RUNSTATEDIR)\""


More information about the WireGuard mailing list