Skip to content

Commit fef292b

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

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

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

+22-1
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 `.` or `$`.
753+
<vendor-specific-suffix> = ("." | "$") <suffix>
749754
```
750755

751756
### Namespace Tags
@@ -801,6 +806,21 @@ 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],
812+
a symbol name containing a period (`.`) or a dollar sign (`$`) represents a
813+
vendor-specific version of the symbol. There are no restrictions on the
814+
characters following the period or dollar sign.
815+
816+
This can happen in practice when locally unique names needed to become globally
817+
unique. For example, LLVM can append a `.llvm.<numbers>` suffix during LTO to
818+
ensure a unique name, and `$` can be used for thread-local data on Mach-O. In
819+
these situations it's generally fine to ignore the suffix: the suffixed name has
820+
the same semantics as the original.
821+
822+
[itanium-mangling-structure]: https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-structure
823+
804824
## Compression
805825

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

0 commit comments

Comments
 (0)