Skip to content

Commit

Permalink
Add vendor-specific suffixes to mangling RFC 2603
Browse files Browse the repository at this point in the history
  • Loading branch information
lqd committed Mar 2, 2022
1 parent 9d3df39 commit 16f95f9
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion text/2603-rust-symbol-name-mangling-v0.md
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,8 @@ Mangled names conform to the following grammar:

```
// The <decimal-number> specifies the encoding version.
<symbol-name> = "_R" [<decimal-number>] <path> [<instantiating-crate>]
<symbol-name> =
"_R" [<decimal-number>] <path> [<instantiating-crate>] [<vendor-specific-suffix>]
<path> = "C" <identifier> // crate root
| "M" <impl-path> <type> // <T> (inherent impl)
Expand Down Expand Up @@ -746,6 +747,10 @@ Mangled names conform to the following grammar:
// We use <path> here, so that we don't have to add a special rule for
// compression. In practice, only a crate root is expected.
<instantiating-crate> = <path>
// There are no restrictions on the characters that may be used
// in the suffix following the `.`.
<vendor-specific-suffix> = "." <suffix>
```

### Namespace Tags
Expand Down Expand Up @@ -801,6 +806,18 @@ With this post-processing in place the Punycode strings can be treated
like regular identifiers and need no further special handling.


### Vendor-specific suffix

Similarly to the [Itanium C++ ABI mangling scheme][itanium-mangling-structure], a symbol name
containing a period (`.`) represents a vendor-specific version of the symbol. There are no
restrictions on the characters following the period.

This can happen in practice when locally unique names needed to become globally unique. For example,
LLVM can append a `.llvm.<numbers>` suffix during LTO to ensure a unique name. In these situations
it's generally fine to ignore the suffix: the suffixed name has the same semantics as the original.

[itanium-mangling-structure]: https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-structure

## Compression

Symbol name compression works by substituting parts of the mangled
Expand Down Expand Up @@ -1156,3 +1173,4 @@ pub static QUUX: u32 = {
- Make `<binder>` optional in `<fn-sig>` and `<dyn-bounds>` productions.
- Extend `<const-data>` to include `bool` values, `char` values, and negative integer values.
- Remove type from constant placeholders.
- Allow vendor-specific suffixes.

0 comments on commit 16f95f9

Please sign in to comment.