Skip to content

[FIX][Rust] Let docs.rs build tvm-ffi and correct the Rust setup docs - #839

Merged
Seven-Streams merged 2 commits into
apache:mainfrom
Seven-Streams:main-dev/2026-10-05/rust_docsrs_build_fix
Oct 6, 2026
Merged

Seven-Streams merged 2 commits into
apache:mainfrom
Seven-Streams:main-dev/2026-10-05/rust_docsrs_build_fix

Conversation

@Seven-Streams

Copy link
Copy Markdown
Member

The docs.rs build of tvm-ffi 0.1.14 failed
(https://docs.rs/crate/tvm-ffi/0.1.14/builds/4724950): rust/tvm-ffi/build.rs
runs tvm-ffi-config unconditionally and panics when it is missing, which is
the case on docs.rs and in docs/conf.py, which sets DOCS_RS the same way.
Bring the script in line with rust/tvm-ffi-sys/build.rs (#825):

  • Under DOCS_RS, warn and skip the loader-path setup instead of panicking.
  • Treat a non-zero exit status or empty output of tvm-ffi-config --libdir as
    an error, and report the exit status and stderr.
  • Fail with the same install guidance as tvm-ffi-sys when DOCS_RS is not
    set.
  • Rerun the script when DOCS_RS, PATH, the loader-path variable, or
    build.rs changes, so switching the Python environment updates the
    LD_LIBRARY_PATH baked into cargo run and cargo test instead of keeping
    the previous library directory.

Also fix two Rust documentation issues:

  • rust/README.md claimed the build sets the dynamic loader path for
    cargo run and cargo test. That only holds inside this workspace: Cargo
    applies rustc-env from the running package's own build script and drops
    rustc-link-search paths outside the target directory, so downstream crates
    must set LD_LIBRARY_PATH themselves, including for cargo run and
    cargo test.
  • docs/guides/rust_lang_guide.md still pointed published users at
    tvm-ffi = "0.1.0-alpha.0"; use 0.1.14.

Validation: with no tvm-ffi-config on PATH, DOCS_RS=1 cargo doc --no-deps -p tvm-ffi now succeeds with a warning (it previously panicked at build.rs:69)
and a plain cargo build -p tvm-ffi still fails, now with the install
guidance. With the Python package installed, cargo test -p tvm-ffi --test test_function and cargo run --example load_library --features example pass;
switching PATH between two environments reruns the build script and bakes the
new library directory, and an unchanged PATH does not rerun it. pre-commit
passed on all files.

Signed-off-by: yuchuan <yuchuan.7streams@gmail.com>
Signed-off-by: yuchuan <yuchuan.7streams@gmail.com>
@Seven-Streams
Seven-Streams merged commit 5e6b6a0 into apache:main Oct 6, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants