Skip to content

Commit 50a1f85

Browse files
committed
Allow kernels to be explicitly enabled/disabled
Distributions may want to enable/disable specific parser kernels. The use case is not recommended, but is supported. Fixes NLnetLabs#172.
1 parent 2bcea0d commit 50a1f85

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

CMakeLists.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ endif()
4646
option(BUILD_TESTING "Build the testing tree." OFF)
4747
option(BUILD_DOCUMENTATION "Build documentation." OFF)
4848

49+
option(WESTMERE "Build Westmere (SSE4.2) kernel for x86_64" ON)
50+
option(HASWELL "Build Haswell (AVX2) kernel for x86_64" ON)
51+
4952
if(CMAKE_VERSION VERSION_LESS 3.20)
5053
# CMAKE_<LANG>_BYTE_ORDER was added in version 3.20. Mimic the option in
5154
# prior versions.
@@ -181,7 +184,7 @@ if(architecture STREQUAL "x86_64" OR architecture STREQUAL "amd64")
181184
check_c_compiler_flag("-march=westmere" HAVE_MARCH_WESTMERE)
182185
check_c_compiler_flag("-march=haswell" HAVE_MARCH_HASWELL)
183186

184-
if(HAVE_IMMINTRIN_H AND HAVE_MARCH_WESTMERE)
187+
if(WESTMERE AND HAVE_IMMINTRIN_H AND HAVE_MARCH_WESTMERE)
185188
set(HAVE_WESTMERE TRUE)
186189
set_source_files_properties(
187190
src/westmere/parser.c PROPERTIES COMPILE_FLAGS "-march=westmere")
@@ -191,7 +194,7 @@ if(architecture STREQUAL "x86_64" OR architecture STREQUAL "amd64")
191194
target_sources(zone-bench PRIVATE src/westmere/bench.c)
192195
endif()
193196

194-
if(HAVE_IMMINTRIN_H AND HAVE_MARCH_HASWELL)
197+
if(HASWELL AND HAVE_IMMINTRIN_H AND HAVE_MARCH_HASWELL)
195198
set(HAVE_HASWELL TRUE)
196199
set_source_files_properties(
197200
src/haswell/parser.c PROPERTIES COMPILE_FLAGS "-march=haswell")

configure.ac

+16-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ AC_CONFIG_FILES([Makefile])
1818
m4_include(m4/ax_check_compile_flag.m4)
1919
m4_version_prereq([2.70], [AC_PROG_CC], [AC_PROG_CC_STDC])
2020

21+
AC_ARG_ENABLE(westmere, AS_HELP_STRING([--disable-westmere],[Disable Westmere (SSE4.2) kernel]))
22+
case "$enable_westmere" in
23+
no) enable_westmere=no ;;
24+
yes|*) enable_westmere=yes ;;
25+
esac
26+
27+
AC_ARG_ENABLE(haswell, AS_HELP_STRING([--disable-haswell],[Disable Haswell (AVX2) kernel]))
28+
case "$enable_haswell" in
29+
no) enable_haswell=no ;;
30+
yes|*) enable_haswell=yes ;;
31+
esac
32+
2133
# Figure out the canonical target architecture.
2234
AC_CANONICAL_TARGET
2335

@@ -36,7 +48,8 @@ if test $x86_64 = "yes"; then
3648
AX_CHECK_COMPILE_FLAG([-march=westmere],,,[-Werror])
3749
AX_CHECK_COMPILE_FLAG([-march=haswell],,,[-Werror])
3850

39-
if test $ac_cv_header_immintrin_h = "yes" -a \
51+
if test $enable_westmere != "no" -a \
52+
$ac_cv_header_immintrin_h = "yes" -a \
4053
$ax_cv_check_cflags__Werror__march_westmere = "yes"
4154
then
4255
AC_DEFINE(HAVE_WESTMERE, 1, [Wether or not to compile support for SSE4.2])
@@ -45,7 +58,8 @@ if test $x86_64 = "yes"; then
4558
HAVE_WESTMERE=NO
4659
fi
4760

48-
if test $ac_cv_header_immintrin_h = "yes" -a \
61+
if test $enable_haswell != "no" -a \
62+
$ac_cv_header_immintrin_h = "yes" -a \
4963
$ax_cv_check_cflags__Werror__march_haswell = "yes"
5064
then
5165
AC_DEFINE(HAVE_HASWELL, 1, [Wether or not to compile support for AVX2])

0 commit comments

Comments
 (0)