11load ("@rules_cc//cc:defs.bzl" , "cc_library" )
22
33# Generate config.h for ARM
4+ # Uses C preprocessor to conditionally define HAVE__BUILTIN_CONSTANT_P based on compiler.
5+ # GCC optimizes __builtin_constant_p() properly, but Clang doesn't optimize away the
6+ # dead branch the same way, causing compile errors with ARM NEON intrinsics that require
7+ # constant arguments.
8+ # See: https://github.com/VectorCamp/vectorscan/blob/6bb8733e93f97a0e55b858ecd4e17d7e7b52619c/cmake/cflags-generic.cmake#L61-L64
49genrule (
510 name = "config_h" ,
611 outs = ["config.h" ],
@@ -10,13 +15,18 @@ genrule(
1015
1116#define ARCH_64_BIT
1217#define ARCH_AARCH64
18+ #define HAVE_C_ARM_NEON_H
1319#define HAVE_NEON
1420#define HAVE_SIMD_128_BITS
1521#define HAVE_CC_BUILTIN_ASSUME_ALIGNED
1622#define HAVE_CXX_BUILTIN_ASSUME_ALIGNED
1723#define HAVE_POSIX_MEMALIGN
1824#define HAVE_UNISTD_H
25+ /* Clang does not use __builtin_constant_p() the same way as GCC.
26+ * Only define for GCC to avoid ARM NEON intrinsic errors with Clang. */
27+ #if defined(__GNUC__) && !defined(__clang__)
1928#define HAVE__BUILTIN_CONSTANT_P
29+ #endif
2030#define HS_OPTIMIZE
2131#define HS_VERSION "5.4.11"
2232#define HS_MAJOR_VERSION 5
@@ -81,7 +91,6 @@ cc_library(
8191 "src/**/*.hpp" ,
8292 ]),
8393 copts = [
84- "-std=c99" ,
8594 "-O3" ,
8695 "-DNDEBUG" ,
8796 "-fno-strict-aliasing" ,
@@ -117,7 +126,6 @@ cc_library(
117126 "src/som/*.c" ,
118127 "src/util/simd_utils.c" ,
119128 "src/util/state_compress.c" ,
120- "src/util/supervector/arch/arm/impl.cpp" ,
121129 ],
122130 exclude = [
123131 "src/**/*_dump*.c" ,
@@ -131,9 +139,11 @@ cc_library(
131139 ],
132140 hdrs = glob ([
133141 "src/**/*.h" ,
134- ]),
142+ ]) + [
143+ ":config_h" ,
144+ ],
145+ textual_hdrs = ["src/util/supervector/arch/arm/impl.cpp" ],
135146 copts = [
136- "-std=c99" ,
137147 "-O3" ,
138148 "-DNDEBUG" ,
139149 "-fno-strict-aliasing" ,
@@ -188,14 +198,14 @@ cc_library(
188198 ":hs_version_h" ,
189199 ],
190200 copts = [
191- "-std=c++11" ,
192201 "-O2" ,
193202 "-DNDEBUG" ,
194203 "-fno-strict-aliasing" ,
195204 "-Wno-unused-parameter" ,
196205 "-Wno-sign-compare" ,
197206 "-Wno-unused-variable" ,
198207 "-Wno-unused-but-set-variable" ,
208+ "-std=c++17" ,
199209 ],
200210 includes = [
201211 "." ,
0 commit comments