From 11745dc1fdfc819c2c11c8a24b660fbb82e888ac Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 23 Jun 2026 05:54:00 +0000 Subject: [PATCH] fix(docker): ship declared example/bench sources in build context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Railway/Docker build aborted at manifest parse: error: failed to parse manifest at `/app/Cargo.toml` Caused by: can't find `amx_gemm_bench` example at `examples/amx_gemm_bench.rs` ... Root cause: `.dockerignore` excluded `examples/` and `benches/` from the build context, but Cargo.toml declares explicit [[example]]/[[bench]] targets. Cargo validates that every explicitly-declared target's source file exists while *parsing* the manifest — even for a lib-only build — so `cargo build` aborts before compiling anything when those files are absent. `amx_gemm_bench` was just the first missing target reported; all 18 examples and 13 root benches were stripped, and the ndarray-rand workspace member's [[bench]] "bench" was also missing (its benches/ dir was never copied — only Cargo.toml + src/). Fix: - .dockerignore: stop excluding examples/ and benches/ so they are present in the build context (kept an NB comment explaining why). - Dockerfile + Dockerfile.avx512: COPY examples/, benches/, and ndarray-rand/benches/ before the build. These are NOT compiled by the default `cargo build` (examples/benches require --examples/--benches), so this adds only source bytes, not build time. Verified by staging the exact Docker COPY set locally: without the dirs, `cargo build` reproduces the parse error; with them, parse succeeds and the build advances past target validation into dependency/lib compilation. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01Kq2xzjPj9p2eoP64uy3Btg --- .dockerignore | 8 ++++++-- Dockerfile | 10 ++++++++++ Dockerfile.avx512 | 10 ++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/.dockerignore b/.dockerignore index a76cf400..b220ea20 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,6 +4,10 @@ target/ *.md !README*.md .github/ -benches/ -examples/ scripts/ +# NB: benches/ and examples/ are intentionally NOT ignored. Cargo.toml declares +# explicit [[bench]] and [[example]] targets, and cargo validates that every +# declared target's source file exists when it parses the manifest — even for a +# lib-only build. Excluding these dirs makes `cargo build` fail at manifest +# parse with "can't find example/bench". They are not compiled by the +# default build, so the cost of shipping them in the context is just their size. diff --git a/Dockerfile b/Dockerfile index bfe45160..5e8f1788 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,6 +34,16 @@ COPY crates/ crates/ COPY src/ src/ COPY ndarray-rand/src/ ndarray-rand/src/ +# Cargo.toml (root) and ndarray-rand/Cargo.toml (a workspace member) declare +# explicit [[example]]/[[bench]] targets. Cargo validates that every declared +# target's source file exists while parsing the manifest — even for a lib-only +# build — so these dirs must be in the context or `cargo build` fails at parse +# with "can't find example/bench". They are NOT compiled here (the default +# build skips examples/benches), so this only adds source bytes, not build time. +COPY examples/ examples/ +COPY benches/ benches/ +COPY ndarray-rand/benches/ ndarray-rand/benches/ + # Default target: x86-64-v3 (AVX2) — runs on GitHub CI and most servers. # Use Dockerfile.avx512 for x86-64-v4 (AVX-512). ndarray's simd.rs polyfill # detects AVX-512 at runtime via LazyLock even when compiled for v3; diff --git a/Dockerfile.avx512 b/Dockerfile.avx512 index 102773c3..b1ebe529 100644 --- a/Dockerfile.avx512 +++ b/Dockerfile.avx512 @@ -32,6 +32,16 @@ COPY crates/ crates/ COPY src/ src/ COPY ndarray-rand/src/ ndarray-rand/src/ +# Cargo.toml (root) and ndarray-rand/Cargo.toml (a workspace member) declare +# explicit [[example]]/[[bench]] targets. Cargo validates that every declared +# target's source file exists while parsing the manifest — even for a lib-only +# build — so these dirs must be in the context or `cargo build` fails at parse +# with "can't find example/bench". They are NOT compiled here (the default +# build skips examples/benches), so this only adds source bytes, not build time. +COPY examples/ examples/ +COPY benches/ benches/ +COPY ndarray-rand/benches/ ndarray-rand/benches/ + # AVX-512 pinned: compile-time dispatch, everything inlined ENV RUSTFLAGS="-C target-cpu=x86-64-v4"