diff --git a/bazel/foreign_cc/BUILD b/bazel/foreign_cc/BUILD index 8d1a0d6cd2d8..5776eb10b0ba 100644 --- a/bazel/foreign_cc/BUILD +++ b/bazel/foreign_cc/BUILD @@ -119,7 +119,7 @@ configure_make( # Workaround for the issue with statically linked libstdc++ # using -l:libstdc++.a. env = { - "CXXFLAGS": "-lstdc++ -Wno-unused-command-line-argument", + "CXXFLAGS": "--static -lstdc++ -Wno-unused-command-line-argument", }, lib_source = "@net_colm_open_source_colm//:all", out_binaries = ["colm"], @@ -141,7 +141,7 @@ configure_make( # Workaround for the issue with statically linked libstdc++ # using -l:libstdc++.a. env = { - "CXXFLAGS": "-lstdc++ -Wno-unused-command-line-argument", + "CXXFLAGS": "--static -lstdc++ -Wno-unused-command-line-argument", }, lib_source = "@net_colm_open_source_ragel//:all", out_binaries = ["ragel"], diff --git a/bazel/foreign_cc/vectorscan.patch b/bazel/foreign_cc/vectorscan.patch new file mode 100644 index 000000000000..2ff5aab68bc1 --- /dev/null +++ b/bazel/foreign_cc/vectorscan.patch @@ -0,0 +1,33 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 1db128b..ee3b4a9 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -27,7 +27,7 @@ include (${CMAKE_MODULE_PATH}/platform.cmake) + include (${CMAKE_MODULE_PATH}/boost.cmake) + include (${CMAKE_MODULE_PATH}/ragel.cmake) + +-find_package(PkgConfig REQUIRED) ++find_package(PkgConfig QUIET) + + find_program(RAGEL ragel) + +diff --git a/cmake/sqlite3.cmake b/cmake/sqlite3.cmake +index 92b18ce..5291726 100644 +--- a/cmake/sqlite3.cmake ++++ b/cmake/sqlite3.cmake +@@ -2,6 +2,8 @@ + # a lot of noise to find sqlite + # + ++if(NOT SQLITE_SKIP_CHECK) ++ + option(SQLITE_PREFER_STATIC "Build sqlite3 statically instead of using an installed lib" OFF) + + if(NOT SQLITE_PREFER_STATIC) +@@ -33,4 +35,6 @@ else() + endif() + endif() + ++endif() ++ + # that's enough about sqlite diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index e1cbf867cefb..b48e3b0cc6f1 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -1,8 +1,8 @@ -load(":dev_binding.bzl", "envoy_dev_binding") +load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language") load("@envoy_api//bazel:envoy_http_archive.bzl", "envoy_http_archive") load("@envoy_api//bazel:external_deps.bzl", "load_repository_locations") +load(":dev_binding.bzl", "envoy_dev_binding") load(":repository_locations.bzl", "PROTOC_VERSIONS", "REPOSITORY_LOCATIONS_SPEC") -load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language") PPC_SKIP_TARGETS = ["envoy.filters.http.lua"] @@ -311,6 +311,7 @@ def envoy_dependencies(skip_targets = []): _com_github_google_quiche() _com_googlesource_googleurl() _io_hyperscan() + _io_vectorscan() _io_opentracing_cpp() _net_colm_open_source_colm() _net_colm_open_source_ragel() @@ -710,6 +711,15 @@ def _io_hyperscan(): patches = ["@envoy//bazel/foreign_cc:hyperscan.patch"], ) +def _io_vectorscan(): + external_http_archive( + name = "io_vectorscan", + build_file_content = BUILD_ALL_CONTENT, + type = "tar.gz", + patch_args = ["-p1"], + patches = ["@envoy//bazel/foreign_cc:vectorscan.patch"], + ) + def _io_opentracing_cpp(): external_http_archive( name = "io_opentracing_cpp", diff --git a/bazel/repository_locations.bzl b/bazel/repository_locations.bzl index 223629179243..7f6ffb586faf 100644 --- a/bazel/repository_locations.bzl +++ b/bazel/repository_locations.bzl @@ -499,6 +499,24 @@ REPOSITORY_LOCATIONS_SPEC = dict( license = "BSD-3-Clause", license_url = "https://github.com/intel/hyperscan/blob/v{version}/LICENSE", ), + io_vectorscan = dict( + project_name = "Vectorscan", + project_desc = "Hyperscan port for additional CPU architectures", + project_url = "https://www.vectorcamp.gr/vectorscan/", + version = "5.4.11", + sha256 = "905f76ad1fa9e4ae0eb28232cac98afdb96c479666202c5a4c27871fb30a2711", + strip_prefix = "vectorscan-vectorscan-{version}", + urls = ["https://codeload.github.com/VectorCamp/vectorscan/tar.gz/refs/tags/vectorscan/{version}"], + use_category = ["dataplane_ext"], + extensions = [ + "envoy.matching.input_matchers.hyperscan", + "envoy.regex_engines.hyperscan", + ], + release_date = "2023-11-20", + cpe = "N/A", + license = "BSD-3-Clause", + license_url = "https://github.com/VectorCamp/vectorscan/blob/vectorscan/{version}/LICENSE", + ), io_opentracing_cpp = dict( project_name = "OpenTracing", project_desc = "Vendor-neutral APIs and instrumentation for distributed tracing", diff --git a/contrib/all_contrib_extensions.bzl b/contrib/all_contrib_extensions.bzl index 005cffb3c097..d79bbcc7779c 100644 --- a/contrib/all_contrib_extensions.bzl +++ b/contrib/all_contrib_extensions.bzl @@ -7,12 +7,16 @@ def envoy_contrib_linux_x86_64_constraints(): "@platforms//cpu:x86_64", ] +def envoy_contrib_linux_aarch64_constraints(): + return [ + "@platforms//os:linux", + "@platforms//cpu:aarch64", + ] + ARM64_SKIP_CONTRIB_TARGETS = [ "envoy.tls.key_providers.cryptomb", "envoy.tls.key_providers.qat", - "envoy.matching.input_matchers.hyperscan", "envoy.network.connection_balance.dlb", - "envoy.regex_engines.hyperscan", ] PPC_SKIP_CONTRIB_TARGETS = [ "envoy.tls.key_providers.cryptomb", diff --git a/contrib/hyperscan/matching/input_matchers/source/BUILD b/contrib/hyperscan/matching/input_matchers/source/BUILD index 5342badb28d1..f41023076bcd 100644 --- a/contrib/hyperscan/matching/input_matchers/source/BUILD +++ b/contrib/hyperscan/matching/input_matchers/source/BUILD @@ -11,6 +11,7 @@ load( ) load( "//contrib:all_contrib_extensions.bzl", + "envoy_contrib_linux_aarch64_constraints", "envoy_contrib_linux_x86_64_constraints", ) @@ -41,8 +42,34 @@ envoy_cmake( ], ) +envoy_cmake( + name = "vectorscan", + build_data = ["@org_boost//:header"], + cache_entries = { + "BOOST_ROOT": "$EXT_BUILD_ROOT/external/org_boost", + # "BUILD_SVE2_BITPERM": "on", + # "BUILD_SVE2": "on", + # "BUILD_SVE": "on", + "BUILD_EXAMPLES": "off", + "BUILD_SHARED_LIBS": "off", + "CMAKE_BUILD_TYPE": "Release", + "CMAKE_INSTALL_LIBDIR": "lib", + "FAT_RUNTIME": "off", + "SQLITE_SKIP_CHECK": "on", + "RAGEL": "$EXT_BUILD_DEPS/ragel/bin/ragel", + }, + default_cache_entries = {}, + lib_source = "@io_vectorscan//:all", + out_static_libs = ["libhs.a"], + tags = ["skip_on_windows"], + target_compatible_with = envoy_contrib_linux_aarch64_constraints(), + deps = [ + envoy_external_dep_path("ragel"), + ], +) + envoy_cc_library( - name = "matcher_lib", + name = "hyperscan_matcher_lib", srcs = ["matcher.cc"], hdrs = ["matcher.h"], deps = [ @@ -53,12 +80,25 @@ envoy_cc_library( ], ) +envoy_cc_library( + name = "vectorscan_matcher_lib", + srcs = ["matcher.cc"], + hdrs = ["matcher.h"], + deps = [ + ":vectorscan", + "//envoy/common:regex_interface", + "//envoy/matcher:matcher_interface", + "//envoy/thread_local:thread_local_interface", + ], +) + envoy_cc_contrib_extension( name = "config", srcs = ["config.cc"], hdrs = ["config.h"], defines = select({ "//bazel:linux_x86_64": [], + "//bazel:linux_aarch64": [], "//conditions:default": [ "HYPERSCAN_DISABLED=1", ], @@ -71,7 +111,10 @@ envoy_cc_contrib_extension( "@envoy_api//contrib/envoy/extensions/matching/input_matchers/hyperscan/v3alpha:pkg_cc_proto", ] + select({ "//bazel:linux_x86_64": [ - ":matcher_lib", + ":hyperscan_matcher_lib", + ], + "//bazel:linux_aarch64": [ + ":vectorscan_matcher_lib", ], "//conditions:default": [ ], diff --git a/contrib/hyperscan/matching/input_matchers/test/BUILD b/contrib/hyperscan/matching/input_matchers/test/BUILD index 9957b2a660d6..aa1ebb140fbe 100644 --- a/contrib/hyperscan/matching/input_matchers/test/BUILD +++ b/contrib/hyperscan/matching/input_matchers/test/BUILD @@ -22,12 +22,18 @@ envoy_cc_test( name = "matcher_test", srcs = ["matcher_test.cc"], deps = [ - "//contrib/hyperscan/matching/input_matchers/source:matcher_lib", "//source/common/thread_local:thread_local_lib", "//test/mocks/event:event_mocks", "//test/mocks/thread_local:thread_local_mocks", "//test/test_common:utility_lib", - ], + ] + select({ + "//bazel:linux_x86_64": [ + "//contrib/hyperscan/matching/input_matchers/source:hyperscan_matcher_lib", + ], + "//bazel:linux_aarch64": [ + "//contrib/hyperscan/matching/input_matchers/source:vectorscan_matcher_lib", + ], + }), ) envoy_cc_benchmark_binary( @@ -35,11 +41,17 @@ envoy_cc_benchmark_binary( srcs = ["hyperscan_speed_test.cc"], external_deps = ["benchmark"], deps = [ - "//contrib/hyperscan/matching/input_matchers/source:hyperscan", "//source/common/common:assert_lib", "//source/common/common:utility_lib", "@com_googlesource_code_re2//:re2", - ], + ] + select({ + "//bazel:linux_x86_64": [ + "//contrib/hyperscan/matching/input_matchers/source:hyperscan", + ], + "//bazel:linux_aarch64": [ + "//contrib/hyperscan/matching/input_matchers/source:vectorscan", + ], + }), ) envoy_cc_benchmark_binary( @@ -47,11 +59,17 @@ envoy_cc_benchmark_binary( srcs = ["matcher_speed_test.cc"], external_deps = ["benchmark"], deps = [ - "//contrib/hyperscan/matching/input_matchers/source:matcher_lib", "//source/common/common:assert_lib", "//source/common/common:regex_lib", "//source/common/common:utility_lib", "//source/common/thread_local:thread_local_lib", "//test/mocks/event:event_mocks", - ], + ] + select({ + "//bazel:linux_x86_64": [ + "//contrib/hyperscan/matching/input_matchers/source:hyperscan_matcher_lib", + ], + "//bazel:linux_aarch64": [ + "//contrib/hyperscan/matching/input_matchers/source:vectorscan_matcher_lib", + ], + }), ) diff --git a/contrib/hyperscan/regex_engines/source/BUILD b/contrib/hyperscan/regex_engines/source/BUILD index 2882492ccdfa..f4555dc97131 100644 --- a/contrib/hyperscan/regex_engines/source/BUILD +++ b/contrib/hyperscan/regex_engines/source/BUILD @@ -14,9 +14,15 @@ envoy_cc_library( srcs = ["regex.cc"], hdrs = ["regex.h"], deps = [ - "//contrib/hyperscan/matching/input_matchers/source:matcher_lib", "//envoy/common:regex_interface", - ], + ] + select({ + "//bazel:linux_x86_64": [ + "//contrib/hyperscan/matching/input_matchers/source:hyperscan_matcher_lib", + ], + "//bazel:linux_aarch64": [ + "//contrib/hyperscan/matching/input_matchers/source:vectorscan_matcher_lib", + ], + }), ) envoy_cc_contrib_extension( @@ -25,6 +31,7 @@ envoy_cc_contrib_extension( hdrs = ["config.h"], defines = select({ "//bazel:linux_x86_64": [], + "//bazel:linux_aarch64": [], "//conditions:default": [ "HYPERSCAN_DISABLED=1", ], @@ -36,6 +43,9 @@ envoy_cc_contrib_extension( "//bazel:linux_x86_64": [ ":regex_lib", ], + "//bazel:linux_aarch64": [ + ":regex_lib", + ], "//conditions:default": [ ], }),