Skip to content

Commit 6a19b22

Browse files
tedjpoolezmiklank
andcommitted
Convert bssl-compat build from CMake to Bazel
- Uses the @boringssl repo instead of a vendored copy - Added @bssl-compat//test:utests-bssl-compat test target - Added @bssl-compat//test:utests-boringssl test target - Added BoringSSL patch for s390x & ppc64le Signed-off-by: Ted Poole <tpoole@redhat.com> Co-authored-by: Zuzana Miklankova <zmiklank@redhat.com>
1 parent 66aac29 commit 6a19b22

File tree

8,187 files changed

+1426
-2401640
lines changed

Some content is hidden

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

8,187 files changed

+1426
-2401640
lines changed

.github/workflows/envoy-openssl.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
uses: envoyproxy/toolshed/gh-actions/diskspace@actions-v0.3.23
2626
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2727
- run: |
28-
./ci/run_envoy_docker.sh './ci/do_ci.sh gcc //test/...'
28+
./ci/run_envoy_docker.sh './ci/do_ci.sh gcc @bssl-compat//test/... //test/...'
2929
env:
3030
BAZEL_BUILD_EXTRA_OPTIONS: >-
3131
--config=remote-envoy-engflow

WORKSPACE

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ local_repository(
55
path = "bssl-compat",
66
)
77

8+
new_local_repository(
9+
name = "llvm",
10+
path = "/opt/llvm",
11+
build_file = "//bazel/external:llvm.BUILD",
12+
)
13+
814
load("//bazel:api_binding.bzl", "envoy_api_binding")
915

1016
envoy_api_binding()

bazel/BUILD

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,12 +572,12 @@ config_setting(
572572
# Alias pointing to the selected version of BoringSSL:
573573
alias(
574574
name = "boringssl",
575-
actual = "@envoy//bssl-compat:ssl"
575+
actual = "@bssl-compat//:ssl"
576576
)
577-
577+
578578
alias(
579579
name = "boringcrypto",
580-
actual = "@envoy//bssl-compat:crypto"
580+
actual = "@bssl-compat//:crypto"
581581
)
582582

583583
config_setting(

bazel/boringssl-bssl-compat.patch

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
diff --git a/BUILD.bazel b/BUILD.bazel
2+
index b7dc359..cd87639 100644
3+
--- a/BUILD.bazel
4+
+++ b/BUILD.bazel
5+
@@ -66,6 +66,20 @@ license(
6+
7+
exports_files(["LICENSE"])
8+
9+
+# Export additional files for bssl-compat layer
10+
+exports_files(glob(["include/**/*"]))
11+
+exports_files(glob(["crypto/**/*"]))
12+
+exports_files(glob(["ssl/**/*"]))
13+
+
14+
+filegroup(
15+
+ name = "test_data",
16+
+ srcs = glob([
17+
+ "crypto/x509/test/*.pem",
18+
+ "crypto/pkcs8/test/*.p12",
19+
+ ]),
20+
+ visibility = ["//visibility:public"],
21+
+)
22+
+
23+
bssl_cc_library(
24+
name = "crypto",
25+
srcs = bcm_sources + crypto_sources,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/include/openssl/target.h b/include/openssl/target.h
2+
index 8d4763d..79f52ba 100644
3+
--- a/include/openssl/target.h
4+
+++ b/include/openssl/target.h
5+
@@ -54,6 +54,10 @@
6+
#define OPENSSL_32_BIT
7+
#elif defined(__myriad2__)
8+
#define OPENSSL_32_BIT
9+
+#elif defined(__s390__) || defined(__s390x__) || defined(__zarch__)
10+
+#define OPENSSL_64_BIT
11+
+#elif defined(__ppc64le__) || defined(__ARCH_PPC64LE__) || defined(_ARCH_PPC64)
12+
+#define OPENSSL_64_BIT
13+
#else
14+
// The list above enumerates the platforms that BoringSSL supports. For these
15+
// platforms we keep a reasonable bar of not breaking them: automated test

bazel/external/llvm.BUILD

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
load("@rules_cc//cc:defs.bzl", "cc_library")
2+
3+
licenses(["notice"]) # Apache 2
4+
5+
# libclang-cpp from llvm, used by the bssl-compat prefixer tool.
6+
cc_library(
7+
name = "libclang-cpp",
8+
srcs = glob(["lib/libclang-cpp.*"]),
9+
hdrs = glob(["include/**/*"]),
10+
includes = ["include"],
11+
linkopts = ["-lstdc++"],
12+
visibility = ["//visibility:public"],
13+
)
14+
15+
# The clang compiler built-in headers (stdef.h, limits.h etc)
16+
filegroup(
17+
name = "clang-headers",
18+
srcs = glob(["lib/clang/*/include/**/*.h"]),
19+
visibility = ["//visibility:public"],
20+
)

bazel/external/openssl.BUILD

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,18 @@ configure_make(
1717
targets = ["build_sw", "install_sw"],
1818
args = ["-j"],
1919
out_lib_dir = "lib",
20-
out_shared_libs = ["libssl.so.3", "libcrypto.so.3"],
20+
out_shared_libs = [
21+
"libssl.so.3",
22+
"libcrypto.so.3",
23+
"ossl-modules/legacy.so"
24+
],
25+
visibility = ["//visibility:public"],
26+
)
27+
28+
filegroup(
29+
name = "include",
30+
srcs = [":openssl"],
31+
output_group = "include",
2132
visibility = ["//visibility:public"],
2233
)
2334

@@ -35,8 +46,15 @@ filegroup(
3546
visibility = ["//visibility:private"],
3647
)
3748

49+
filegroup(
50+
name = "legacy",
51+
srcs = [":openssl"],
52+
output_group = "legacy.so",
53+
visibility = ["//visibility:private"],
54+
)
55+
3856
filegroup(
3957
name = "libs",
40-
srcs = [":libssl", ":libcrypto"],
58+
srcs = [":libssl", ":libcrypto", ":legacy"],
4159
visibility = ["//visibility:public"],
4260
)

bazel/repositories.bzl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,16 @@ def envoy_dependencies(skip_targets = []):
136136
_foreign_cc_dependencies()
137137

138138
_openssl()
139+
_boringssl()
139140

140141
# Binding to an alias pointing to the bssl-compat layer
141142
native.bind(
142143
name = "ssl",
143-
actual = "@envoy//bssl-compat:ssl",
144+
actual = "@bssl-compat//:ssl",
144145
)
145146
native.bind(
146147
name = "crypto",
147-
actual = "@envoy//bssl-compat:crypto",
148+
actual = "@bssl-compat//:crypto",
148149
)
149150

150151
# The long repo names (`com_github_fmtlib_fmt` instead of `fmtlib`) are
@@ -261,7 +262,14 @@ def envoy_dependencies(skip_targets = []):
261262
)
262263

263264
def _boringssl():
264-
external_http_archive(name = "boringssl")
265+
external_http_archive(
266+
name = "boringssl",
267+
patches = [
268+
"@envoy//bazel:boringssl-bssl-compat.patch",
269+
"@envoy//bazel:boringssl-s390x-ppc64le.patch",
270+
],
271+
patch_args = ["-p1"],
272+
)
265273

266274
def _boringssl_fips():
267275
external_http_archive(

0 commit comments

Comments
 (0)