Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vendor-specific suffixes to v0 mangling RFC 2603 #3224

Merged
merged 1 commit into from
Mar 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 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 `.` or `$`.
<vendor-specific-suffix> = ("." | "$") <suffix>
```

### Namespace Tags
Expand Down Expand Up @@ -801,6 +806,21 @@ 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 (`.`) or a dollar sign (`$`) represents a
vendor-specific version of the symbol. There are no restrictions on the
characters following the period or dollar sign.

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, and `$` can be used for thread-local data on Mach-O. 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 +1176,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.