From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-x136.google.com with SMTP id m7so921282lfj.8 for ; Mon, 20 Feb 2023 02:02:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:date:user-agent:subject:to:from:from:to:cc :subject:date:message-id:reply-to; bh=nWqX7VtX1mRTwZZYOnqfx78ITnUUUnfsbYam7nlDWj4=; b=eyNs0TNytfZ6c4b+by3I7JYIYmAJ2tsp8/Z4F6yCDIZ32dUQt6zx0kr6GYl8OM0u0Q kW2EWpcL3nvpysEbvCAH5xXGOGKiPLBbvwzAkCIYRt88sXiLXRTGo9OXdH8wOsbF6ThD 66Cz4ES242qzbFLc2VmxYoHDI5eS6Ea//wOpmMiRu02yWjhysWXuFAqNn6GgSZ9/F9dJ cnMak65fPvk3xVyxYPujYt7ddXOMWZr+hFvakpQarz82VaGG1LJXN7ZSJw2b315lgUwh APscqWCkgk/hOnu1aE9d8LXSW4TrskcsQdXxwmi4E1gtRV5tsVg814GylkWtAySQa/WV GQOQ== 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 From: Gaius Mulley 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 Content-Type: text/plain 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 List-Id: 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. */