From patchwork Mon Feb 20 01:06:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gaius Mulley X-Patchwork-Id: 59339 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1226399wrn; Mon, 20 Feb 2023 02:13:34 -0800 (PST) X-Google-Smtp-Source: AK7set8AtrNzPjwQ/sgOdQPjWzq+cxjvyuOjYUfuhl3RuABYlxquUUNpx5m6FCjOk7FSZTCLnlWP X-Received: by 2002:a17:906:248e:b0:878:814d:bc99 with SMTP id e14-20020a170906248e00b00878814dbc99mr6275081ejb.66.1676888014117; Mon, 20 Feb 2023 02:13:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676888014; cv=none; d=google.com; s=arc-20160816; b=E+CrXSEVfZAcVQuV950DOg/JJCs9xe9hE7vUtL/KwYyhor77qkHIQ/r6hf5UOQR6ra /fLAnKQsU84CbbqJEPhHDudRWhie5jLNdMS0ULT/50SDOTQs6SdlnTH18FTBFiOps3p3 EUjG/rekQMCOfjWPeAdWHjqIbhitLeazpFdlQafDurYG5MdJ4SY7pRAWRaBnCbFi6zlZ ele8ykIIPd7iAsVEiFkNG5iw2GZD3/U7sEOsiwf+9qp9M9x+ekpssZ4nA2cC+QhUwVeB GEMseEArAovkr16k+Rbkng3nUfWAQtXW9UgU0ZqYwAcqnNTKebT4cuWJ++Ek7fVpTghL 4IIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :message-id:date:user-agent:subject:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=nWqX7VtX1mRTwZZYOnqfx78ITnUUUnfsbYam7nlDWj4=; b=cu9hkHmfcRpn1Wl+unrhPCbmgVZ8AfJMTNUGvSy2L6XQ6NadoKtDziySX1oOrlQblH EyMa8gEVTpwqfcqNlh39lNoDR1pLBMS7dpYnot3lOBzlaU/gTeRw0AVqTjDDcfVOqV8x As6FFekqhrC3VBwW0J6NRmU2A+zP6HaFA/nmICBDhvkKrXrDmHi2HMYWYoDk0GesHJqf xJQ7OWi/nTdwEep0rPyW3Ak1CFsNR6t4OE+svZo6R/O562DCfXQvCX2vrD7qICS7YSRr 3TWbIdnGs9CZUsSvlZcixGn1O++aYxdCyW5N2UX0OvZ6K9/SODUkRsakQgSoaqu72UMD Fsyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=JqdHwvhj; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ew6-20020a170907950600b008c9eb8758desi5462260ejc.915.2023.02.20.02.13.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 02:13:34 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=JqdHwvhj; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 89B16382FD86 for ; Mon, 20 Feb 2023 10:03:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 89B16382FD86 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676887434; bh=nWqX7VtX1mRTwZZYOnqfx78ITnUUUnfsbYam7nlDWj4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=JqdHwvhjzPHnDfh5MKETb33h80HOzmni91AYEjSysJJ9Ys1V/24tOXA+oDNEECP/g DBdPEXbUXeSoOqo/VEONLKG8GOXe476FCXNZT93UdgJ/mPeHPUUj6O1NqT0mqLq0/U W0wvCbMg+O2H24fxvhA/vpnFiI+v6sRMoZ6VUTOw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by sourceware.org (Postfix) with ESMTPS id 81034383DB8C for ; Mon, 20 Feb 2023 10:02:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 81034383DB8C Received: by mail-lf1-x136.google.com with SMTP id m7so921282lfj.8 for ; Mon, 20 Feb 2023 02:02:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:user-agent:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nWqX7VtX1mRTwZZYOnqfx78ITnUUUnfsbYam7nlDWj4=; b=oRtnilRlOv1zjWlLPLYxhEYvmA/5ShXoFc0vndFNbuTJAVP/DszjqOZ6hhqmsUkQqE m6ppU9FUiGKGhgfyzlVQODEgM/f1N4g/eyUN4ueMgpQfncHe183YGF1TOGvnNMYSTdpo eJHl7AepPXbX0LQQaA5jfub6mfIxYIJPMz59YwJqK/pBHwTSipey7Slv9cJhT+9mvvhe iwdhBeBFNf4S+V1oCYmtwC4Oa8BiLqErjT1PjKnzAw68PoFbIzZGU+Zo1e6NW0jxGPcD qP5NFP3Wf0+B0GmldDREGShVM42YLs8alU8TbYnjZxmfgF17bdHmoS4tEb5+Pf+WhyqQ l8Iw== X-Gm-Message-State: AO0yUKXsRZTRoOp+JVVZ2rhEwLKtZF7Byv5oyJYQMh/LMar6xmUEzMmu ZxrKbbpPmx3mT4wy/7kTvdKDdQwnXYk= X-Received: by 2002:a5d:6645:0:b0:2c5:509b:dc54 with SMTP id f5-20020a5d6645000000b002c5509bdc54mr27975wrw.0.1676855178115; Sun, 19 Feb 2023 17:06:18 -0800 (PST) Received: from lancelot ([82.152.222.179]) by smtp.gmail.com with ESMTPSA id p14-20020a5d4e0e000000b002c5a790e959sm2570314wrt.19.2023.02.19.17.06.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Feb 2023 17:06:17 -0800 (PST) Received: from gaius by lancelot with local (Exim 4.94.2) (envelope-from ) id 1pTudD-0009TB-T1; Mon, 20 Feb 2023 01:06:15 +0000 To: gcc-patches@gcc.gnu.org, Joseph Myers Subject: [PATCH] Allow front ends to register spec functions gcc/{gcc.cc,gcc.h} [PR108261] User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Date: Mon, 20 Feb 2023 01:06:15 +0000 Message-ID: <87fsb1no1k.fsf@debian> MIME-Version: 1.0 X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Gaius Mulley via Gcc-patches From: Gaius Mulley Reply-To: Gaius Mulley Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758344526314499087?= X-GMAIL-MSGID: =?utf-8?q?1758344526314499087?= Hello, bootstrapped on gcc master x86_64 and no extra failures generated on all front ends. Would this be ok for trunc? regards, Gaius Allow front ends to register spec functions gcc/{gcc.cc,gcc.h} [PR108261] This patch allows front ends to register spec functions. It is motivated by PR108261 which needs to retain the order of search path related options in the modula-2 front end. gcc/ChangeLog: * gcc.cc (add_spec_function): * gcc.h (add_spec_function): diff --git a/gcc/gcc.cc b/gcc/gcc.cc index becc56051a8..93e4e38389d 100644 --- a/gcc/gcc.cc +++ b/gcc/gcc.cc @@ -46,6 +46,7 @@ compilation is specified by a string called a "spec". */ #include "spellcheck.h" #include "opts-jobserver.h" #include "common/common-target.h" +#include @@ -1774,6 +1775,8 @@ static const struct spec_function static_spec_functions[] = { 0, 0 } }; +static std::vectorlang_spec_functions; + static int processing_spec_function; /* Add appropriate libgcc specs to OBSTACK, taking into account @@ -6825,9 +6828,25 @@ lookup_spec_function (const char *name) if (strcmp (sf->name, name) == 0) return sf; + for (auto *sf : lang_spec_functions) + if (strcmp (sf->name, name) == 0) + return sf; + return NULL; } +/* Add a new spec function. */ + +void +add_spec_function (const char *name, + const char *(*func) (int, const char **)) +{ + struct spec_function *sf = XNEW (struct spec_function); + sf->name = name; + sf->func = func; + lang_spec_functions.push_back (sf); +} + /* Evaluate a spec function. */ static const char * diff --git a/gcc/gcc.h b/gcc/gcc.h index 19a61b373ee..f40de0f5520 100644 --- a/gcc/gcc.h +++ b/gcc/gcc.h @@ -73,6 +73,8 @@ struct spec_function extern int do_spec (const char *); extern void record_temp_file (const char *, int, int); extern void set_input (const char *); +extern void add_spec_function (const char *name, + const char *(*func) (int, const char **)); /* Spec files linked with gcc.cc must provide definitions for these. */