diff mbox series

[3/3] jit: Add support for weak linkage

Message ID 52a93e6eea764dd191e56539b77ddefb@kth.se
State New
Headers show
Series jit: Add support for weak linkage | expand

Commit Message

Petter Tomner Aug. 8, 2021, 3:21 p.m. UTC
This patch updates the documentation concerning the addition of weak linkage for 'gcc_jit_context_new_function()' and  'gcc_jit_context_new_global()'. The documentation needs regeneration.

gcc/jit/docs/topics/
	* compilation.rst
	* expressions.rst
	* functions.rst
---
 gcc/jit/docs/topics/compilation.rst |  3 ++-
 gcc/jit/docs/topics/expressions.rst | 13 +++++++++++++
 gcc/jit/docs/topics/functions.rst   | 20 +++++++++++++++++---
 3 files changed, 32 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/gcc/jit/docs/topics/compilation.rst b/gcc/jit/docs/topics/compilation.rst
index b6ace12120f..67c7ac5f7f3 100644
--- a/gcc/jit/docs/topics/compilation.rst
+++ b/gcc/jit/docs/topics/compilation.rst
@@ -57,7 +57,8 @@  In-memory compilation
    with a name matching `funcname` must have been created on
    `result`'s context (or a parent context) via a call to
    :func:`gcc_jit_context_new_function` with `kind`
-   :macro:`GCC_JIT_FUNCTION_EXPORTED`:
+   :macro:`GCC_JIT_FUNCTION_EXPORTED` or 
+   :macro:`GCC_JIT_FUNCTION_EXPORTED_WEAK`:
 
    .. code-block:: c
 
diff --git a/gcc/jit/docs/topics/expressions.rst b/gcc/jit/docs/topics/expressions.rst
index 396259ef07e..e3a57264732 100644
--- a/gcc/jit/docs/topics/expressions.rst
+++ b/gcc/jit/docs/topics/expressions.rst
@@ -582,6 +582,19 @@  Global variables
       referring to it.  Analogous to using an "extern" global from a
       header file.
 
+   .. c:macro:: GCC_JIT_GLOBAL_EXPORTED_WEAK
+
+      Global is defined by the client code with weak linkage and is visible
+      by name outside of this JIT context via
+      :c:func:`gcc_jit_result_get_global`.  Analogous to declaring a variable
+      with ``__attribute__((weak))``.
+
+      When compiled to file weak linkage allow multiple definitions
+      of the same symbol name in different files all being linked 
+      together. Note that child contexts include their parent and 
+      can't have more than one variable with the same name no matter
+      if weak or not.
+
 .. function:: gcc_jit_lvalue *\
               gcc_jit_global_set_initializer (gcc_jit_lvalue *global,\
                                               const void *blob,\
diff --git a/gcc/jit/docs/topics/functions.rst b/gcc/jit/docs/topics/functions.rst
index b2d9239aa0a..31de2147e10 100644
--- a/gcc/jit/docs/topics/functions.rst
+++ b/gcc/jit/docs/topics/functions.rst
@@ -90,9 +90,8 @@  Functions
          Function is defined by the client code and visible
          by name outside of the JIT.
 
-         This value is required if you want to extract machine code
-         for this function from a :type:`gcc_jit_result` via
-         :func:`gcc_jit_result_get_code`.
+         With this value you can extract machine code for this function
+         from a :type:`gcc_jit_result` via :func:`gcc_jit_result_get_code`.
 
       .. macro::   GCC_JIT_FUNCTION_INTERNAL
 
@@ -117,6 +116,21 @@  Functions
          above 0; when optimization is off, this is essentially the
          same as GCC_JIT_FUNCTION_INTERNAL.
 
+      .. macro:: GCC_JIT_FUNCTION_EXPORTED_WEAK
+
+         Function is defined by the client code with weak linkage and 
+         is visible by name outside of the JIT.  Analogous to a function
+         with ``__attribute__((weak))``.
+
+         When compiled to file weak linkage allow multiple definitions
+         of the same symbol name in different files all being linked 
+         together. Note that child contexts include their parent and 
+         can't have more than one function with the same name no matter
+         if weak or not.
+
+         With this value you can extract machine code for this function
+         from a :type:`gcc_jit_result` via :func:`gcc_jit_result_get_code`.
+
    The parameter ``name`` must be non-NULL.  The call takes a copy of the
    underlying string, so it is valid to pass in a pointer to an on-stack
    buffer.