Fix Check failed: buffer.str().take_front(4) == kZtsPrefix on Windows. - #2013
Merged
Merged
Conversation
copybara-service
Bot
force-pushed
the
test_981314301
branch
from
September 15, 2026 15:33
6b31c33 to
8e6420d
Compare
Check failed: buffer.str().take_front(4) == kZtsPrefix.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:
* 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
Bot
force-pushed
the
test_981314301
branch
from
September 15, 2026 15:57
8e6420d to
4f6f52f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix
Check failed: buffer.str().take_front(4) == kZtsPrefixon Windows.Importer::GetMangledNameused the target platform's mangler to computethe mangled name of a tag type. When targeting an MSVC-ABI platform
this produced a Microsoft-mangled name, and
rs_bindings_from_ccaborted on
CHECK(buffer.str().take_front(4) == kZtsPrefix). The fixis to always use Itanium mangling for Crubit's
mangled_cc_name.mangled_cc_namedoesn't have to correspond to a real symbol, becauseit is only used to construct Crubit-specific names. All three callers
should be therefore okay with an Itanium name on every target platform:
(
__CcTemplateInst...) and C++ identifiers for virtual upcastthunks. The Microsoft scheme uses
?,@and$, which are notvalid in identifiers.
#[cfi_encoding], whichrustcdefines in terms of the ItaniumC++ 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 symbolnames for the target.
Also adds
Platform::X86Windowsso that the new regression test inir_from_cc_test.rscan ask forx86_64-pc-windows-msvcbindings.