Skip to content

Commit aa8af26

Browse files
authored
Merge pull request #181 from VectorCamp/bugfix/fix-clang15-compilation-errors
Fix clang 15,16 compilation errors on all platforms, refactor CMake build system
2 parents 4918f81 + 5a4d900 commit aa8af26

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1250
-1046
lines changed

CMakeLists.txt

Lines changed: 154 additions & 529 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,6 @@ matching of regular expressions across streams of data.
2929

3030
Vectorscan is typically used in a DPI library stack, just like Hyperscan.
3131

32-
# Cross Compiling for AArch64
33-
34-
- To cross compile for AArch64, first adjust the variables set in cmake/setenv-arm64-cross.sh.
35-
- `export CROSS=<arm-cross-compiler-dir>/bin/aarch64-linux-gnu-`
36-
- `export CROSS_SYS=<arm-cross-compiler-system-dir>`
37-
- `export BOOST_PATH=<boost-source-dir>`
38-
- Set the environment variables:
39-
- `source cmake/setenv-arm64-cross.sh`
40-
- Configure Vectorscan:
41-
- `mkdir <build-dir-name>`
42-
- `cd <build-dir>`
43-
- `cmake -DCROSS_COMPILE_AARCH64=1 <hyperscan-source-dir> -DCMAKE_TOOLCHAIN_FILE=<hyperscan-source-dir>/cmake/arm64-cross.cmake`
44-
- Build Vectorscan:
45-
- `make -jT` where T is the number of threads used to compile.
46-
- `cmake --build . -- -j T` can also be used instead of make.
47-
4832
# Compiling for SVE
4933

5034
The following cmake variables can be set in order to target Arm's Scalable

cmake/arch.cmake

Lines changed: 0 additions & 207 deletions
This file was deleted.

cmake/archdetect.cmake

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
if (USE_CPU_NATIVE)
2+
# Detect best GNUCC_ARCH to tune for
3+
if (CMAKE_COMPILER_IS_GNUCC)
4+
message(STATUS "gcc version ${CMAKE_C_COMPILER_VERSION}")
5+
6+
# If gcc doesn't recognise the host cpu, then mtune=native becomes
7+
# generic, which isn't very good in some cases. march=native looks at
8+
# cpuid info and then chooses the best microarch it can (and replaces
9+
# the flag), so use that for tune.
10+
11+
set(TUNE_FLAG "mtune")
12+
set(GNUCC_TUNE "")
13+
message(STATUS "ARCH_FLAG '${ARCH_FLAG}' '${GNUCC_ARCH}', TUNE_FLAG '${TUNE_FLAG}' '${GNUCC_TUNE}' ")
14+
15+
# arg1 might exist if using ccache
16+
string (STRIP "${CMAKE_C_COMPILER_ARG1}" CC_ARG1)
17+
set (EXEC_ARGS ${CC_ARG1} -c -Q --help=target -${ARCH_FLAG}=native -${TUNE_FLAG}=native)
18+
execute_process(COMMAND ${CMAKE_C_COMPILER} ${EXEC_ARGS}
19+
OUTPUT_VARIABLE _GCC_OUTPUT)
20+
set(_GCC_OUTPUT_TUNE ${_GCC_OUTPUT})
21+
string(FIND "${_GCC_OUTPUT}" "${ARCH_FLAG}=" POS)
22+
string(SUBSTRING "${_GCC_OUTPUT}" ${POS} -1 _GCC_OUTPUT)
23+
string(REGEX REPLACE "${ARCH_FLAG}=[ \t]*([^ \n]*)[ \n].*" "\\1" GNUCC_ARCH "${_GCC_OUTPUT}")
24+
25+
string(FIND "${_GCC_OUTPUT_TUNE}" "${TUNE_FLAG}=" POS_TUNE)
26+
string(SUBSTRING "${_GCC_OUTPUT_TUNE}" ${POS_TUNE} -1 _GCC_OUTPUT_TUNE)
27+
string(REGEX REPLACE "${TUNE_FLAG}=[ \t]*([^ \n]*)[ \n].*" "\\1" GNUCC_TUNE "${_GCC_OUTPUT_TUNE}")
28+
29+
message(STATUS "ARCH_FLAG '${ARCH_FLAG}' '${GNUCC_ARCH}', TUNE_FLAG '${TUNE_FLAG}' '${GNUCC_TUNE}' ")
30+
31+
# test the parsed flag
32+
set (EXEC_ARGS ${CC_ARG1} -E - -${ARCH_FLAG}=${GNUCC_ARCH} -${TUNE_FLAG}=${GNUCC_TUNE})
33+
execute_process(COMMAND ${CMAKE_C_COMPILER} ${EXEC_ARGS}
34+
OUTPUT_QUIET ERROR_QUIET
35+
INPUT_FILE /dev/null
36+
RESULT_VARIABLE GNUCC_TUNE_TEST)
37+
38+
if (NOT GNUCC_TUNE_TEST EQUAL 0)
39+
message(WARNING "Something went wrong determining gcc tune: -mtune=${GNUCC_TUNE} not valid, falling back to -mtune=native")
40+
set(GNUCC_TUNE native)
41+
else()
42+
set(GNUCC_TUNE ${GNUCC_TUNE})
43+
message(STATUS "gcc will tune for ${GNUCC_ARCH}, ${GNUCC_TUNE}")
44+
endif()
45+
elseif (CMAKE_COMPILER_IS_CLANG)
46+
if (ARCH_IA32 OR ARCH_X86_64)
47+
set(GNUCC_ARCH x86_64_v2)
48+
set(TUNE_FLAG generic)
49+
elseif(ARCH_AARCH64)
50+
if (BUILD_SVE2_BITPERM)
51+
set(GNUCC_ARCH ${SVE2_BITPERM_ARCH})
52+
elseif (BUILD_SVE2)
53+
set(GNUCC_ARCH ${SVE2_ARCH})
54+
elseif (BUILD_SVE)
55+
set(GNUCC_ARCH ${SVE_ARCH})
56+
else ()
57+
set(GNUCC_ARCH ${ARMV8_ARCH})
58+
endif()
59+
set(TUNE_FLAG generic)
60+
elseif(ARCH_ARM32)
61+
set(GNUCC_ARCH armv7a)
62+
set(TUNE_FLAG generic)
63+
else()
64+
set(GNUCC_ARCH native)
65+
set(TUNE_FLAG generic)
66+
endif()
67+
message(STATUS "clang will tune for ${GNUCC_ARCH}, ${TUNE_FLAG}")
68+
endif()
69+
else()
70+
if (ARCH_IA32 OR ARCH_X86_64)
71+
set(GNUCC_ARCH native)
72+
set(TUNE_FLAG generic)
73+
elseif(ARCH_AARCH64)
74+
if (BUILD_SVE2_BITPERM)
75+
set(GNUCC_ARCH ${SVE2_BITPERM_ARCH})
76+
elseif (BUILD_SVE2)
77+
set(GNUCC_ARCH ${SVE2_ARCH})
78+
elseif (BUILD_SVE)
79+
set(GNUCC_ARCH ${SVE_ARCH})
80+
else ()
81+
set(GNUCC_ARCH ${ARMV8_ARCH})
82+
endif()
83+
set(TUNE_FLAG generic)
84+
elseif(ARCH_ARM32)
85+
set(GNUCC_ARCH armv7a)
86+
set(TUNE_FLAG generic)
87+
else()
88+
set(GNUCC_ARCH power9)
89+
set(TUNE_FLAG power9)
90+
endif()
91+
endif()

0 commit comments

Comments
 (0)