mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
Enable cross compilation to aarch64
Change-Id: Iafc8ac60926f5286990ce63a4ff4f8b6a7c46bef
This commit is contained in:
parent
feb2d3ccf7
commit
b6c3ab723b
@ -209,7 +209,7 @@ else()
|
||||
message(SEND_ERROR "Something went wrong determining gcc tune: -mtune=${GNUCC_ARCH} not valid")
|
||||
endif()
|
||||
set(TUNE_FLAG ${GNUCC_ARCH})
|
||||
else ()
|
||||
elseif (NOT TUNE_FLAG)
|
||||
set(TUNE_FLAG native)
|
||||
endif()
|
||||
|
||||
@ -252,11 +252,11 @@ else()
|
||||
endif()
|
||||
|
||||
if (NOT CMAKE_C_FLAGS MATCHES .*march.* AND NOT CMAKE_C_FLAGS MATCHES .*mtune.*)
|
||||
set(ARCH_C_FLAGS "-march=native -mtune=${TUNE_FLAG}")
|
||||
set(ARCH_C_FLAGS "-march=${GNUCC_ARCH} -mtune=${TUNE_FLAG}")
|
||||
endif()
|
||||
|
||||
if (NOT CMAKE_CXX_FLAGS MATCHES .*march.* AND NOT CMAKE_CXX_FLAGS MATCHES .*mtune.*)
|
||||
set(ARCH_CXX_FLAGS "-march=native -mtune=${TUNE_FLAG}")
|
||||
set(ARCH_CXX_FLAGS "-march=${GNUCC_ARCH} -mtune=${TUNE_FLAG}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
@ -460,7 +460,11 @@ endif()
|
||||
endif()
|
||||
|
||||
if (NOT FAT_RUNTIME)
|
||||
if (CROSS_COMPILE_AARCH64)
|
||||
message(STATUS "Building for target CPU: ${ARCH_C_FLAGS}")
|
||||
else()
|
||||
message(STATUS "Building for current host CPU: ${ARCH_C_FLAGS}")
|
||||
endif()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARCH_C_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARCH_CXX_FLAGS}")
|
||||
else()
|
||||
|
1
LICENSE
1
LICENSE
@ -5,6 +5,7 @@ Copyright (c) 2015, Intel Corporation
|
||||
Vectorscan is licensed under the BSD License.
|
||||
|
||||
Copyright (c) 2020, VectorCamp PC
|
||||
Copyright (c) 2021, Arm Limited
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
16
README.md
16
README.md
@ -29,6 +29,22 @@ matching of regular expressions across streams of data.
|
||||
|
||||
Vectorscan is typically used in a DPI library stack, just like Hyperscan.
|
||||
|
||||
# Cross Compiling for AArch64
|
||||
|
||||
- To cross compile for AArch64, first adjust the variables set in cmake/setenv-arm64-cross.sh.
|
||||
- `export CROSS=<arm-cross-compiler-dir>/bin/aarch64-linux-gnu-`
|
||||
- `export CROSS_SYS=<arm-cross-compiler-system-dir>`
|
||||
- `export BOOST_PATH=<boost-source-dir>`
|
||||
- Set the environment variables:
|
||||
- `source cmake/setenv-arm64-cross.sh`
|
||||
- Configure Vectorscan:
|
||||
- `mkdir <build-dir-name>`
|
||||
- `cd <build-dir>`
|
||||
- `cmake -DCROSS_COMPILE_AARCH64=1 <hyperscan-source-dir> -DCMAKE_TOOLCHAIN_FILE=<hyperscan-source-dir>/cmake/arm64-cross.cmake`
|
||||
- Build Vectorscan:
|
||||
- `make -jT` where T is the number of threads used to compile.
|
||||
- `cmake --build . -- -j T` can also be used instead of make.
|
||||
|
||||
# Documentation
|
||||
|
||||
Information on building the Hyperscan library and using its API is available in
|
||||
|
22
cmake/arm64-cross.cmake
Normal file
22
cmake/arm64-cross.cmake
Normal file
@ -0,0 +1,22 @@
|
||||
set(CMAKE_SYSTEM_NAME "Linux")
|
||||
set(CMAKE_SYSTEM_PROCESSOR "aarch64")
|
||||
|
||||
# specify the cross compiler
|
||||
set(CMAKE_C_COMPILER "$ENV{CROSS}gcc")
|
||||
set(CMAKE_CXX_COMPILER "$ENV{CROSS}g++")
|
||||
# where is the target environment
|
||||
set(CMAKE_SYSROOT $ENV{CROSS_SYS})
|
||||
|
||||
set(Boost_INCLUDE_DIR $ENV{BOOST_PATH})
|
||||
|
||||
# for libraries and headers in the target directories
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
set(THREADS_PTHREAD_ARG "2" CACHE STRING "Result from TRY_RUN" FORCE)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -falign-functions=16 -falign-jumps=16 -falign-labels=16 -falign-loops=16" CACHE STRING "" FORCE)
|
||||
|
||||
set(GNUCC_ARCH "armv8.2-a+fp16+simd+rcpc+dotprod+crypto")
|
||||
set(TUNE_FLAG "neoverse-n1")
|
@ -21,6 +21,9 @@
|
||||
/* "Define if building for AARCH64" */
|
||||
#cmakedefine ARCH_AARCH64
|
||||
|
||||
/* "Define if cross compiling for AARCH64" */
|
||||
#cmakedefine CROSS_COMPILE_AARCH64
|
||||
|
||||
/* internal build, switch on dump support. */
|
||||
#cmakedefine DUMP_SUPPORT
|
||||
|
||||
|
@ -1,15 +1,21 @@
|
||||
# determine the target arch
|
||||
|
||||
# really only interested in the preprocessor here
|
||||
CHECK_C_SOURCE_COMPILES("#if !(defined(__x86_64__) || defined(_M_X64))\n#error not 64bit\n#endif\nint main(void) { return 0; }" ARCH_X86_64)
|
||||
|
||||
CHECK_C_SOURCE_COMPILES("#if !(defined(__i386__) || defined(_M_IX86))\n#error not 32bit\n#endif\nint main(void) { return 0; }" ARCH_IA32)
|
||||
|
||||
CHECK_C_SOURCE_COMPILES("#if !defined(__ARM_ARCH_ISA_A64)\n#error not 64bit\n#endif\nint main(void) { return 0; }" ARCH_AARCH64)
|
||||
CHECK_C_SOURCE_COMPILES("#if !defined(__ARM_ARCH_ISA_ARM)\n#error not 32bit\n#endif\nint main(void) { return 0; }" ARCH_ARM32)
|
||||
|
||||
if (ARCH_X86_64 OR ARCH_AARCH64)
|
||||
if (CROSS_COMPILE_AARCH64)
|
||||
set(ARCH_AARCH64 TRUE)
|
||||
set(ARCH_64_BIT TRUE)
|
||||
message(STATUS "Cross compiling for aarch64")
|
||||
else()
|
||||
# really only interested in the preprocessor here
|
||||
CHECK_C_SOURCE_COMPILES("#if !(defined(__x86_64__) || defined(_M_X64))\n#error not 64bit\n#endif\nint main(void) { return 0; }" ARCH_X86_64)
|
||||
|
||||
CHECK_C_SOURCE_COMPILES("#if !(defined(__i386__) || defined(_M_IX86))\n#error not 32bit\n#endif\nint main(void) { return 0; }" ARCH_IA32)
|
||||
|
||||
CHECK_C_SOURCE_COMPILES("#if !defined(__ARM_ARCH_ISA_A64)\n#error not 64bit\n#endif\nint main(void) { return 0; }" ARCH_AARCH64)
|
||||
CHECK_C_SOURCE_COMPILES("#if !defined(__ARM_ARCH_ISA_ARM)\n#error not 32bit\n#endif\nint main(void) { return 0; }" ARCH_ARM32)
|
||||
|
||||
if (ARCH_X86_64 OR ARCH_AARCH64)
|
||||
set(ARCH_64_BIT TRUE)
|
||||
else()
|
||||
set(ARCH_32_BIT TRUE)
|
||||
endif()
|
||||
endif()
|
19
cmake/setenv-arm64-cross.sh
Normal file
19
cmake/setenv-arm64-cross.sh
Normal file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
export BOOST_VERSION=1_57_0
|
||||
export BOOST_DOT_VERSION=${BOOST_VERSION//_/.}
|
||||
export CROSS=<arm-cross-compiler-dir>/bin/aarch64-linux-gnu-
|
||||
export CROSS_SYS=<arm-cross-compiler-system-dir>
|
||||
|
||||
# if [ ! -d "boost_$BOOST_VERSION" ];
|
||||
# then
|
||||
# wget -O boost_$BOOST_VERSION.tar.gz https://sourceforge.net/projects/boost/files/boost/$BOOST_DOT_VERSION/boost_$BOOST_VERSION.tar.gz/download
|
||||
# tar xf boost_$BOOST_VERSION.tar.gz
|
||||
# fi
|
||||
if [ ! -d "pcre-8.41" ];
|
||||
then
|
||||
wget -O pcre-8.41.tar.bz2 https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.bz2
|
||||
tar xf pcre-8.41.tar.bz2
|
||||
export PCRE_SOURCE=1
|
||||
fi
|
||||
|
||||
export BOOST_PATH=<boost-source-dir>
|
Loading…
x
Reference in New Issue
Block a user