From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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-x131.google.com with SMTP id a26so2265186lfk.10 for ; Mon, 20 Feb 2023 02:34:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:date:subject:to:from:from:to:cc :subject:date:message-id:reply-to; bh=nWqX7VtX1mRTwZZYOnqfx78ITnUUUnfsbYam7nlDWj4=; b=mek+fNzX8ZLS3hzNV84jhsGHykmyTvbFADSEqnBuvI3QPxl2OJxV1DyrJ+YrANCO6w GJq0PxU9yuH3vdisCZySsx70dklQdu5QT4zWjDwgXihRsSX0PwymNKxeEVYkOA9scBrz SwAnGbo/+LcLe7VhdKaqV+sl5rc8EWDGYhNF7jSoAuUoq5WWNBMwFpO23Jrk8ThjQKAM RtHT130VRGEr47A5CbtyqFlPg6uryYWzCb88H7yYk20wd1Ga/f9MgiBoebEO+yaA1VVU et1Bb4uwsq1CKcOHqJ1/E5k3QH6qx1TJncWyjpyO2bSXumYthkVi6W6hTe/UtcnLo61J NLzQ== 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-Google-Smtp-Source: AK7set/WmkluAjON0ElWHDKTlz+eD1rK7bIjyRpzqyuYaYQ6mHRBuJuL1H3vq7EWRHGl+QgBmRA3WQ== 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 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] 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 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. */