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: 1744979 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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: legolas.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=KrBO3L4j; 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PKyft2DSzz23r4 for ; Mon, 20 Feb 2023 21:03:34 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 929C43858CDB for ; Mon, 20 Feb 2023 10:03:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 929C43858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676887410; bh=nWqX7VtX1mRTwZZYOnqfx78ITnUUUnfsbYam7nlDWj4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=KrBO3L4joBO962ZYCruaKsAILwU1GF70Yn44DVbpVqOYmoLQPVMME3iAtfhMz6Gz7 5tN6H1DYONLxbIrl+A8v3zY1njEGUTEZBXrD2GC2WYbi4XnizWOIYMcF1I+ihT88/z HWaqJsGk9MKi8f+pQq/X/Z3XP3U1IWW8cC1h2dB0= 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-Google-Smtp-Source: AK7set9tCQiirCxUvr00/8KukTZMYF08sFMjAXuLVq9qsgkYxRawOvBUwLMOVbE9hhdmkZBWhT66fQ== 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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. */