From 437dea7dbc01ffd075b1d9c60172c13a19757ba5 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Fri, 10 Jun 2022 13:31:09 -0400 Subject: [PATCH 1/2] Add module mangling New , reductions, global initializer special name. --- abi.html | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 70 insertions(+), 4 deletions(-) diff --git a/abi.html b/abi.html index b2df8ab..3e9882a 100644 --- a/abi.html +++ b/abi.html @@ -4592,11 +4592,11 @@
Names
::= <template-param> # template template parameter ::= <substitution> - <unqualified-name> ::= <operator-name> [<abi-tags>] + <unqualified-name> ::= [<module-name>] <operator-name> [<abi-tags>] ::= <ctor-dtor-name> - ::= <source-name> - ::= <unnamed-type-name> - ::= DC <source-name>+ E # structured binding declaration + ::= [<module-name>] <source-name> + ::= [<module-name>] <unnamed-type-name> + ::= [<module-name>] DC <source-name>+ E # structured binding declaration <source-name> ::= <positive length number> <identifier> <identifier> ::= <unqualified source code identifier> @@ -4611,6 +4611,45 @@
Names
may be either a function or data object name when derived from <name>, or a class or enum name when derived from <type>. + +
Modules
+ +

C++20 modules add a new linkage kind — module-linkage. This +is implemented by extending the mangling scheme to encode module +attachment. The symbols themselves will have the existing external +and/or weak/comdat ELF linkage. The strong-ownership model is +implemented — the symbols of exported entities with named-module +attachment are mangled with a module-name component. + +


+    <module-name> ::= <module-component>
+                  ::= <module-name> <module-component>
+                  ::= <substitution>
+    <module-component> ::= W <source-name>
+                       ::= W P <source-name>  # First component of partition
+
+ +

The <module-name> component is prefixed to the +namespace-scope entity with named-module attachment. Module +partitions are only applicable for global initializers. +<module-name>s are substitutable, using the same sequence +numbering as other substitutable components. However, the +<module-name> substitutions are orthogonal, and attach +independently to the +<source-name> they prefix. If +the <source-name> is +subtitutable, its substitituion includes its module attachment. +Notice this introduces an ambiguity in the grammar, which can be +resolved by inspecting whether a substition refers to a +<module-name> or another entity. + +For example: +

+  export module Foo:part;
+  export struct Quux;
+  export void Foo (Quux *) {}; //  mangles as _ZW3Foo3FooPS_4Quux
+
+
ABI tags
@@ -4980,6 +5019,33 @@
5.1.4.6 Transaction-Safe Function <special-name> ::= GTt <encoding> + +
5.1.4.7 Module Initializer +Function
+ +

Namespace-scope static objects with dynamic-initializers that are +defined in importable named-module translation units are initialized +by an idempotent initializer function. These initializer functions are +called by importing translation-units, prior to their own dynamic +initialization of such objects. (Therefore the module-initializer +function of an importable unit will call the module-initializer +functions of its own imports.) It is permitted to omit calls to +module-initializer functions that are known to be indirectly called by +another called module-initializer. It is also permitted to omit calls +to module-initializer functions known to have no dynamic +initializations. It is unspecified how an implemntation aranges any +indirect module-initializer functions of that module-initializer. + +

A module-initializer function must arrange to be called during the +usual (non-modular) dynamic initialization process, for instance by +adding a pointer to it in the .init_array section. + +


+  <special-name>:= GI <module-name>
+
+ +

The <module-name> includes any partition component. +

5.1.5 Type encodings

From 35ba138676d78b4e71e0d081026210318bc9ddc6 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 18 Oct 2024 17:06:23 -0400 Subject: [PATCH 2/2] Update abi.html Co-authored-by: Po-Yao Chang --- abi.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abi.html b/abi.html index 3e9882a..cdc41c0 100644 --- a/abi.html +++ b/abi.html @@ -5033,7 +5033,7 @@
5.1.4.7 Module Initializer module-initializer functions that are known to be indirectly called by another called module-initializer. It is also permitted to omit calls to module-initializer functions known to have no dynamic -initializations. It is unspecified how an implemntation aranges any +initializations. It is unspecified how an implementation arranges any indirect module-initializer functions of that module-initializer.

A module-initializer function must arrange to be called during the