diff --git a/docs/ABI/Mangling.rst b/docs/ABI/Mangling.rst index 13603c66c8c..112def4baa3 100644 --- a/docs/ABI/Mangling.rst +++ b/docs/ABI/Mangling.rst @@ -12,6 +12,7 @@ Mangling mangled-name ::= '@__swiftmacro_' global // Swift mangling for filenames mangled-name ::= '_T0' global // Swift 4.0 mangled-name ::= '$S' global // Swift 4.2 + mangled-name ::= '$e' global // Embedded Swift (unstable) All Swift-mangled names begin with a common prefix. Since Swift 4.0, the compiler has used variations of the mangling described in this document, though diff --git a/docs/EmbeddedSwift/ABI.md b/docs/EmbeddedSwift/ABI.md index d868f2c2fdd..f3be5ec377f 100644 --- a/docs/EmbeddedSwift/ABI.md +++ b/docs/EmbeddedSwift/ABI.md @@ -12,6 +12,10 @@ The ABI of code generated by Embedded Swift is not currently stable. For a concr Similarly, do not mix Embedded Swift code with full Swift code, as the ABIs are different. Details are described in the following sections. +## Symbol mangling under Embedded Swift + +Since Swift 5.0, the stable ABI mangling schema uses the `$s` prefix on all Swift symbols. Because Embedded Swift's ABI differs from the stable ABI, and furthermore because it's not expected to be stable, Embedded Swift uses a `$e` mangling prefix. The logic and structure of the mangling stays the same, the only difference is the prefix. + ## Calling convention of Embedded Swift As of today, Embedded Swift has identical calling convention to full Swift. However, this does not need to continue in the future, and there should not be expectations that the ABI of Embedded Swift is compatible with full Swift. diff --git a/include/swift/Demangling/ManglingFlavor.h b/include/swift/Demangling/ManglingFlavor.h index 8603ff0a7e8..db5374d2ca2 100644 --- a/include/swift/Demangling/ManglingFlavor.h +++ b/include/swift/Demangling/ManglingFlavor.h @@ -1,8 +1,8 @@ -//===--- ManglingUtils.h - Utilities for Swift name mangling ----*- C++ -*-===// +//===--- ManglingFlavor.h - Swift name mangling -----------------*- C++ -*-===// // // This source file is part of the Swift.org open source project // -// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors +// Copyright (c) 2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information @@ -23,7 +23,7 @@ SWIFT_BEGIN_INLINE_NAMESPACE /// Which mangling style and prefix to use. enum class ManglingFlavor: uint8_t { - /// Default manling with the ABI stable $s prefix + /// Default mangling with the ABI stable $s prefix Default, /// Embedded Swift's mangling with $e prefix Embedded,