Skip to content

Commit

Permalink
feat(build): add wasmx to arm64 build matrix (#11290)
Browse files Browse the repository at this point in the history
  • Loading branch information
flrgh authored Jul 26, 2023
1 parent ce9813a commit b4f328e
Show file tree
Hide file tree
Showing 7 changed files with 264 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/matrix-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ build-packages:
- label: ubuntu-22.04-arm64
os: ubuntu-22.04
package: deb
bazel-args: --platforms=//:generic-crossbuild-aarch64 --//:wasmx=false
bazel-args: --platforms=//:generic-crossbuild-aarch64
check-manifest-suite: ubuntu-22.04-arm64

# Debian
Expand Down
72 changes: 72 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,30 @@ config_setting(
visibility = ["//visibility:public"],
)

config_setting(
name = "wasmx_v8_x86_64",
constraint_values = [
"@platforms//cpu:x86_64",
],
flag_values = {
":wasmx": "true",
":wasm_runtime": "v8",
},
visibility = ["//visibility:public"],
)

config_setting(
name = "wasmx_v8_aarch64",
constraint_values = [
"@platforms//cpu:aarch64",
],
flag_values = {
":wasmx": "true",
":wasm_runtime": "v8",
},
visibility = ["//visibility:public"],
)

config_setting(
name = "wasmx_wasmer",
flag_values = {
Expand All @@ -246,6 +270,30 @@ config_setting(
visibility = ["//visibility:public"],
)

config_setting(
name = "wasmx_wasmer_x86_64",
constraint_values = [
"@platforms//cpu:x86_64",
],
flag_values = {
":wasmx": "true",
":wasm_runtime": "wasmer",
},
visibility = ["//visibility:public"],
)

config_setting(
name = "wasmx_wasmer_aarch64",
constraint_values = [
"@platforms//cpu:aarch64",
],
flag_values = {
":wasmx": "true",
":wasm_runtime": "wasmer",
},
visibility = ["//visibility:public"],
)

config_setting(
name = "wasmx_wasmtime",
flag_values = {
Expand All @@ -255,6 +303,30 @@ config_setting(
visibility = ["//visibility:public"],
)

config_setting(
name = "wasmx_wasmtime_x86_64",
constraint_values = [
"@platforms//cpu:x86_64",
],
flag_values = {
":wasmx": "true",
":wasm_runtime": "wasmtime",
},
visibility = ["//visibility:public"],
)

config_setting(
name = "wasmx_wasmtime_aarch64",
constraint_values = [
"@platforms//cpu:aarch64",
],
flag_values = {
":wasmx": "true",
":wasm_runtime": "wasmtime",
},
visibility = ["//visibility:public"],
)

##### dynamic modules
selects.config_setting_group(
name = "nginx_dynamic_module_support",
Expand Down
21 changes: 15 additions & 6 deletions build/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,23 @@ install_webui_cmd = select({
})

wasmx_vm_deps = select({
"@kong//:wasmx_v8": [
"@v8//:lib",
"@kong//:wasmx_v8_x86_64": [
"@v8-x86_64//:lib",
],
"@kong//:wasmx_wasmer": [
"@wasmer//:lib",
"@kong//:wasmx_v8_aarch64": [
"@v8-aarch64//:lib",
],
"@kong//:wasmx_wasmtime": [
"@wasmtime//:lib",
"@kong//:wasmx_wasmer_x86_64": [
"@wasmer-x86_64//:lib",
],
"@kong//:wasmx_wasmer_aarch64": [
"@wasmer-aarch64//:lib",
],
"@kong//:wasmx_wasmtime_x86_64": [
"@wasmtime-x86_64//:lib",
],
"@kong//:wasmx_wasmtime_aarch64": [
"@wasmtime-aarch64//:lib",
],
"//conditions:default": [],
})
Expand Down
9 changes: 0 additions & 9 deletions build/kong_bindings.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,6 @@ def _load_vars(ctx):
content += '"WASMER_OS": "linux",'
content += '"WASMTIME_OS": "linux",'

if ctx.os.arch == "amd64" or ctx.os.arch == "x86_64":
content += '"V8_ARCH": "x86_64",'
content += '"WASMER_ARCH": "amd64",'
content += '"WASMTIME_ARCH": "x86_64",'
elif ctx.os.arch == "aarch64":
content += '"V8_ARCH": "FIXME",' # no releases available atm
content += '"WASMER_ARCH": "aarch64",'
content += '"WASMTIME_ARCH": "aarch64",'

ctx.file("BUILD.bazel", "")
ctx.file("variables.bzl", "KONG_VAR = {\n" + content + "\n}")

Expand Down
111 changes: 83 additions & 28 deletions build/openresty/BUILD.openresty.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -254,21 +254,39 @@ CONFIGURE_OPTIONS = [
],
"//conditions:default": [],
}) + select({
"@kong//:wasmx_v8": [
"--with-cc-opt=\"-I$$EXT_BUILD_ROOT$$/external/v8/include\"",
"--with-ld-opt=\"-L$$EXT_BUILD_ROOT$$/external/v8/lib\"",
"@kong//:wasmx_v8_x86_64": [
"--with-cc-opt=\"-I$$EXT_BUILD_ROOT$$/external/v8-x86_64/include\"",
"--with-ld-opt=\"-L$$EXT_BUILD_ROOT$$/external/v8-x86_64/lib\"",
],
"//conditions:default": [],
}) + select({
"@kong//:wasmx_wasmer": [
"--with-cc-opt=\"-I$$EXT_BUILD_ROOT$$/external/wasmer/include\"",
"--with-ld-opt=\"-L$$EXT_BUILD_ROOT$$/external/wasmer/lib\"",
"@kong//:wasmx_v8_aarch64": [
"--with-cc-opt=\"-I$$EXT_BUILD_ROOT$$/external/v8-aarch64/include\"",
"--with-ld-opt=\"-L$$EXT_BUILD_ROOT$$/external/v8-aarch64/lib\"",
],
"//conditions:default": [],
}) + select({
"@kong//:wasmx_wasmtime": [
"--with-cc-opt=\"-I$$EXT_BUILD_ROOT$$/external/wasmtime/include\"",
"--with-ld-opt=\"-L$$EXT_BUILD_ROOT$$/external/wasmtime/lib\"",
"@kong//:wasmx_wasmer_x86_64": [
"--with-cc-opt=\"-I$$EXT_BUILD_ROOT$$/external/wasmer-x86_64/include\"",
"--with-ld-opt=\"-L$$EXT_BUILD_ROOT$$/external/wasmer-x86_64/lib\"",
],
"//conditions:default": [],
}) + select({
"@kong//:wasmx_wasmer_aarch64": [
"--with-cc-opt=\"-I$$EXT_BUILD_ROOT$$/external/wasmer-aarch64/include\"",
"--with-ld-opt=\"-L$$EXT_BUILD_ROOT$$/external/wasmer-aarch64/lib\"",
],
"//conditions:default": [],
}) + select({
"@kong//:wasmx_wasmtime_x86_64": [
"--with-cc-opt=\"-I$$EXT_BUILD_ROOT$$/external/wasmtime-x86_64/include\"",
"--with-ld-opt=\"-L$$EXT_BUILD_ROOT$$/external/wasmtime-x86_64/lib\"",
],
"//conditions:default": [],
}) + select({
"@kong//:wasmx_wasmtime_aarch64": [
"--with-cc-opt=\"-I$$EXT_BUILD_ROOT$$/external/wasmtime-aarch64/include\"",
"--with-ld-opt=\"-L$$EXT_BUILD_ROOT$$/external/wasmtime-aarch64/lib\"",
],
"//conditions:default": [],
})
Expand All @@ -279,19 +297,33 @@ wasmx_build_data = select({
],
"//conditions:default": [],
}) + select({
"@kong//:wasmx_v8": [
"@v8//:all_srcs",
"@openresty//:wasmx_v8_ar",
"@kong//:wasmx_v8_x86_64": [
"@v8-x86_64//:all_srcs",
],
"//conditions:default": [],
}) + select({
"@kong//:wasmx_v8_aarch64": [
"@v8-aarch64//:all_srcs",
],
"//conditions:default": [],
}) + select({
"@kong//:wasmx_wasmer_x86_64": [
"@wasmer-x86_64//:all_srcs",
],
"//conditions:default": [],
}) + select({
"@kong//:wasmx_wasmer": [
"@wasmer//:all_srcs",
"@kong//:wasmx_wasmer_aarch64": [
"@wasmer-aarch64//:all_srcs",
],
"//conditions:default": [],
}) + select({
"@kong//:wasmx_wasmtime": [
"@wasmtime//:all_srcs",
"@kong//:wasmx_wasmtime_x86_64": [
"@wasmtime-x86_64//:all_srcs",
],
"//conditions:default": [],
}) + select({
"@kong//:wasmx_wasmtime_aarch64": [
"@wasmtime-aarch64//:all_srcs",
],
"//conditions:default": [],
})
Expand Down Expand Up @@ -323,28 +355,51 @@ configure_make(
configure_in_place = True,
configure_options = CONFIGURE_OPTIONS,
env = select({
"@kong//:wasmx_v8": {
"@kong//:wasmx_v8_x86_64": {
"NGX_WASM_RUNTIME": "v8",
"NGX_WASM_RUNTIME_LIB": "$$EXT_BUILD_ROOT$$/external/v8-x86_64/lib",
"NGX_WASM_RUNTIME_INC": "$$EXT_BUILD_ROOT$$/external/v8-x86_64/include",
# https://github.com/Kong/ngx_wasm_module/blob/0f07c712c48d410190ec5e0cc0b34fdfd190387d/t/10-build/003-dynamic_module.t#L43
"NGX_WASM_RUNTIME_LD_OPT": "$$EXT_BUILD_ROOT$$/external/v8-x86_64/lib/libwee8.a -lv8bridge -lstdc++ -lm -ldl -lpthread",
# see the above comments and source for this dummy ar script
"AR": "$(execpath @openresty//:wasmx_v8_ar)",
},
"@kong//:wasmx_v8_aarch64": {
"NGX_WASM_RUNTIME": "v8",
"NGX_WASM_RUNTIME_LIB": "$$EXT_BUILD_ROOT$$/external/v8/lib",
"NGX_WASM_RUNTIME_INC": "$$EXT_BUILD_ROOT$$/external/v8/include",
"NGX_WASM_RUNTIME_LIB": "$$EXT_BUILD_ROOT$$/external/v8-aarch64/lib",
"NGX_WASM_RUNTIME_INC": "$$EXT_BUILD_ROOT$$/external/v8-aarch64/include",
# https://github.com/Kong/ngx_wasm_module/blob/0f07c712c48d410190ec5e0cc0b34fdfd190387d/t/10-build/003-dynamic_module.t#L43
"NGX_WASM_RUNTIME_LD_OPT": "$$EXT_BUILD_ROOT$$/external/v8/lib/libwee8.a -lv8bridge -lstdc++ -lm -ldl -lpthread",
"NGX_WASM_RUNTIME_LD_OPT": "$$EXT_BUILD_ROOT$$/external/v8-aarch64/lib/libwee8.a -lv8bridge -lstdc++ -lm -ldl -lpthread",
# see the above comments and source for this dummy ar script
"AR": "$(execpath @openresty//:wasmx_v8_ar)",
},
"@kong//:wasmx_wasmer": {
"@kong//:wasmx_wasmer_x86_64": {
"NGX_WASM_RUNTIME": "wasmer",
"NGX_WASM_RUNTIME_LIB": "$$EXT_BUILD_ROOT$$/external/wasmer-x86_64/lib",
"NGX_WASM_RUNTIME_INC": "$$EXT_BUILD_ROOT$$/external/wasmer-x86_64/include",
# https://github.com/Kong/ngx_wasm_module/blob/0f07c712c48d410190ec5e0cc0b34fdfd190387d/t/10-build/003-dynamic_module.t#L30
"NGX_WASM_RUNTIME_LD_OPT": "$$EXT_BUILD_ROOT$$/external/wasmer-x86_64/lib/libwasmer.a -lm -ldl -lpthread",
},
"@kong//:wasmx_wasmer_aarch64": {
"NGX_WASM_RUNTIME": "wasmer",
"NGX_WASM_RUNTIME_LIB": "$$EXT_BUILD_ROOT$$/external/wasmer/lib",
"NGX_WASM_RUNTIME_INC": "$$EXT_BUILD_ROOT$$/external/wasmer/include",
"NGX_WASM_RUNTIME_LIB": "$$EXT_BUILD_ROOT$$/external/wasmer-aarch64/lib",
"NGX_WASM_RUNTIME_INC": "$$EXT_BUILD_ROOT$$/external/wasmer-aarch64/include",
# https://github.com/Kong/ngx_wasm_module/blob/0f07c712c48d410190ec5e0cc0b34fdfd190387d/t/10-build/003-dynamic_module.t#L30
"NGX_WASM_RUNTIME_LD_OPT": "$$EXT_BUILD_ROOT$$/external/wasmer-aarch64/lib/libwasmer.a -lm -ldl -lpthread",
},
"@kong//:wasmx_wasmtime_x86_64": {
"NGX_WASM_RUNTIME": "wasmtime",
"NGX_WASM_RUNTIME_LIB": "$$EXT_BUILD_ROOT$$/external/wasmtime-x86_64/lib",
"NGX_WASM_RUNTIME_INC": "$$EXT_BUILD_ROOT$$/external/wasmtime-x86_64/include",
# https://github.com/Kong/ngx_wasm_module/blob/0f07c712c48d410190ec5e0cc0b34fdfd190387d/t/10-build/003-dynamic_module.t#L30
"NGX_WASM_RUNTIME_LD_OPT": "$$EXT_BUILD_ROOT$$/external/wasmer/lib/libwasmer.a -lm -ldl -lpthread",
"NGX_WASM_RUNTIME_LD_OPT": "$$EXT_BUILD_ROOT$$/external/wasmtime-x86_64/lib/libwasmtime.a -lm -ldl -lpthread",
},
"@kong//:wasmx_wasmtime": {
"@kong//:wasmx_wasmtime_aarch64": {
"NGX_WASM_RUNTIME": "wasmtime",
"NGX_WASM_RUNTIME_LIB": "$$EXT_BUILD_ROOT$$/external/wasmtime/lib",
"NGX_WASM_RUNTIME_INC": "$$EXT_BUILD_ROOT$$/external/wasmtime/include",
"NGX_WASM_RUNTIME_LIB": "$$EXT_BUILD_ROOT$$/external/wasmtime-aarch64/lib",
"NGX_WASM_RUNTIME_INC": "$$EXT_BUILD_ROOT$$/external/wasmtime-aarch64/include",
# https://github.com/Kong/ngx_wasm_module/blob/0f07c712c48d410190ec5e0cc0b34fdfd190387d/t/10-build/003-dynamic_module.t#L30
"NGX_WASM_RUNTIME_LD_OPT": "$$EXT_BUILD_ROOT$$/external/wasmtime/lib/libwasmtime.a -lm -ldl -lpthread",
"NGX_WASM_RUNTIME_LD_OPT": "$$EXT_BUILD_ROOT$$/external/wasmtime-aarch64/lib/libwasmtime.a -lm -ldl -lpthread",
},
"//conditions:default": {},
}),
Expand Down
Loading

2 comments on commit b4f328e

@khcp-gha-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel Build

Docker image available kong/kong:b4f328e431cecb700b4a9c0da7955f267773254e
Artifacts available https://github.com/Kong/kong/actions/runs/5671235863

@flrgh
Copy link
Contributor Author

@flrgh flrgh commented on b4f328e Jul 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build failure was fixed in #11298

Please sign in to comment.