From c74bbd605e89bf9ff30b780902b4cf1f8349dc22 Mon Sep 17 00:00:00 2001 From: dongbo4 Date: Wed, 7 Nov 2018 08:55:09 +0000 Subject: [PATCH 1/5] Add arch arm64 compiler options --- lib/Makefile | 35 +++++++++++++++++++++++++++++++---- mk/kern.mk | 4 ++++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/lib/Makefile b/lib/Makefile index 8dc9d9d41..4c7c3c756 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -24,11 +24,19 @@ FF_KNI=1 #FF_IPFW=1 ifeq ($(FF_DPDK),) - FF_DPDK=${TOPDIR}/dpdk/x86_64-native-linuxapp-gcc +ifeq (${MACHINE_CPUARCH},aarch64) + FF_DPDK=${TOPDIR}/dpdk/build +else + #FF_DPDK=${TOPDIR}/dpdk/x86_64-native-linuxapp-gcc +endif endif ifdef RTE_SDK - FF_DPDK=${RTE_SDK}/x86_64-native-linuxapp-gcc +ifeq (${MACHINE_CPUARCH},aarch64) + FF_DPDK=${RTE_SDK}/build +else + #FF_DPDK=${RTE_SDK}/x86_64-native-linuxapp-gcc +endif endif DPDK_CFLAGS= -Wall -Werror -include ${FF_DPDK}/include/rte_config.h @@ -92,6 +100,13 @@ endif endif +# +# fix the MACHINE_CPUARCH to match the FreeBSD directory name +# +ifeq (${MACHINE_CPUARCH},aarch64) +MACHINE_CPUARCH=arm64 +endif + # # Distilled from FreeBSD src/sys/conf/Makefile.i386 @@ -262,7 +277,7 @@ KERN_MHEADERS+= \ KERN_MSRCS+= \ linker_if.m - +ifeq (${MACHINE_CPUARCH},arm64) LIBKERN_SRCS+= \ bcd.c \ crc32.c \ @@ -270,7 +285,19 @@ LIBKERN_SRCS+= \ jenkins_hash.c \ strlcpy.c \ strnlen.c \ - zlib.c + zlib.c \ + fls.c \ + flsl.c +else +LIBKERN_SRCS+= \ + bcd.c \ + crc32.c \ + inet_ntoa.c \ + jenkins_hash.c \ + strlcpy.c \ + strnlen.c \ + zlib.c +endif MACHINE_SRCS+= \ diff --git a/mk/kern.mk b/mk/kern.mk index 877815d66..979e0a2f4 100644 --- a/mk/kern.mk +++ b/mk/kern.mk @@ -101,6 +101,10 @@ CFLAGS+= INLINE_LIMIT?= 8000 endif +ifeq (${MACHINE_CPUARCH},arm64) +INLINE_LIMIT?= 15000 +endif + # # GCC SSP support # From e3636d6024ea50df8995c1a2c5fdc3d94c1bf4a5 Mon Sep 17 00:00:00 2001 From: dongbo4 Date: Wed, 7 Nov 2018 08:56:50 +0000 Subject: [PATCH 2/5] Fix f_stack -Werror=unused-but-set-variable errors with gcc compilers --- mk/compiler.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/compiler.mk b/mk/compiler.mk index 1bb5ba22c..8cff36283 100644 --- a/mk/compiler.mk +++ b/mk/compiler.mk @@ -4,7 +4,7 @@ ifndef COMPILER_TYPE ifeq ($(patsubst gcc%,gcc,$(notdir ${CC})),gcc) -COMPILER_TYPE:= gcc +COMPILER_TYPE:= gcc else ifeq ($(notdir ${CC}), clang) COMPILER_TYPE:= clang else From 02744692ce441caeadbef64ddfad556f6c0ba8a0 Mon Sep 17 00:00:00 2001 From: dongbo4 Date: Wed, 7 Nov 2018 08:59:23 +0000 Subject: [PATCH 3/5] Fix nginx_with_fstack setting up segment faults on arm64 platform --- freebsd/arm64/include/pcpu.h | 1 + 1 file changed, 1 insertion(+) diff --git a/freebsd/arm64/include/pcpu.h b/freebsd/arm64/include/pcpu.h index 21b58db5c..68ebbeb87 100644 --- a/freebsd/arm64/include/pcpu.h +++ b/freebsd/arm64/include/pcpu.h @@ -64,6 +64,7 @@ get_curthread(void) } #define curthread get_curthread() +#undef curthread #define PCPU_GET(member) (get_pcpu()->pc_ ## member) #define PCPU_ADD(member, value) (get_pcpu()->pc_ ## member += (value)) From e404bd1de6752b14c4c175e5b5fef940f7f62e8f Mon Sep 17 00:00:00 2001 From: DonBearH <32063987+DonBearH@users.noreply.github.com> Date: Thu, 8 Nov 2018 10:03:22 +0800 Subject: [PATCH 4/5] Update Makefile for reserving FF_DPDK for x86 The former patch, which add compiler option for arm64, removes the FF_DPDK for x86. That's a mistake. --- lib/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Makefile b/lib/Makefile index 4c7c3c756..89e713021 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -24,18 +24,18 @@ FF_KNI=1 #FF_IPFW=1 ifeq ($(FF_DPDK),) -ifeq (${MACHINE_CPUARCH},aarch64) +ifeq (${shell uname -m},aarch64) FF_DPDK=${TOPDIR}/dpdk/build else - #FF_DPDK=${TOPDIR}/dpdk/x86_64-native-linuxapp-gcc + FF_DPDK=${TOPDIR}/dpdk/x86_64-native-linuxapp-gcc endif endif ifdef RTE_SDK -ifeq (${MACHINE_CPUARCH},aarch64) +ifeq (${shell uname -m},aarch64) FF_DPDK=${RTE_SDK}/build else - #FF_DPDK=${RTE_SDK}/x86_64-native-linuxapp-gcc + FF_DPDK=${RTE_SDK}/x86_64-native-linuxapp-gcc endif endif From 31b03876fc58a7b7fd27968aecc5aea6312dfeeb Mon Sep 17 00:00:00 2001 From: DonBearH <32063987+DonBearH@users.noreply.github.com> Date: Thu, 8 Nov 2018 14:57:44 +0800 Subject: [PATCH 5/5] Setting FF_DPDK with MACHINE_CPUARCH --- lib/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Makefile b/lib/Makefile index 89e713021..03409983b 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -23,8 +23,10 @@ FF_KNI=1 #FF_NETGRAPH=1 #FF_IPFW=1 +include ${TOPDIR}/mk/kern.pre.mk + ifeq ($(FF_DPDK),) -ifeq (${shell uname -m},aarch64) +ifeq (${MACHINE_CPUARCH},aarch64) FF_DPDK=${TOPDIR}/dpdk/build else FF_DPDK=${TOPDIR}/dpdk/x86_64-native-linuxapp-gcc @@ -32,7 +34,7 @@ endif endif ifdef RTE_SDK -ifeq (${shell uname -m},aarch64) +ifeq (${MACHINE_CPUARCH},aarch64) FF_DPDK=${RTE_SDK}/build else FF_DPDK=${RTE_SDK}/x86_64-native-linuxapp-gcc @@ -45,8 +47,6 @@ DPDK_CFLAGS+= -DRTE_MACHINE_CPUFLAG_SSSE3 -DRTE_MACHINE_CPUFLAG_SSE4_1 -DRTE_MAC DPDK_CFLAGS+= -DRTE_COMPILE_TIME_CPUFLAGS=RTE_CPUFLAG_SSE,RTE_CPUFLAG_SSE2,RTE_CPUFLAG_SSE3,RTE_CPUFLAG_SSSE3,RTE_CPUFLAG_SSE4_1,RTE_CPUFLAG_SSE4_2 DPDK_CFLAGS+= -I${FF_DPDK}/include -include ${TOPDIR}/mk/kern.pre.mk - KERNPREINCLUDES:= ${INCLUDES} INCLUDES= -I${OVERRIDE_INCLUDES_ROOT} ${KERNPREINCLUDES} INCLUDES+= -I./machine_include