From d029408a45f751e9bbef0276d0080abef09a6557 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 3 Aug 2023 13:11:07 +0200 Subject: [PATCH 1/2] Specify `#[link_ordinal]` and `#[link]` "raw-dylib" --- src/attributes.rst | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/src/attributes.rst b/src/attributes.rst index 40555d23..0e800fd9 100644 --- a/src/attributes.rst +++ b/src/attributes.rst @@ -134,6 +134,7 @@ Built-in Attributes | LinkContent | LinkNameContent | LinkSectionContent + | LinkOrdinalContent | MacroExportContent | MacroUseContent | NoBinutilsContent @@ -1031,6 +1032,7 @@ Attribute ``link`` NativeLibrayKindType ::= $$dylib$$ + | $$raw-dylib$$ | $$framework$$ | $$static$$ @@ -1054,6 +1056,9 @@ The following native library kinds are available: * - :dp:`fls_wpqawdpevkj6` - dylib - Dynamic library + * - :dp:`fls_HPl6poXGiAqV` + - raw-dylib + - Dynamic library * - :dp:`fls_h9dfs6kzmobp` - framework - macOS framework @@ -1070,6 +1075,15 @@ on macOS targets. If :t:`attribute` :c:`link` appears without a WebAssembly module name, then the WebAssembly module name defaults to ``env``. +:dp:`fls_iDjcQczFQknm` +When :t:`attribute` :c:`link` appears with ``raw-dylib`` as the native library +kind, the supplied name must include the file extension. + +:dp:`fls_rcERq1PfKPJI` +When :t:`attribute` :c:`link` appears with ``raw-dylib`` as the native library +kind, the :t:`[external function]s` and :t:`[external static]s` of the related +:t:`external block` shall not be subject to :t:`attribute` :c:`no_mangle`. + .. rubric:: Examples .. code-block:: rust @@ -1099,6 +1113,11 @@ Attribute ``link_name`` :t:`Attribute` :dc:`link_name` shall specify the linking symbol of the related :t:`external function` or :t:`external static`. +:dp:`fls_0Athv8KFA5FO` +:t:`Attribute` :dc:`link_name` shall not be applied to :t:`[external function]s` +and :t:`[external static]s` that are annotated with :t:`Attribute` +:c:`link_ordinal`. + .. rubric:: Examples .. code-block:: rust @@ -1137,6 +1156,43 @@ symbol of the related :t:`function` or :t:`static` will be placed. #[link_section = ".example_section"] pub static THE_ANSWER: u32 = 42; +.. _fls_Obik2w9gvhLN: + +Attribute ``link_ordinal`` +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. rubric:: Syntax + +.. syntax:: + + LinkOrdinalContent ::= + $$link_ordinal$$ $$($$ DecimalLiteral $$)$$ + +.. rubric:: Legality Rules + +:dp:`fls_fuv29BIqcawW` +:t:`Attribute` :c:`link_ordinal` shall apply to :t:`[external function]s` and +:t:`[external static]s`. + +:dp:`fls_qh5sXG4znAXa` +The related :t:`extern block` of the :t:`[external function]` or +:t:`[external static]` shall be subject to :t:`attribute` :c:`link` with +``raw-dylib`` as the native library kind. + +:dp:`fls_d00wni4edi8f` +:t:`Attribute` :dc:`link_ordinal` shall specify the linking symbol of the +related :t:`external function` or :t:`external static` by ordinal number. + +.. rubric:: Examples + +.. code-block:: rust + + #[link(name = "lib.dll", kind = "raw-dylib")] + extern "system" { + #[link_ordinal(16)] + fn function(); + } + .. _fls_ch9nkxkloozv: Attribute ``no_link`` From 79e1db7e6820a0f4747b7f06f9d6e2d0c3367098 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 3 Aug 2023 13:24:56 +0200 Subject: [PATCH 2/2] Specify `extern "C-unwind"` --- src/attributes.rst | 4 ++-- src/ffi.rst | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/attributes.rst b/src/attributes.rst index 0e800fd9..0db78806 100644 --- a/src/attributes.rst +++ b/src/attributes.rst @@ -1114,7 +1114,7 @@ Attribute ``link_name`` :t:`external function` or :t:`external static`. :dp:`fls_0Athv8KFA5FO` -:t:`Attribute` :dc:`link_name` shall not be applied to :t:`[external function]s` +:t:`Attribute` :c:`link_name` shall not be applied to :t:`[external function]s` and :t:`[external static]s` that are annotated with :t:`Attribute` :c:`link_ordinal`. @@ -1179,7 +1179,7 @@ The related :t:`extern block` of the :t:`[external function]` or :t:`[external static]` shall be subject to :t:`attribute` :c:`link` with ``raw-dylib`` as the native library kind. -:dp:`fls_d00wni4edi8f` +:dp:`fls_ASnJJiXWGlKI` :t:`Attribute` :dc:`link_ordinal` shall specify the linking symbol of the related :t:`external function` or :t:`external static` by ordinal number. diff --git a/src/ffi.rst b/src/ffi.rst index 295c980d..6968b631 100644 --- a/src/ffi.rst +++ b/src/ffi.rst @@ -65,6 +65,10 @@ The following :t:`[ABI]s` are supported: ``extern "C"`` - The default :t:`ABI` of :t:`C` code, referred to as :dt:`extern C ABI`. +* :dp:`fls_LfjvLXvI6TFL` + ``extern "C-unwind"`` - The same as ``extern "C"`` with the addition that + unwinding across FFI is expected. + * :dp:`fls_a2d8ltpgtvn6` ``extern "Rust"`` - The default :t:`ABI` of a Rust program, referred to as :dt:`Rust ABI`. @@ -183,7 +187,7 @@ An :t:`external function` shall be invoked from an :t:`unsafe context`. An :t:`external function` shall not specify a :s:`FunctionQualifierList`. :dp:`fls_w00qi1gx204e` -An :t:`external function` inherits the :t:`ABI` of its enclosing +An :t:`external function` inherits the :t:`ABI` of its enclosing :t:`external block`. :dp:`fls_m7tu4w4lk8v`