Skip to content

Commit b62edf0

Browse files
authored
envoy: switch default WASM runtime to wasmtime (NixOS#435633)
2 parents 507f494 + f89b85d commit b62edf0

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed

pkgs/by-name/en/envoy/bazel_nix.BUILD.bazel

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
load("@bazel_tools//tools/sh:sh_toolchain.bzl", "sh_toolchain")
22
load("@rules_rust//rust:toolchain.bzl", "rust_toolchain")
3+
load("@rules_rust//rust:defs.bzl", "rust_stdlib_filegroup")
34

45
toolchains = {
56
"x86_64": "x86_64-unknown-linux-gnu",
67
"aarch64": "aarch64-unknown-linux-gnu",
78
}
89

9-
exports_files(["cargo", "rustdoc", "ruststd", "rustc"])
10+
exports_files(["cargo", "rustdoc", "rustc"])
11+
12+
[
13+
rust_stdlib_filegroup(
14+
name = "rust_nix_" + k + "_stdlib",
15+
srcs = glob(
16+
[
17+
"rustcroot/lib/rustlib/" + v + "/lib/**",
18+
],
19+
allow_empty=True,
20+
),
21+
)
22+
for k, v in toolchains.items()
23+
]
1024

1125
[
1226
rust_toolchain(
@@ -16,7 +30,7 @@ exports_files(["cargo", "rustdoc", "ruststd", "rustc"])
1630
exec_triple = v,
1731
cargo = ":cargo",
1832
rust_doc = ":rustdoc",
19-
rust_std = ":ruststd",
33+
rust_std = ":rust_nix_" + k + "_stdlib",
2034
rustc = ":rustc",
2135
stdlib_linkflags = ["-ldl", "-lpthread"],
2236
staticlib_ext = ".a",

pkgs/by-name/en/envoy/package.nix

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@
2323
gnutar,
2424
gnugrep,
2525
envoy,
26+
git,
2627

2728
# v8 (upstream default), wavm, wamr, wasmtime, disabled
28-
wasmRuntime ? "wamr",
29+
wasmRuntime ? "wasmtime",
30+
31+
# Allows overriding the deps hash used for building - you will likely need to
32+
# set this if you have changed the 'wasmRuntime' setting.
33+
depsHash ? null,
2934
}:
3035

3136
let
@@ -40,12 +45,15 @@ let
4045
};
4146

4247
# these need to be updated for any changes to fetchAttrs
43-
depsHash =
44-
{
45-
x86_64-linux = "sha256-E6yUSd00ngmjaMds+9UVZLtcYhzeS8F9eSIkC1mZSps=";
46-
aarch64-linux = "sha256-ivboOrV/uORKVHRL3685aopcElGvzsxgVcUmYsBwzXY=";
47-
}
48-
.${stdenv.system} or (throw "unsupported system ${stdenv.system}");
48+
depsHash' =
49+
if depsHash != null then
50+
depsHash
51+
else
52+
{
53+
x86_64-linux = "sha256-t4Xv4UGYW5YU0kmv+1rdf2JvM1BYQyNWdtpz6Cdmxm4=";
54+
aarch64-linux = "sha256-aIBnNGzc0hTdlTgRyJ7eLnWvHqZ5ywhqOM+mHfH3/18=";
55+
}
56+
.${stdenv.system} or (throw "unsupported system ${stdenv.system}");
4957

5058
python3 = python312;
5159

@@ -94,7 +102,7 @@ buildBazelPackage rec {
94102
ln -sf "${cargo}/bin/cargo" bazel/nix/cargo
95103
ln -sf "${rustc}/bin/rustc" bazel/nix/rustc
96104
ln -sf "${rustc}/bin/rustdoc" bazel/nix/rustdoc
97-
ln -sf "${rustPlatform.rustLibSrc}" bazel/nix/ruststd
105+
ln -sf "${rustc.unwrapped}" bazel/nix/rustcroot
98106
substituteInPlace bazel/dependency_imports.bzl \
99107
--replace-fail 'crate_universe_dependencies()' 'crate_universe_dependencies(rust_toolchain_cargo_template="@@//bazel/nix:cargo", rust_toolchain_rustc_template="@@//bazel/nix:rustc")' \
100108
--replace-fail 'crates_repository(' 'crates_repository(rust_toolchain_cargo_template="@@//bazel/nix:cargo", rust_toolchain_rustc_template="@@//bazel/nix:rustc",'
@@ -120,12 +128,13 @@ buildBazelPackage rec {
120128
ninja
121129
patchelf
122130
cacert
131+
git
123132
];
124133

125134
buildInputs = [ linuxHeaders ];
126135

127136
fetchAttrs = {
128-
sha256 = depsHash;
137+
sha256 = depsHash';
129138
env.CARGO_BAZEL_REPIN = true;
130139
dontUseCmakeConfigure = true;
131140
dontUseGnConfigure = true;
@@ -239,6 +248,7 @@ buildBazelPackage rec {
239248
"--linkopt=-Wl,-z,noexecstack"
240249
"--config=gcc"
241250
"--verbose_failures"
251+
"--incompatible_enable_cc_toolchain_resolution=true"
242252

243253
# Force use of system Java.
244254
"--extra_toolchains=@local_jdk//:all"

0 commit comments

Comments
 (0)