Skip to content

Commit e9ac2c0

Browse files
committed
Add vendor-specific suffixes to mangling RFC 2063
1 parent 9d3df39 commit e9ac2c0

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

text/2603-rust-symbol-name-mangling-v0.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,8 @@ Mangled names conform to the following grammar:
623623

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

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

803808

809+
### Vendor-specific suffix
810+
811+
Similarly to the [Itanium C++ ABI mangling scheme][itanium-mangling-structure], a symbol name
812+
containing a period (`.`) represents a vendor-specific version of the symbol. There are no
813+
restrictions on the characters following the period.
814+
815+
This can happen in practice when locally unique names needed to become globally unique. For example,
816+
LLVM can append a `.llvm.<numbers>` suffix during LTO to ensure a unique name. In these situations
817+
it's generally fine to ignore the suffix: the suffixed name has the same semantics as the original.
818+
819+
[itanium-mangling-structure]: https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-structure
820+
804821
## Compression
805822

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

0 commit comments

Comments
 (0)