Rust codegen: @snap_client_toolchains//:compilation_mode_opt is missing in internal monorepo builds, breaking valdi_core_rust_cc analysis

Open Beginner friendly
#233 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
77/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp, rust
Domain
build-system

Research direction

Start in valdi_core/BUILD.bazel at the defines select on valdi_core_rust_cc, then compare the @snap_client_toolchains templates in client/bzl/toolchains/BUILD.sc_build_flags.tpl and BUILD.flags.tpl with the standalone stub bzl/toolchains/BUILD.bazel. Make the configuration setting available in internal builds and confirm Bazel analysis succeeds for //valdi_core:valdi_core_rust_cc there.

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.

@snap_client_toolchains//:compilation_mode_opt is missing in internal monorepo builds, breaking valdi_core_rust_cc analysis

File: valdi_core/BUILD.bazel

Configuring //valdi_core:valdi_core_rust_cc (or any target that depends on it, such as //valdi:test_integration or a valdi_module with native_language = "rust") in an internal monorepo workspace (client, android, phantom, banshee) fails Bazel analysis because @snap_client_toolchains//:compilation_mode_opt does not exist there. The defines select(...) on valdi_core_rust_cc references @snap_client_toolchains//:compilation_mode_opt.

Internal builds generate @snap_client_toolchains via setup_snap_cxx_toolchains in client/bzl/toolchains/setup.bzl using templates such as client/bzl/toolchains/BUILD.sc_build_flags.tpl and client/bzl/toolchains/BUILD.flags.tpl, none of which declare :compilation_mode_opt (it only exists in the standalone stub bzl/toolchains/BUILD.bazel). Because Bazel evaluates select keys during analysis in every workspace, referencing a label absent from the generated repo breaks target analysis on internal builds.

Define a local config_setting(name = "compilation_mode_opt", values = {"compilation_mode": "opt"}) in valdi_core/BUILD.bazel and select on ":compilation_mode_opt" (or use @snap_client_toolchains//:sc_build_flag_assert, which both toolchains define).

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.