envoy: fix builds for x86_64-linux and aarch64-linux

* Bumps brotli version to incorporate a fix for some GCC warnings which
  get promoted to errors.
* Switches from wee8 to WAMR because it's easier to make it build
  sensibly on a range of GCC versions that aren't just "whatever ships
  with Ubuntu LTS".
* Adds a patch for WAMR's build in Envoy because it won't build properly
  under Linux aarch64, since WAMR doesn't detect aarch64 unless it's on
  macOS.
This commit is contained in:
Luke Granger-Brown 2022-05-08 21:44:47 +00:00
parent 38be21ac6e
commit defb2298de
3 changed files with 71 additions and 3 deletions

View File

@ -0,0 +1,15 @@
diff --git a/bazel/repository_locations.bzl b/bazel/repository_locations.bzl
index 454c54b0ef..2ac0623cf0 100644
--- a/bazel/repository_locations.bzl
+++ b/bazel/repository_locations.bzl
@@ -510,8 +510,8 @@ REPOSITORY_LOCATIONS_SPEC = dict(
project_url = "https://brotli.org",
# Use the dev branch of brotli to resolve compilation issues.
# TODO(rojkov): Remove when brotli > 1.0.9 is released.
- version = "0cd2e3926e95e7e2930f57ae3f4885508d462a25",
- sha256 = "93810780e60304b51f2c9645fe313a6e4640711063ed0b860cfa60999dd256c5",
+ version = "27dd7265403d8e8fed99a854b9c3e1db7d79525f",
+ sha256 = "e71238b12e30233bdf25997132b29ae49639a69f33fdef3ae18a47abfc0d5e4c",
strip_prefix = "brotli-{version}",
urls = ["https://github.com/google/brotli/archive/{version}.tar.gz"],
use_category = ["dataplane_ext"],

View File

@ -12,6 +12,9 @@
, python3
, linuxHeaders
, nixosTests
# v8 (upstream default), wavm, wamr, wasmtime, disabled
, wasmRuntime ? "wamr"
}:
let
@ -31,7 +34,7 @@ buildBazelPackage rec {
src = fetchFromGitHub {
owner = "envoyproxy";
repo = "envoy";
inherit (srcVer) rev ;
inherit (srcVer) rev;
hash = "sha256:11mm72zmb479ss585jzqzhklyyqmdadnvr91ghzvjxc0j2a1hrr4";
extraPostFetch = ''
@ -58,6 +61,13 @@ buildBazelPackage rec {
url = "https://github.com/envoyproxy/envoy/commit/68448aae7a78a3123097b6ea96016b270457e7b8.patch";
sha256 = "123kv3x37p8fgfp29jhw5xg5js5q5ipibs8hsm7gzfd5bcllnpfh";
})
# fix issues with brotli and GCC 11.2.0+ (-Werror=vla-parameter)
./bump-brotli.patch
# fix linux-aarch64 WAMR builds
# (upstream WAMR only detects aarch64 on Darwin, not Linux)
./fix-aarch64-wamr.patch
];
nativeBuildInputs = [
@ -75,8 +85,8 @@ buildBazelPackage rec {
fetchAttrs = {
sha256 = {
x86_64-linux = "0f7mls2zrpjjvbz6pgkzrvr55bv05xn2l76j9i1r0cf367qqfkz8";
aarch64-linux = "1l3ls47z20xrw6x9qps5jm7vq50xb1acv9gczfdrj9hw6jybgwgg";
x86_64-linux = "0k2cna0vjzc8z7jvxdlcw741vacil8daczppv32bslw17af65vq6";
aarch64-linux = "1ijv4arw67nprykn2wkn4ji8fbr284mc7p74zxfsky772s42yy9j";
}.${stdenv.system} or (throw "unsupported system ${stdenv.system}");
dontUseCmakeConfigure = true;
dontUseGnConfigure = true;
@ -128,6 +138,11 @@ buildBazelPackage rec {
"--cxxopt=-Wno-maybe-uninitialized"
"--cxxopt=-Wno-uninitialized"
"--cxxopt=-Wno-error=type-limits"
"--define=wasm=${wasmRuntime}"
];
bazelFetchFlags = [
"--define=wasm=${wasmRuntime}"
];
passthru.tests = {

View File

@ -0,0 +1,38 @@
diff --git a/bazel/envoy_build_system.bzl b/bazel/envoy_build_system.bzl
index f48ebe7056..1e5cc5d663 100644
--- a/bazel/envoy_build_system.bzl
+++ b/bazel/envoy_build_system.bzl
@@ -102,6 +102,7 @@ def envoy_cmake(
pdb_name = "",
cmake_files_dir = "$BUILD_TMPDIR/CMakeFiles",
generate_crosstool_file = False,
+ generate_args = [],
**kwargs):
cache_entries.update({"CMAKE_BUILD_TYPE": "Bazel"})
cache_entries_debug = dict(cache_entries)
@@ -131,7 +132,7 @@ def envoy_cmake(
"@envoy//bazel:dbg_build": cache_entries_debug,
"//conditions:default": cache_entries,
}),
- generate_args = ["-GNinja"],
+ generate_args = ["-GNinja"] + generate_args,
targets = ["", "install"],
# TODO: Remove install target and make this work
install = False,
diff --git a/bazel/foreign_cc/BUILD b/bazel/foreign_cc/BUILD
index 4d3a281669..b4716dfe2e 100644
--- a/bazel/foreign_cc/BUILD
+++ b/bazel/foreign_cc/BUILD
@@ -394,6 +394,12 @@ envoy_cmake(
"WAMR_BUILD_LIBC_WASI": "0",
"WAMR_BUILD_TAIL_CALL": "1",
},
+ generate_args = select({
+ "//conditions:default": [],
+ "@platforms//cpu:aarch64": [
+ "-DWAMR_BUILD_TARGET=AARCH64",
+ ],
+ }),
lib_source = "@com_github_wamr//:all",
out_static_libs = ["libvmlib.a"],
tags = ["skip_on_windows"],