Skip to content

Fix Check failed: buffer.str().take_front(4) == kZtsPrefix on Windows. - #2013

Merged
copybara-service[bot] merged 1 commit into
mainfrom
test_981314301
Sep 15, 2026
Merged

copybara-service[bot] merged 1 commit into
mainfrom
test_981314301

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Sep 14, 2026

Copy link
Copy Markdown

Fix Check failed: buffer.str().take_front(4) == kZtsPrefix on Windows.

Importer::GetMangledName used the target platform's mangler to compute
the mangled name of a tag type. When targeting an MSVC-ABI platform
this produced a Microsoft-mangled name, and rs_bindings_from_cc
aborted on CHECK(buffer.str().take_front(4) == kZtsPrefix). The fix
is to always use Itanium mangling for Crubit's mangled_cc_name.

mangled_cc_name doesn't have to correspond to a real symbol, because
it is only used to construct Crubit-specific names. All three callers
should be therefore okay with an Itanium name on every target platform:

This change adds a second, always-Itanium mangler that is used only for
tag type names. mangler_ keeps its role of producing real symbol
names for the target.

Also adds Platform::X86Windows so that the new regression test in
ir_from_cc_test.rs can ask for x86_64-pc-windows-msvc bindings.

@copybara-service copybara-service Bot changed the title Fix Check failed: buffer.str().take_front(4) == kZtsPrefix. Fix Check failed: buffer.str().take_front(4) == kZtsPrefix on Windows. Sep 15, 2026
`Importer::GetMangledName` used the target platform's mangler to compute
the mangled name of a tag type.  When targeting an MSVC-ABI platform
this produced a Microsoft-mangled name, and `rs_bindings_from_cc`
aborted on `CHECK(buffer.str().take_front(4) == kZtsPrefix)`.  The fix
is to always use Itanium mangling for Crubit's `mangled_cc_name`.

`mangled_cc_name` doesn't have to correspond to a real symbol, because
it is only used to construct Crubit-specific names.  All three callers
should be therefore okay with an Itanium name on every target platform:

*   Rust identifiers for C++ template specializations
    (`__CcTemplateInst...`) and C++ identifiers for virtual upcast
    thunks.  The Microsoft scheme uses `?`, `@` and `$`, which are not
    valid in identifiers.
*   `#[cfi_encoding]`, which `rustc` defines in terms of the Itanium
    C++ ABI mangling on all target platforms.  See also
    https://github.com/rust-lang/rust/blob/574ff7d98bd6d037e5236a8453029173b32631fd/compiler/rustc_sanitizers/src/cfi/typeid/mod.rs#L39-L55

This change adds a second, always-Itanium mangler that is used only for
tag type names.  `mangler_` keeps its role of producing real symbol
names for the target.

Also adds `Platform::X86Windows` so that the new regression test in
`ir_from_cc_test.rs` can ask for `x86_64-pc-windows-msvc` bindings.

PiperOrigin-RevId: 981851655
@copybara-service
copybara-service Bot merged commit 4f6f52f into main Sep 15, 2026
7 checks passed
@copybara-service
copybara-service Bot deleted the test_981314301 branch September 15, 2026 15:57
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.

1 participant