From patchwork Sun Feb 19 18:05:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gaius Mulley X-Patchwork-Id: 59362 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1237435wrn; Mon, 20 Feb 2023 02:45:47 -0800 (PST) X-Google-Smtp-Source: AK7set9Ab8OxmQSBr7zdicUHEuVzfA4nhuZpd0MEbXjbJ5fgRvhEXLx2yZJNkeQtYhL9VY4fURDr X-Received: by 2002:a17:906:4dce:b0:8a4:e0a2:e77f with SMTP id f14-20020a1709064dce00b008a4e0a2e77fmr9270530ejw.34.1676889947463; Mon, 20 Feb 2023 02:45:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676889947; cv=none; d=google.com; s=arc-20160816; b=LFKNSZwz63v1FiwGjx6f1EPJsJwcPvohB3Xs+/PmD/U4LxP9FNKOEwbnvLPZK65MT5 VcKw1PGRSfQZePhSXI+2MsrMLzEuQgcxCPFG0oAMUv/3idhvGVdKZL6+yzkC53h5O0qC z3Kk3x4+V2ujei8+fNShjKwz3YcGZBOMb0QcPaFG0KWY2rpAaQ5w+hYxnrVPdOK9GnlP /c9V8g3bEGvMSH74+QHJRnmTmoNAmbmrtq4nnSTJlK6GnysPJelhXTe7eom49ZzrHgbN PgVh+N9kUv0dx3jkFFbcY04csHNr7GzXI5iEFnvO/KW3CtPA8pL32SaKvv/OKY7oo/tv Tmkw== 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 :user-agent:message-id:date:subject:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=nWqX7VtX1mRTwZZYOnqfx78ITnUUUnfsbYam7nlDWj4=; b=jp7NY4wAkMsID+fuGMEOl+vUo85zijhpDg8GZg0B/hWIz1Kui9xGebQS5Ja/8NUT3A H5AZSirSQJySK3FPTWZfy72QXX2PhCbLil7cGbmIzGydk6bK8IWaA4hcbvNexV1O0v7M h5QNRe0Bg4v22xGM5/bCRveIEGfwRni30wieN8bWnlJOuLwFMw3aUmKskmerjA21Suel yF5WleISGkGO0/NW1t5RBgzUs1Q20YbNfLbTEuT0QkSIh5VbhGC2mVSbDvFSwwow+2xB lcSh75C4tDSlqsQind3CtF/U40hw2QTaPs/vWvRs1vFnTTgSFD4oglvuL09X/LxmwVWs 8J6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=dptYumcV; 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 uj42-20020a170907c9aa00b008d1693c2123si3349395ejc.549.2023.02.20.02.45.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 02:45:47 -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=dptYumcV; 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 8945338114EA for ; Mon, 20 Feb 2023 10:35:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8945338114EA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676889331; bh=nWqX7VtX1mRTwZZYOnqfx78ITnUUUnfsbYam7nlDWj4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=dptYumcVmQvpJTaTn/o1XOM+U+vqFDqCRJWSxqsX+dNSANruOIs97mGYlx23b9yyZ wIHYed6A1llE053idtKmR/Es8rtc23PA9eoAGN4NQbpIx+77bk2Z9toy+MVTyMOlNq vv847mjF6Q9QRkiL0pAfOauNiZzpsJ++iaqo+7q8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by sourceware.org (Postfix) with ESMTPS id 35A363835E20 for ; Mon, 20 Feb 2023 10:34:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 35A363835E20 Received: by mail-lf1-x131.google.com with SMTP id a26so2265186lfk.10 for ; Mon, 20 Feb 2023 02:34:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nWqX7VtX1mRTwZZYOnqfx78ITnUUUnfsbYam7nlDWj4=; b=WygpxgCodSwQu4atvWsi5zySpus/pVq0p6MMamXeaBTNYMWX9/afYIpvQR13SfpCyi 2JByttV4BskDY4zMEUprONujD1g+juBELYw0MtQ8XmGnlbOilIeie64b8M8cMwweymyi NTgx7TJqVugigdi7qbK5Iwra159lOY8jPKQ/TJNcJU3K3HO6tmJ7wHnHUyEeH+hvz5Ce fZ8I+NWOvqO6BuRVbWJz1FICKeJLX+bSzTYRAlAEG9ii7YazmMbRiBsZqN5T8sadjuRa O10g8EX6aDocGMblGHJ+qRyx+FYffr/1NveNphIKSwqGQwVjuwJxMuu8uP/D+GbokJN6 ZO9w== X-Gm-Message-State: AO0yUKX1mSXwAQs+qsdaxbnk+SjHmqSyVChoP2PGPkpHngGWyC4PoGdG CtpgIKS4+Pw49hDc5TYGnmi6zoyQnEU= X-Received: by 2002:a5d:58e4:0:b0:2c5:5574:5d5f with SMTP id f4-20020a5d58e4000000b002c555745d5fmr2351760wrd.57.1676829953765; Sun, 19 Feb 2023 10:05:53 -0800 (PST) Received: from lancelot ([82.152.222.179]) by smtp.gmail.com with ESMTPSA id a18-20020adffb92000000b002bfd524255esm2163512wrr.43.2023.02.19.10.05.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Feb 2023 10:05:53 -0800 (PST) Received: from gaius by lancelot with local (Exim 4.94.2) (envelope-from ) id 1pTo4N-00BI7G-Lp; Sun, 19 Feb 2023 18:05:51 +0000 To: gcc-patches@gcc.gnu.org, Joseph Myers Subject: [PATCH] Allow front ends to register spec functions gcc/{gcc.cc,gcc.h} [PR108261] Date: Sun, 19 Feb 2023 18:05:51 +0000 Message-ID: <87zg99pm2o.fsf@debian> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) 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?1758346553719774240?= 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. */