From patchwork Sun Aug 8 15:21:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petter Tomner X-Patchwork-Id: 1514809 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=Q88hcp7S; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GjNHs2xmxz9sXk for ; Mon, 9 Aug 2021 01:22:33 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 029693851C04 for ; Sun, 8 Aug 2021 15:22:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 029693851C04 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1628436148; bh=oblMYTnQu5BPgLjhssy/csL5eyCQ27yXw+1zqQHp/xw=; h=To:Subject:Date:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Q88hcp7SQu7hBQhq2j8SR4J9CdnDkdZTeZ8W56QUNbP9tV2FzIcGaRUMlbvCGhSLn I/QMBiJLVPOCKB0HICz39KzDafZXji71KFlogYjgQ7gXaOM2V5fQoNnzZN/0dR2ehs tO8gbGGeDTpHoB3s6EW6A9u0/8Ho7wLWy2Xc3AQk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-3.sys.kth.se (smtp-3.sys.kth.se [IPv6:2001:6b0:1:1300:250:56ff:fea6:2de2]) by sourceware.org (Postfix) with ESMTPS id 217CA385802D; Sun, 8 Aug 2021 15:21:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 217CA385802D Received: from smtp-3.sys.kth.se (localhost.localdomain [127.0.0.1]) by smtp-3.sys.kth.se (Postfix) with ESMTP id 3A45C320B; Sun, 8 Aug 2021 17:21:58 +0200 (CEST) X-Virus-Scanned: by amavisd-new at kth.se Received: from smtp-3.sys.kth.se ([127.0.0.1]) by smtp-3.sys.kth.se (smtp-3.sys.kth.se [127.0.0.1]) (amavisd-new, port 10024) with LMTP id FzLewX0gFFQc; Sun, 8 Aug 2021 17:21:57 +0200 (CEST) Received: from exdb3.ug.kth.se (exdb3.ug.kth.se [192.168.32.58]) by smtp-3.sys.kth.se (Postfix) with ESMTPS id 511C327E2; Sun, 8 Aug 2021 17:21:57 +0200 (CEST) Received: from exdb6.ug.kth.se (192.168.32.61) by exdb3.ug.kth.se (192.168.32.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.858.15; Sun, 8 Aug 2021 17:21:56 +0200 Received: from exdb6.ug.kth.se ([192.168.32.61]) by exdb6.ug.kth.se ([192.168.32.61]) with mapi id 15.02.0858.015; Sun, 8 Aug 2021 17:21:56 +0200 To: "gcc-patches@gcc.gnu.org" , Petter Tomner , "jit@gcc.gnu.org" Subject: [PATCH 3/3] jit: Add support for weak linkage Thread-Topic: [PATCH 3/3] jit: Add support for weak linkage Thread-Index: AQHXjGkgAIfWl9D8B0SoVuJsiEepMQ== Date: Sun, 8 Aug 2021 15:21:56 +0000 Message-ID: <52a93e6eea764dd191e56539b77ddefb@kth.se> References: <44423472d36e42f1a6e3612b704ba513@kth.se> In-Reply-To: <44423472d36e42f1a6e3612b704ba513@kth.se> Accept-Language: sv-SE, en-US Content-Language: sv-SE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.168.32.250] MIME-Version: 1.0 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Petter Tomner via Gcc-patches From: Petter Tomner Reply-To: Petter Tomner Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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.