Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ build --cxxopt=-std=c++20 --host_cxxopt=-std=c++20
build --copt=-Wno-deprecated-declarations
build --define envoy_mobile_listener=enabled
build --experimental_repository_downloader_retries=2
build --experimental_cc_static_library
build --enable_platform_specific_config
build --incompatible_merge_fixed_and_default_shell_env
# A workaround for slow ICU download.
Expand Down
46 changes: 34 additions & 12 deletions bazel/external/numactl.BUILD
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Copied from https://github.com/bazelbuild/bazel-central-registry/blob/main/modules/numactl/2.0.19/overlay/BUILD.bazel

load("@bazel_skylib//rules:write_file.bzl", "write_file")
load(
"@envoy//contrib:all_contrib_extensions.bzl",
"envoy_contrib_linux_x86_64_constraints",
)
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_static_library.bzl", "cc_static_library")

LINUX_ONLY = select({
"@platforms//os:linux": [],
"//conditions:default": ["@platforms//:incompatible"],
})

# Generate config.h
write_file(
Expand Down Expand Up @@ -82,7 +84,7 @@ cc_library(
copts = COMMON_COPTS,
includes = ["."],
linkstatic = True,
target_compatible_with = envoy_contrib_linux_x86_64_constraints(),
target_compatible_with = LINUX_ONLY,
visibility = ["//visibility:public"],
alwayslink = True,
)
Expand All @@ -98,7 +100,7 @@ cc_library(
copts = COMMON_COPTS,
includes = ["."],
linkstatic = True,
target_compatible_with = envoy_contrib_linux_x86_64_constraints(),
target_compatible_with = LINUX_ONLY,
visibility = ["//visibility:public"],
deps = [":numa"],
alwayslink = True,
Expand All @@ -115,7 +117,7 @@ cc_binary(
],
copts = COMMON_COPTS + ["-DVERSION=\\\"2.0.19\\\""],
linkstatic = True,
target_compatible_with = envoy_contrib_linux_x86_64_constraints(),
target_compatible_with = LINUX_ONLY,
visibility = ["//visibility:public"],
deps = [
":numa",
Expand All @@ -134,7 +136,7 @@ cc_binary(
"-std=gnu99",
"-DVERSION=\\\"2.0.19\\\"",
],
target_compatible_with = envoy_contrib_linux_x86_64_constraints(),
target_compatible_with = LINUX_ONLY,
visibility = ["//visibility:public"],
)

Expand All @@ -161,7 +163,7 @@ cc_binary(
],
linkopts = ["-lm"],
linkstatic = True,
target_compatible_with = envoy_contrib_linux_x86_64_constraints(),
target_compatible_with = LINUX_ONLY,
visibility = ["//visibility:public"],
deps = [
":numa",
Expand All @@ -178,7 +180,7 @@ cc_binary(
],
copts = COMMON_COPTS,
linkstatic = True,
target_compatible_with = envoy_contrib_linux_x86_64_constraints(),
target_compatible_with = LINUX_ONLY,
visibility = ["//visibility:public"],
deps = [
":numa",
Expand All @@ -195,7 +197,7 @@ cc_binary(
],
copts = COMMON_COPTS,
linkstatic = True,
target_compatible_with = envoy_contrib_linux_x86_64_constraints(),
target_compatible_with = LINUX_ONLY,
visibility = ["//visibility:public"],
deps = [
":numa",
Expand All @@ -212,7 +214,7 @@ cc_binary(
],
copts = COMMON_COPTS,
linkstatic = True,
target_compatible_with = envoy_contrib_linux_x86_64_constraints(),
target_compatible_with = LINUX_ONLY,
visibility = ["//visibility:public"],
deps = [
":numa",
Expand All @@ -226,3 +228,23 @@ alias(
actual = ":numa",
visibility = ["//visibility:public"],
)

# Create a proper static library archive from the cc_library.
cc_static_library(
name = "numa_static",
target_compatible_with = LINUX_ONLY,
deps = [":numa"],
)

# Create a properly named libnuma.a archive for foreign_cc dependencies.
# The cc_library above produces Bazel-internal archives, but foreign_cc
# configure_make rules (like qatlib) expect a traditional libnuma.a file
# that can be found with -lnuma.
genrule(
name = "numa_archive",
srcs = [":numa_static"],
outs = ["lib/libnuma.a"],
cmd = "mkdir -p $$(dirname $@) && cp $< $@",
target_compatible_with = LINUX_ONLY,
visibility = ["//visibility:public"],
)
20 changes: 19 additions & 1 deletion bazel/foreign_cc/qatzstd.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/src/Makefile b/src/Makefile
index 6b35340..5c81d74 100644
index 6b35340..b45e528 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -57,13 +57,13 @@ ifneq ($(ICP_ROOT), )
Expand All @@ -18,3 +18,21 @@ index 6b35340..5c81d74 100644
endif

ifdef ZSTDLIB
@@ -101,17 +101,11 @@ qatseqprod.o: qatseqprod.c

lib: qatseqprod.o
$(AR) rc libqatseqprod.a $^
- $(CC) -shared $^ $(LDFLAGS) -Wl,-soname,libqatseqprod.so.$(VERSION_MAJOR) -o libqatseqprod.so.$(VERSION)
- ln -sf libqatseqprod.so.$(VERSION) libqatseqprod.so.$(VERSION_MAJOR)
- ln -sf libqatseqprod.so.$(VERSION_MAJOR) libqatseqprod.so

.PHONY: install
install: lib
[ -e $(DESTDIR)$(LIBDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/
[ -e $(DESTDIR)$(INCLUDEDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(INCLUDEDIR)/
- $(INSTALL_PROGRAM) libqatseqprod.so.$(VERSION) $(DESTDIR)$(LIBDIR)
- ln -sf libqatseqprod.so.$(VERSION) $(DESTDIR)$(LIBDIR)/libqatseqprod.so.$(VERSION_MAJOR)
- ln -sf libqatseqprod.so.$(VERSION_MAJOR) $(DESTDIR)$(LIBDIR)/libqatseqprod.so
$(INSTALL_DATA) libqatseqprod.a $(DESTDIR)$(LIBDIR)
$(INSTALL_DATA) qatseqprod.h $(DESTDIR)$(INCLUDEDIR)
@echo qatseqprod library successfully installed
11 changes: 11 additions & 0 deletions contrib/qat/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ configure_make(
"--enable-static",
"--enable-samples=no",
],
# Include the numa_archive genrule output so that libnuma.a is available
# for the linker to find with -lnuma.
data = [
"@numactl//:numa_archive",
],
# Point to the directory containing the libnuma.a archive created by the
# numa_archive genrule. The cc_library doesn't produce a file that can be
# found with -lnuma, so we need to use the genrule output.
env = {
"LDFLAGS": "-L$$EXT_BUILD_ROOT/$(BINDIR)/external/numactl/lib",
},
lib_source = "@com_github_intel_qatlib//:all",
out_static_libs = [
"libqat.a",
Expand Down
17 changes: 15 additions & 2 deletions contrib/qat/compression/qatzip/compressor/source/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ licenses(["notice"]) # Apache 2

envoy_contrib_package()

COMMON_ENV = {
"LDFLAGS": "-L$$EXT_BUILD_ROOT/$(BINDIR)/external/numactl/lib",
}

configure_make(
name = "qatzip",
autogen = True,
Expand All @@ -22,11 +26,19 @@ configure_make(
"--enable-static",
"--disable-shared",
],
# Include the numa_archive genrule output so that libnuma.a is available
# for the linker to find with -lnuma.
data = [
"@numactl//:numa_archive",
],
# Point to the directory containing the libnuma.a archive created by the
# numa_archive genrule. The cc_library doesn't produce a file that can be
# found with -lnuma, so we need to use the genrule output.
env = select({
"//bazel:clang_build": {
"//bazel:clang_build": COMMON_ENV | {
"CFLAGS": "-Wno-error=newline-eof -Wno-error=strict-prototypes -Wno-error=unused-but-set-variable",
},
"//conditions:default": {},
"//conditions:default": COMMON_ENV,
}),
lib_source = "@com_github_intel_qatzip//:all",
out_static_libs = [
Expand All @@ -41,6 +53,7 @@ configure_make(
"//contrib/qat:qatlib",
# Use boringssl alias to select fips vs non-fips version.
"//bazel:boringcrypto",
"@numactl//:numa",
],
alwayslink = False,
)
Expand Down
20 changes: 16 additions & 4 deletions contrib/qat/compression/qatzstd/compressor/source/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,29 @@ licenses(["notice"]) # Apache 2

envoy_contrib_package()

common_env = {
COMMON_ENV = {
"ZSTDLIB": "$$EXT_BUILD_ROOT/external/zstd/lib",
"QAT_INCLUDE_PATH": "$$EXT_BUILD_DEPS/qatlib/include/qat",
"LDFLAGS": "-L$$EXT_BUILD_ROOT/$(BINDIR)/external/numactl/lib",
}

COMMON_CFLAGS = "-I$$EXT_BUILD_ROOT/external/numactl"

make(
name = "qat-zstd",
build_data = ["@com_github_qat_zstd//:all"],
# Include the numa_archive genrule output so that libnuma.a is available
# for the linker to find with -lnuma.
data = [
"@numactl//:numa_archive",
],
env = select({
"//bazel:clang_build": common_env | {
"CFLAGS": "-Wno-error=unused-parameter -Wno-error=unused-command-line-argument",
"//bazel:clang_build": COMMON_ENV | {
"CFLAGS": COMMON_CFLAGS + " -Wno-error=unused-parameter -Wno-error=unused-command-line-argument",
},
"//conditions:default": COMMON_ENV | {
"CFLAGS": COMMON_CFLAGS,
},
"//conditions:default": common_env,
}),
includes = [],
lib_source = "@com_github_qat_zstd//:all",
Expand All @@ -39,6 +49,8 @@ make(
deps = [
"//contrib/qat:qatlib",
"@zstd",
# numactl headers are needed for compilation
"@numactl//:numa",
],
)

Expand Down