From: Petter Tomner <tomner@kth.se>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
Petter Tomner <tomner@kth.se>,
"jit@gcc.gnu.org" <jit@gcc.gnu.org>
Subject: [PATCH 3/3] jit: Add support for weak linkage
Date: Sun, 8 Aug 2021 15:21:56 +0000 [thread overview]
Message-ID: <52a93e6eea764dd191e56539b77ddefb@kth.se> (raw)
In-Reply-To: <44423472d36e42f1a6e3612b704ba513@kth.se>
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 --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.
--
2.20.1
prev parent reply other threads:[~2021-08-08 15:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-08 15:07 [PATCH 0/3] " Petter Tomner
2021-08-08 15:18 ` [PATCH 1/3] " Petter Tomner
2021-08-08 15:20 ` [PATCH 2/3] " Petter Tomner
2021-08-08 15:21 ` Petter Tomner [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52a93e6eea764dd191e56539b77ddefb@kth.se \
--to=tomner@kth.se \
--cc=gcc-patches@gcc.gnu.org \
--cc=jit@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).