[Rust Frontend] Replace external `protoc` with pure Rust lib `protox` (#52892)
Signed-off-by: Bugen Zhao <i@bugenzhao.com> Co-authored-by: OpenAI Codex <codex@openai.com> Co-authored-by: Nick Hill <nickhill123@gmail.com>
Bugen Zhao committed
Aug 21, 2026 at 11:43 UTC
83c5d59209d2a3629cafaa1ceca0893530442835
14 files changed
+181
-125
.buildkite/ci_config_rocm.yaml
-1
@@ -25,7 +25,6 @@ run_all_patterns:
25
- "rust/"
26
- "rust-toolchain.toml"
27
- "tools/build_rust.py"
28
- - "tools/install_protoc.sh"
28
- "tools/install_torchcodec_rocm.sh"
29
- "tests/vllm_test_utils/"
30
- "vllm/envs.py"
.buildkite/scripts/build-macos-wheel.sh
-5
@@ -10,11 +10,6 @@ set -euo pipefail
10
# The macmini queue uses persistent checkouts, so refresh tags for setuptools-scm.
11
git fetch --tags --force origin
12
13
-# The Rust frontend build needs protoc.
14
-if ! command -v protoc >/dev/null 2>&1; then
15
- brew install protobuf
16
-fi
17
-
13
# upload-nightly-wheels.sh expects exactly one wheel.
14
rm -rf artifacts/dist
15
mkdir -p artifacts/dist
.buildkite/scripts/ci-bake-rocm.sh
+2
-2
@@ -15,7 +15,7 @@ set -euo pipefail
15
16
DEFAULT_REPO_SLUG="vllm-project/vllm"
17
DEFAULT_CI_HCL_SOURCE="docker/ci-rocm.hcl"
18
-DEFAULT_CI_BASE_CONTENT_FILES=".dockerignore requirements/common.txt requirements/rocm.txt requirements/test/rocm.txt tools/install_torchcodec_rocm.sh tools/install_protoc.sh rust-toolchain.toml tests/vllm_test_utils"
18
+DEFAULT_CI_BASE_CONTENT_FILES=".dockerignore requirements/common.txt requirements/rocm.txt requirements/test/rocm.txt tools/install_torchcodec_rocm.sh rust-toolchain.toml tests/vllm_test_utils"
19
DEFAULT_CI_BASE_DOCKERFILE="docker/Dockerfile.rocm"
20
DEFAULT_CI_BASE_DOCKERFILE_STAGES="base rust_toolchain_input_0 rust-toolchain-input rust-toolchain build_nixl lmcache_source build_lmcache build_rocshmem build_deepep mori_base ci_base"
21
DEFAULT_CI_BASE_METADATA_VERSION="3"
@@ -23,7 +23,7 @@ DEFAULT_CI_BASE_METADATA_VERSION="3"
23
# local-source stages rather than unreachable remote-fetch alternatives.
24
DEFAULT_ROCM_CSRC_CONTENT_FILES=".dockerignore requirements/common.txt requirements/rocm.txt pyproject.toml setup.py CMakeLists.txt cmake csrc vllm/envs.py vllm/__init__.py tools/build_rust.py"
25
DEFAULT_ROCM_CSRC_DOCKERFILE_STAGES="base fetch_vllm_0 fetch_vllm build_vllm_dependencies rocm-triton-kernels csrc-build"
26
-DEFAULT_ROCM_RUST_CONTENT_FILES=".dockerignore .git_archival.txt pyproject.toml requirements/build/rust.txt rust/Cargo.lock rust/Cargo.toml rust/proto rust/src rust-toolchain.toml tools/build_rust.py tools/install_protoc.sh build_rust.sh"
26
+DEFAULT_ROCM_RUST_CONTENT_FILES=".dockerignore .git_archival.txt pyproject.toml requirements/build/rust.txt rust/Cargo.lock rust/Cargo.toml rust/proto rust/src rust-toolchain.toml tools/build_rust.py build_rust.sh"
27
DEFAULT_ROCM_RUST_DOCKERFILE_STAGES="base fetch_vllm_0 fetch_vllm vllm-version rust_toolchain_input_0 rust-toolchain-input rust_input_0 rust-input rust-toolchain rust-build"
28
# Docker's 128-character tag limit minus the longest cache prefix
29
# ("csrc-rocm-branch-" and "rust-rocm-branch-", both 17 characters).
.buildkite/scripts/run-rust-frontend-cargo-ci.sh
-30
@@ -21,7 +21,6 @@ export CARGO_HOME="${CARGO_HOME:-$HOME/.cargo}"
21
export RUSTUP_HOME="${RUSTUP_HOME:-$HOME/.rustup}"
22
export PATH="$CARGO_HOME/bin:$PATH"
23
24
-PROTOC_VERSION="${PROTOC_VERSION:-31.1}"
24
CARGO_BINSTALL_VERSION="${CARGO_BINSTALL_VERSION:-1.20.1}"
25
UV_VERSION="${UV_VERSION:-0.11.28}"
26
PYO3_PYTHON_VERSION="${PYO3_PYTHON_VERSION:-3.12}"
@@ -34,34 +33,6 @@ log_section() {
33
echo "--- $*"
34
}
35
37
-install_protoc() {
38
- local arch
39
- case "$(uname -m)" in
40
- x86_64)
41
- arch="x86_64"
42
- ;;
43
- aarch64|arm64)
44
- arch="aarch_64"
45
- ;;
46
- *)
47
- echo "Unsupported protoc architecture: $(uname -m)" >&2
48
- return 1
49
- ;;
50
- esac
51
-
52
- local url="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-${arch}.zip"
53
- local tmp_dir
54
- tmp_dir="$(mktemp -d)"
55
-
56
- log_section "Installing protoc ${PROTOC_VERSION}"
57
- curl -L --proto '=https' --tlsv1.2 -sSf "$url" -o "$tmp_dir/protoc.zip"
58
- mkdir -p "$CARGO_HOME/bin"
59
- unzip -q "$tmp_dir/protoc.zip" bin/protoc 'include/*' -d "$CARGO_HOME"
60
- chmod +x "$CARGO_HOME/bin/protoc"
61
- rm -rf "$tmp_dir"
62
- protoc --version
63
-}
64
-
36
rust_toolchain() {
37
awk -F '"' '/channel[[:space:]]*=/ { print $2; exit }' rust-toolchain.toml
38
}
@@ -186,7 +157,6 @@ run_tests() {
157
--no-fail-fast
158
}
159
189
-install_protoc
160
install_rust_toolchain
161
162
case "$MODE" in
docker/Dockerfile
+3
-6
@@ -243,21 +243,18 @@ ENV TORCH_CUDA_ARCH_LIST=${torch_cuda_arch_list}
243
244
#################### RUST BUILD IMAGE ####################
245
# Build the Rust frontend (`vllm-rs`) in a dedicated stage so the main wheel
246
-# build stage doesn't need the rust toolchain, protoc, or the rust source.
246
+# build stage doesn't need the rust toolchain or the rust source.
247
# This stage reuses the Python environment from base and runs in parallel with
248
# csrc-build/extensions-build.
249
FROM base AS rust-build
250
ARG USE_SCCACHE
251
ARG SCCACHE_ENDPOINT
252
253
-# Install native tools needed only for Rust/protoc builds.
254
-RUN dnf install -y --setopt=install_weak_deps=False make unzip \
253
+# Install native tools needed only for Rust builds.
254
+RUN dnf install -y --setopt=install_weak_deps=False make \
255
&& dnf clean all \
256
&& rm -rf /var/cache/dnf
257
258
-COPY tools/install_protoc.sh /tmp/install_protoc.sh
259
-RUN /tmp/install_protoc.sh && rm /tmp/install_protoc.sh
260
-
258
WORKDIR /workspace
259
260
COPY requirements/build/rust.txt requirements/build/rust.txt
docker/Dockerfile.cpu
+2
-5
@@ -127,19 +127,16 @@ RUN echo 'ulimit -c 0' >> ~/.bashrc
127
128
######################### RUST BUILD IMAGE #########################
129
# Build the Rust frontend (`vllm-rs`) in a dedicated stage so the wheel build
130
-# stage doesn't need the rust toolchain or protoc. This stage runs in parallel
130
+# stage doesn't need the rust toolchain. This stage runs in parallel
131
# with the main vllm-build stage.
132
FROM base AS rust-build
133
ENV DEBIAN_FRONTEND=noninteractive
134
135
RUN apt-get update -y \
136
&& apt-get install -y --no-install-recommends \
137
- build-essential unzip python3 python3-pip \
137
+ build-essential python3 python3-pip \
138
&& rm -rf /var/lib/apt/lists/*
139
140
-COPY tools/install_protoc.sh /tmp/install_protoc.sh
141
-RUN /tmp/install_protoc.sh && rm /tmp/install_protoc.sh
142
-
140
WORKDIR /workspace
141
142
COPY requirements/build/rust.txt requirements/build/rust.txt
docker/Dockerfile.rocm
+5
-13
@@ -138,13 +138,12 @@ RUN --mount=type=cache,id=vllm-rocm-uv,target=/root/.cache/uv \
138
> /vllm-version.txt
139
140
# -----------------------
141
-# Rust/protoc toolchain inputs
141
+# Rust toolchain inputs
142
#
143
# Keep these separate from Rust source inputs so Rust source-only changes do not
144
# invalidate the long-lived ci_base image that carries the toolchain.
145
FROM scratch AS rust_toolchain_input_0
146
COPY rust-toolchain.toml /rust-toolchain-input/vllm/rust-toolchain.toml
147
-COPY tools/install_protoc.sh /rust-toolchain-input/vllm/tools/install_protoc.sh
147
148
FROM base AS rust_toolchain_input_1
149
ARG VLLM_REPO
@@ -155,7 +154,6 @@ RUN git clone --no-checkout --filter=blob:none ${VLLM_REPO} /rust-toolchain-inpu
154
&& git sparse-checkout init --no-cone \
155
&& git sparse-checkout set \
156
rust-toolchain.toml \
158
- tools/install_protoc.sh \
157
&& git checkout FETCH_HEAD
158
159
FROM rust_toolchain_input_${REMOTE_VLLM} AS rust-toolchain-input
@@ -195,21 +193,17 @@ RUN git clone --no-checkout --filter=blob:none ${VLLM_REPO} /rust-input/vllm \
193
FROM rust_input_${REMOTE_VLLM} AS rust-input
194
195
# -----------------------
198
-# Rust/protoc toolchain
196
+# Rust toolchain
197
FROM base AS rust-toolchain
198
199
ENV CARGO_HOME=/root/.cargo
200
ENV RUSTUP_HOME=/root/.rustup
201
ENV PATH=${CARGO_HOME}/bin:${PATH}
202
205
-# protoc is used by tonic-build/prost-build.
203
RUN apt-get update -q -y && apt-get install -q -y --no-install-recommends \
207
- ca-certificates curl unzip \
204
+ ca-certificates curl \
205
&& rm -rf /var/lib/apt/lists/*
206
210
-COPY --from=rust-toolchain-input /rust-toolchain-input/vllm/tools/install_protoc.sh /tmp/install_protoc.sh
211
-RUN /tmp/install_protoc.sh && rm /tmp/install_protoc.sh
212
-
207
COPY --from=rust-toolchain-input /rust-toolchain-input/vllm/rust-toolchain.toml /tmp/rust-toolchain.toml
208
RUN TOOLCHAIN="$(grep '^channel' /tmp/rust-toolchain.toml | sed 's/.*= *"\(.*\)"/\1/')" \
209
&& if ! command -v rustup >/dev/null 2>&1; then \
@@ -224,7 +218,7 @@ RUN TOOLCHAIN="$(grep '^channel' /tmp/rust-toolchain.toml | sed 's/.*= *"\(.*\)"
218
# -----------------------
219
# Rust build stage
220
# Builds the `vllm-rs` frontend in a dedicated stage so the wheel build stages
227
-# don't need the rust toolchain or protoc.
221
+# don't need the rust toolchain.
222
FROM rust-toolchain AS rust-build
223
ARG COMMON_WORKDIR
224
ARG USE_SCCACHE
@@ -780,12 +774,10 @@ ENV CARGO_HOME=/root/.cargo
774
ENV RUSTUP_HOME=/root/.rustup
775
ENV PATH=${CARGO_HOME}/bin:${PATH}
776
783
-# Bake the Rust/protoc toolchain into ci_base so Rust build/test steps do not
777
+# Bake the Rust toolchain into ci_base so Rust build/test steps do not
778
# need to fetch it on each per-commit image build.
779
COPY --from=rust-toolchain /root/.cargo /root/.cargo
780
COPY --from=rust-toolchain /root/.rustup /root/.rustup
787
-COPY --from=rust-toolchain /usr/local/bin/protoc /usr/local/bin/protoc
788
-COPY --from=rust-toolchain /usr/local/include/google /usr/local/include/google
781
782
# Update rdma-core to support latest rocshmem.
783
ARG DEEPEP_NIC
docker/Dockerfile.rocm_gfx1250
+1
-9
@@ -141,18 +141,10 @@ RUN --mount=type=cache,id=vllm-rocm-uv,target=/root/.cache/uv \
141
# -----------------------
142
# Rust build stage
143
# Builds the `vllm-rs` frontend in a dedicated stage so the wheel build stages
144
-# don't need the rust toolchain or protoc.
144
+# don't need the rust toolchain.
145
FROM fetch_vllm AS rust-build
146
ARG COMMON_WORKDIR
147
148
-# protoc is used by tonic-build/prost-build.
149
-RUN apt-get update -q -y && apt-get install -q -y --no-install-recommends \
150
- ca-certificates curl unzip \
151
- && rm -rf /var/lib/apt/lists/*
152
-
153
-COPY tools/install_protoc.sh /tmp/install_protoc.sh
154
-RUN /tmp/install_protoc.sh && rm /tmp/install_protoc.sh
155
-
148
# Cap cargo parallelism to avoid exhausting the AMD CI host's open-file limit
149
# (rustc spawns enough concurrent processes to hit RLIMIT_NOFILE otherwise).
150
ENV CARGO_BUILD_JOBS=4
docker/Dockerfile.xpu
+2
-5
@@ -1,17 +1,14 @@
1
######################### RUST BUILD IMAGE #########################
2
# Build the Rust frontend (`vllm-rs`) in a dedicated stage so the main image
3
-# doesn't need the rust toolchain or protoc. Runs in parallel with vllm-base.
3
+# doesn't need the rust toolchain. Runs in parallel with vllm-base.
4
FROM ubuntu:22.04 AS rust-build
5
ENV DEBIAN_FRONTEND=noninteractive
6
7
RUN apt-get update -y \
8
&& apt-get install -y --no-install-recommends \
9
- ca-certificates curl git build-essential unzip python3 python3-pip \
9
+ ca-certificates curl git build-essential python3 python3-pip \
10
&& rm -rf /var/lib/apt/lists/*
11
12
-COPY tools/install_protoc.sh /tmp/install_protoc.sh
13
-RUN /tmp/install_protoc.sh && rm /tmp/install_protoc.sh
14
-
12
WORKDIR /workspace
13
14
COPY requirements/build/rust.txt requirements/build/rust.txt
rust/Cargo.lock
+152
-3
@@ -385,6 +385,12 @@ version = "1.8.3"
385
source = "registry+https://github.com/rust-lang/crates.io-index"
386
checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06"
387
388
+[[package]]
389
+name = "beef"
390
+version = "0.5.2"
391
+source = "registry+https://github.com/rust-lang/crates.io-index"
392
+checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1"
393
+
394
[[package]]
395
name = "bit-set"
396
version = "0.5.3"
@@ -661,7 +667,7 @@ dependencies = [
667
"encode_unicode",
668
"libc",
669
"once_cell",
664
- "unicode-width",
670
+ "unicode-width 0.2.2",
671
"windows-sys 0.61.2",
672
]
673
@@ -1499,7 +1505,7 @@ version = "0.2.24"
1505
source = "registry+https://github.com/rust-lang/crates.io-index"
1506
checksum = "cfe4fbac503b8d1f88e6676011885f34b7174f46e59956bba534ba83abded4df"
1507
dependencies = [
1502
- "unicode-width",
1508
+ "unicode-width 0.2.2",
1509
]
1510
1511
[[package]]
@@ -2005,7 +2011,7 @@ checksum = "25470f23803092da7d239834776d653104d551bc4d7eacaf31e6837854b8e9eb"
2011
dependencies = [
2012
"console",
2013
"portable-atomic",
2008
- "unicode-width",
2014
+ "unicode-width 0.2.2",
2015
"unit-prefix",
2016
"web-time",
2017
]
@@ -2264,6 +2270,72 @@ version = "0.4.29"
2270
source = "registry+https://github.com/rust-lang/crates.io-index"
2271
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
2272
2273
+[[package]]
2274
+name = "logos"
2275
+version = "0.15.1"
2276
+source = "registry+https://github.com/rust-lang/crates.io-index"
2277
+checksum = "ff472f899b4ec2d99161c51f60ff7075eeb3097069a36050d8037a6325eb8154"
2278
+dependencies = [
2279
+ "logos-derive 0.15.1",
2280
+]
2281
+
2282
+[[package]]
2283
+name = "logos"
2284
+version = "0.16.1"
2285
+source = "registry+https://github.com/rust-lang/crates.io-index"
2286
+checksum = "eb2c55a318a87600ea870ff8c2012148b44bf18b74fad48d0f835c38c7d07c5f"
2287
+dependencies = [
2288
+ "logos-derive 0.16.1",
2289
+]
2290
+
2291
+[[package]]
2292
+name = "logos-codegen"
2293
+version = "0.15.1"
2294
+source = "registry+https://github.com/rust-lang/crates.io-index"
2295
+checksum = "192a3a2b90b0c05b27a0b2c43eecdb7c415e29243acc3f89cc8247a5b693045c"
2296
+dependencies = [
2297
+ "beef",
2298
+ "fnv",
2299
+ "lazy_static",
2300
+ "proc-macro2",
2301
+ "quote",
2302
+ "regex-syntax",
2303
+ "rustc_version",
2304
+ "syn 2.0.117",
2305
+]
2306
+
2307
+[[package]]
2308
+name = "logos-codegen"
2309
+version = "0.16.1"
2310
+source = "registry+https://github.com/rust-lang/crates.io-index"
2311
+checksum = "58b3ffaa284e1350d017a57d04ada118c4583cf260c8fb01e0fe28a2e9cf8970"
2312
+dependencies = [
2313
+ "fnv",
2314
+ "proc-macro2",
2315
+ "quote",
2316
+ "regex-automata",
2317
+ "regex-syntax",
2318
+ "syn 2.0.117",
2319
+]
2320
+
2321
+[[package]]
2322
+name = "logos-derive"
2323
+version = "0.15.1"
2324
+source = "registry+https://github.com/rust-lang/crates.io-index"
2325
+checksum = "605d9697bcd5ef3a42d38efc51541aa3d6a4a25f7ab6d1ed0da5ac632a26b470"
2326
+dependencies = [
2327
+ "logos-codegen 0.15.1",
2328
+]
2329
+
2330
+[[package]]
2331
+name = "logos-derive"
2332
+version = "0.16.1"
2333
+source = "registry+https://github.com/rust-lang/crates.io-index"
2334
+checksum = "52d3a9855747c17eaf4383823f135220716ab49bea5fbea7dd42cc9a92f8aa31"
2335
+dependencies = [
2336
+ "logos-codegen 0.16.1",
2337
+]
2338
+
2339
[[package]]
2340
name = "macro_rules_attribute"
2341
version = "0.2.2"
@@ -2375,6 +2447,28 @@ version = "0.3.3"
2447
source = "registry+https://github.com/rust-lang/crates.io-index"
2448
checksum = "38d1115007560874e373613744c6fba374c17688327a71c1476d1a5954cc857b"
2449
2450
+[[package]]
2451
+name = "miette"
2452
+version = "7.6.0"
2453
+source = "registry+https://github.com/rust-lang/crates.io-index"
2454
+checksum = "5f98efec8807c63c752b5bd61f862c165c115b0a35685bdcfd9238c7aeb592b7"
2455
+dependencies = [
2456
+ "cfg-if",
2457
+ "miette-derive",
2458
+ "unicode-width 0.1.14",
2459
+]
2460
+
2461
+[[package]]
2462
+name = "miette-derive"
2463
+version = "7.6.0"
2464
+source = "registry+https://github.com/rust-lang/crates.io-index"
2465
+checksum = "db5b29714e950dbb20d5e6f74f9dcec4edbcc1067bb7f8ed198c097b8c1a818b"
2466
+dependencies = [
2467
+ "proc-macro2",
2468
+ "quote",
2469
+ "syn 2.0.117",
2470
+]
2471
+
2472
[[package]]
2473
name = "mimalloc"
2474
version = "0.1.52"
@@ -3116,6 +3210,18 @@ dependencies = [
3210
"syn 2.0.117",
3211
]
3212
3213
+[[package]]
3214
+name = "prost-reflect"
3215
+version = "0.16.5"
3216
+source = "registry+https://github.com/rust-lang/crates.io-index"
3217
+checksum = "01b80ea363c31af2de2b92e3c07ed1156628f7838c4afb4df75ee78a37fedbd1"
3218
+dependencies = [
3219
+ "logos 0.16.1",
3220
+ "miette",
3221
+ "prost",
3222
+ "prost-types",
3223
+]
3224
+
3225
[[package]]
3226
name = "prost-types"
3227
version = "0.14.3"
@@ -3125,6 +3231,33 @@ dependencies = [
3231
"prost",
3232
]
3233
3234
+[[package]]
3235
+name = "protox"
3236
+version = "0.9.1"
3237
+source = "registry+https://github.com/rust-lang/crates.io-index"
3238
+checksum = "4f25a07a73c6717f0b9bbbd685918f5df9815f7efba450b83d9c9dea41f0e3a1"
3239
+dependencies = [
3240
+ "bytes",
3241
+ "miette",
3242
+ "prost",
3243
+ "prost-reflect",
3244
+ "prost-types",
3245
+ "protox-parse",
3246
+ "thiserror 2.0.18",
3247
+]
3248
+
3249
+[[package]]
3250
+name = "protox-parse"
3251
+version = "0.9.0"
3252
+source = "registry+https://github.com/rust-lang/crates.io-index"
3253
+checksum = "072eee358134396a4643dff81cfff1c255c9fbd3fb296be14bdb6a26f9156366"
3254
+dependencies = [
3255
+ "logos 0.15.1",
3256
+ "miette",
3257
+ "prost-types",
3258
+ "thiserror 2.0.18",
3259
+]
3260
+
3261
[[package]]
3262
name = "pulldown-cmark"
3263
version = "0.13.3"
@@ -3623,6 +3756,15 @@ version = "2.1.1"
3756
source = "registry+https://github.com/rust-lang/crates.io-index"
3757
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
3758
3759
+[[package]]
3760
+name = "rustc_version"
3761
+version = "0.4.1"
3762
+source = "registry+https://github.com/rust-lang/crates.io-index"
3763
+checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
3764
+dependencies = [
3765
+ "semver",
3766
+]
3767
+
3768
[[package]]
3769
name = "rustfft"
3770
version = "6.4.1"
@@ -5284,6 +5426,12 @@ version = "1.13.1"
5426
source = "registry+https://github.com/rust-lang/crates.io-index"
5427
checksum = "da36089a805484bcccfffe0739803392c8298778a2d2f09febf76fac5ad9025b"
5428
5429
+[[package]]
5430
+name = "unicode-width"
5431
+version = "0.1.14"
5432
+source = "registry+https://github.com/rust-lang/crates.io-index"
5433
+checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
5434
+
5435
[[package]]
5436
name = "unicode-width"
5437
version = "0.2.2"
@@ -5733,6 +5881,7 @@ dependencies = [
5881
"openssl",
5882
"prost",
5883
"prost-types",
5884
+ "protox",
5885
"rmp-serde",
5886
"rmpv",
5887
"serde",
rust/Cargo.toml
+1
@@ -75,6 +75,7 @@ prometheus-client = "0.24.0"
75
prometheus-client-derive-encode = "0.5.0"
76
prost = "0.14.3"
77
prost-types = "0.14.3"
78
+protox = "0.9.1"
79
pyo3 = "0.28.3"
80
pythonize = "0.28.0"
81
rand = "0.9.2"
rust/src/server/Cargo.toml
+1
@@ -53,6 +53,7 @@ vllm-metrics.workspace = true
53
vllm-text.workspace = true
54
55
[build-dependencies]
56
+protox.workspace = true
57
tonic-prost-build.workspace = true
58
59
[dev-dependencies]
rust/src/server/build.rs
+12
-9
@@ -3,19 +3,22 @@
3
4
fn main() -> Result<(), Box<dyn std::error::Error>> {
5
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
6
- let proto_dir = format!("{manifest_dir}/../../proto");
6
+ let proto_dir = std::path::PathBuf::from(format!("{manifest_dir}/../../proto"));
7
+ let protos = [
8
+ proto_dir.join("control.proto"),
9
+ proto_dir.join("inference.proto"),
10
+ ];
11
+
12
+ for proto in &protos {
13
+ println!("cargo:rerun-if-changed={}", proto.display());
14
+ }
15
+
16
+ let file_descriptor_set = protox::compile(&protos, [&proto_dir])?;
17
18
tonic_prost_build::configure()
19
.build_server(true)
20
.build_client(true)
11
- .protoc_arg("--experimental_allow_proto3_optional") // be compatible with old compilers
12
- .compile_protos(
13
- &[
14
- format!("{proto_dir}/control.proto"),
15
- format!("{proto_dir}/inference.proto"),
16
- ],
17
- &[proto_dir],
18
- )?;
21
+ .compile_fds(file_descriptor_set)?;
22
23
Ok(())
24
}
tools/install_protoc.sh
deleted
-37
@@ -1,37 +0,0 @@
1
-#!/usr/bin/env bash
2
-set -euo pipefail
3
-
4
-# Install a pinned protoc binary from upstream GitHub releases.
5
-#
6
-# Distro protobuf-compiler packages vary widely in version (e.g.
7
-# AlmaLinux/RHEL 8 ships protoc 3.5, predating the
8
-# --experimental_allow_proto3_optional flag the rust frontend's build.rs
9
-# passes), so we pin the protoc version here instead.
10
-#
11
-# Override the version via the PROTOC_VERSION env var.
12
-# Requires: curl, unzip, root privileges.
13
-
14
-if [[ $(id -u) -ne 0 ]]; then
15
- echo "Must be run as root" >&2
16
- exit 1
17
-fi
18
-
19
-VERSION="${PROTOC_VERSION:-34.2}"
20
-
21
-ARCH="$(uname -m)"
22
-case "${ARCH}" in
23
- # protoc release archives use "aarch_64" (with an underscore), not
24
- # "aarch64". Don't "fix" this.
25
- aarch64|arm64) URL_ARCH="aarch_64" ;;
26
- x86_64|amd64) URL_ARCH="x86_64" ;;
27
- *) echo "Unsupported arch for protoc binary: ${ARCH}" >&2; exit 1 ;;
28
-esac
29
-
30
-URL="https://github.com/protocolbuffers/protobuf/releases/download/v${VERSION}/protoc-${VERSION}-linux-${URL_ARCH}.zip"
31
-TMPDIR="$(mktemp -d)"
32
-trap 'rm -rf "${TMPDIR}"' EXIT
33
-
34
-echo "Downloading: ${URL}"
35
-curl -fsSL -o "${TMPDIR}/protoc.zip" "${URL}"
36
-unzip -q -o "${TMPDIR}/protoc.zip" -d /usr/local
37
-echo "Installed $(protoc --version)"