Rust codegen: Gating emit_rust on emit_release breaks Rust native_deps and valdi_test under code_coverage and output_flavor=debug

Open
#235 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp, rust

Research direction

Start in bzl/valdi/valdi_compiled.bzl and trace how emit_release controls emit_rust and outputs for debug and code_coverage builds. Then read bzl/valdi/extract_rust_outputs.bzl and bzl/valdi/valdi_test.bzl to follow the generated Rust sources into native_deps. Done means Rust bindings are generated and native_deps and valdi_test compile with both configurations.

Written by the indexing model from the issue text.

Description

Found while reviewing https://github.com/Snapchat/Valdi/pull/211 (native Rust code generation). Not blocking that PR.

Gating emit_rust on emit_release breaks Rust native_deps and valdi_test under code_coverage and output_flavor=debug

File: bzl/valdi/valdi_compiled.bzl

When building a native_language = "rust" module (or running its valdi_test target) with @valdi//bzl/valdi:code_coverage_enabled=true or @valdi//bzl/valdi:output_flavor=debug, Rust compilation of native_deps fails because the generated _rust crate is empty. In valdi_compiled.bzl, emit_rust is gated on emit_release, which is False under code_coverage or output_flavor == "debug".

When emit_rust is False, ValdiModuleInfo.rust_srcs is None, so bzl/valdi/extract_rust_outputs.bzl writes an empty .rs file for <name>_rust_srcs. Any rust_library in native_deps then fails to compile due to missing generated traits, models, and registration macros — including during valdi_test, because bzl/valdi/valdi_test.bzl now builds a test_binary linked against <target>_native -> <target>_cpp -> native_deps.

Either keep generating the shared Rust bindings regardless of output_flavor / code_coverage (the compiler only suppresses release platform outputs when --output-target debug is passed), or avoid gating emit_rust / outputs on emit_release when native targets depend on them.

Dominant language
C++
Stars
16.4k
Forks
539
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Snapchat/Valdi

All issues in Snapchat/Valdi

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.