[rust] Cover `rustflags` / `--cfg` in `buildflag_header`. [chromium/src : main]

0 views
Skip to first unread message

Łukasz Anforowicz (Gerrit)

unread,
Jan 9, 2026, 7:00:37 PM (21 hours ago) Jan 9
to Devon Loehr, Daniel Cheng, Chromium LUCI CQ, chromium...@chromium.org, blink-...@chromium.org, kinuko...@chromium.org
Attention needed from Daniel Cheng

Łukasz Anforowicz added 4 comments

Patchset-level comments
File-level comment, Patchset 5 (Latest):
Łukasz Anforowicz . resolved

@dcheng, can you PTAL again?

I've addressed the comments (adding explicit test coverage of `true` and `false`). I also rebased this CL on top of ToT (i.e. making this independent of `--check-cfg`-related stuff).

FWIW, @dloehr is asking for similar functionality in https://crbug.com/462501862#comment11.

File build/buildflag_header.gni
Line 171, Patchset 2: if (_value == "true" || _value == "1") {
Daniel Cheng . resolved

Maybe we should note that this is the logic used by build/write_buildflag_header.py and/or have some test case that covers this.

Łukasz Anforowicz

`build/rust/tests/test_buildflag_header/BUILD.gn` is the test for covering this.

File build/rust/allocator/lib.rs
Line 31, Patchset 2:#[cfg(RUST_ALLOCATOR_USES_ALLOCATOR_IMPLS_H)]
Daniel Cheng . resolved

Is the rust convention to use underscore_case? Do we want to do the same for buildflags? I guess that's maybe a bit harder in pure GN?

Łukasz Anforowicz

This is indeed hard to do in pure GN.

And in general, I think we try to avoid automatically changing identifier styles when they are used in other languages.

I think it's fine to land as-is, and in the future we may consider **adding** an alternative lowercase spelling (if we decide this is more ergonomic/expected + if we are ok with GN situation - either adding `string_lowercase` to GN built-in functions, or doing this with [gasp!] `string_replace` repeated 26 times).

File build/rust/tests/test_buildflag_header/BUILD.gn
Line 18, Patchset 2:is_bar = 1 == 2
Daniel Cheng . resolved

Oh I guess this is the test. Do we want to test explicit `true` / `false` at all?

Łukasz Anforowicz

Oh I guess this is the test.

Yes.

Do we want to test explicit `true` / `false` at all?

Done.

Open in Gerrit

Related details

Attention is currently required from:
  • Daniel Cheng
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Iba469801b12bd24f9608859ae6bd73add7e22f57
Gerrit-Change-Number: 7050763
Gerrit-PatchSet: 5
Gerrit-Owner: Łukasz Anforowicz <luk...@chromium.org>
Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
Gerrit-Reviewer: Łukasz Anforowicz <luk...@chromium.org>
Gerrit-CC: Devon Loehr <dlo...@google.com>
Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
Gerrit-Comment-Date: Sat, 10 Jan 2026 00:00:28 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Daniel Cheng <dch...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Łukasz Anforowicz (Gerrit)

unread,
Jan 9, 2026, 10:00:54 PM (18 hours ago) Jan 9
to Devon Loehr, Daniel Cheng, Chromium LUCI CQ, chromium...@chromium.org, blink-...@chromium.org, kinuko...@chromium.org
Attention needed from Daniel Cheng

Łukasz Anforowicz added 1 comment

Patchset-level comments
Łukasz Anforowicz . unresolved

I guess there is an open question about potential naming conflicts. Maybe `build/buildflag_header.gni`-originated `--cfg` flags should have a `BUILDFLAG_` or `CHROMIUM_` prefix to make conflicts less likely? I note that the convention of spelling Chromium buildflags using SHOUTY_CASE makes it less likely to conflict with typical hacker_case_spelling of other Rust cfg flags). So, I think landing as-is should also be ok?

(In theory, instead of doing `--cfg=IS_ASAN` we can also do `'--cfg=buildflag="IS_ASAN"'`. It seems to me that the former is simpler + less verbose and just as good. For the latter it may be a tiny bit simpler to single to `cxxbridge` which flags are possible vs set [since `buildflag` is always "possible"], but it's a tiny difference.)

Open in Gerrit

Related details

Attention is currently required from:
  • Daniel Cheng
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Iba469801b12bd24f9608859ae6bd73add7e22f57
    Gerrit-Change-Number: 7050763
    Gerrit-PatchSet: 5
    Gerrit-Owner: Łukasz Anforowicz <luk...@chromium.org>
    Gerrit-Reviewer: Daniel Cheng <dch...@chromium.org>
    Gerrit-Reviewer: Łukasz Anforowicz <luk...@chromium.org>
    Gerrit-CC: Devon Loehr <dlo...@google.com>
    Gerrit-Attention: Daniel Cheng <dch...@chromium.org>
    Gerrit-Comment-Date: Sat, 10 Jan 2026 03:00:43 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages