From patchwork Tue Apr 21 21:41:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 463497 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6CB9E1401AD for ; Wed, 22 Apr 2015 07:42:06 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=XiXR7Jhy; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:cc:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=NXFoTAaY3Ow5gL/2e1+QwVBbcrU0ePbbJb+LN2zYqPTiOCcDgB6rr 1kHgyTbXK3/SOXUa2+lgq5W1+zepIynb/dny8cALGeTAFhwwhz9+1+aGWwgMaOM+ vTNMbIGUxipVoIhXno6D8VdrH+E0zw+GK01iIuvt+RpdPwr6Ndeamc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:cc:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=default; bh=CFSjqw9SwfWTvIuAezYuxQPMIms=; b=XiXR7JhyuIPY9c4mS9ztrYfPDM/D 5Ebb+bnBLxQSDm7ffUC2lRdnag5NzeLc+ocwH4aTrmP6LUCpTgwU6aiJ3wV97SNI 2gCtv5h8cIG5UnVEzVYYIyHCTMUI0oj0yi6LpOM3VslKZqc8ysqe2ametXDqKmAT qrT5zYnSlcIx4aw= Received: (qmail 11773 invoked by alias); 21 Apr 2015 21:41:37 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 11719 invoked by uid 89); 21 Apr 2015 21:41:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 21 Apr 2015 21:41:35 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3LLfXEQ009248 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 21 Apr 2015 17:41:33 -0400 Received: from host1.jankratochvil.net (ovpn-116-27.ams2.redhat.com [10.36.116.27]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3LLfVGj013969; Tue, 21 Apr 2015 17:41:32 -0400 Subject: [PATCH 4/5] libcc1: Add 'set compile-gcc' From: Jan Kratochvil To: gcc-patches@gcc.gnu.org Cc: Phil Muldoon Date: Tue, 21 Apr 2015 23:41:31 +0200 Message-ID: <20150421214131.14972.57617.stgit@host1.jankratochvil.net> In-Reply-To: <20150421214109.14972.34388.stgit@host1.jankratochvil.net> References: <20150421214109.14972.34388.stgit@host1.jankratochvil.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-IsSubscribed: yes as discussed in How to use compile & execute function in GDB https://sourceware.org/ml/gdb/2015-04/msg00026.html GDB currently searches for /usr/bin/ARCH-OS-gcc and chooses one but one cannot override which one. GDB would provide new option 'set compile-gcc'. This patch does not change the libcc1 API as it overloads the triplet_regexp parameter of GCC's set_arguments according to: + if (access (triplet_regexp, X_OK) == 0) GDB counterpart: [PATCH 4/4] compile: Add 'set compile-gcc' https://sourceware.org/ml/gdb-patches/2015-04/msg00808.html Message-ID: <20150421213657.14147.60506.stgit@host1.jankratochvil.net> Jan include/ChangeLog 2015-04-21 Jan Kratochvil * gcc-interface.h (enum gcc_base_api_version): Add comment to GCC_FE_VERSION_1. (struct gcc_base_vtable): Describe triplet_regexp parameter overload for set_arguments. libcc1/ChangeLog 2015-04-21 Jan Kratochvil * libcc1.cc (libcc1_set_arguments): Implement filenames for triplet_regexp. --- include/gcc-interface.h | 7 ++++- libcc1/libcc1.cc | 62 +++++++++++++++++++++++++++-------------------- 2 files changed, 41 insertions(+), 28 deletions(-) diff --git a/include/gcc-interface.h b/include/gcc-interface.h index dd9fd50..a15edf7 100644 --- a/include/gcc-interface.h +++ b/include/gcc-interface.h @@ -46,7 +46,9 @@ enum gcc_base_api_version { GCC_FE_VERSION_0 = 0, - /* Parameter verbose has been moved from compile to set_arguments. */ + /* Parameter verbose has been moved from compile to set_arguments. + Parameter triplet_regexp of set_arguments can be also gcc driver + executable. */ GCC_FE_VERSION_1 = 1, }; @@ -69,7 +71,8 @@ struct gcc_base_vtable /* Set the compiler's command-line options for the next compilation. TRIPLET_REGEXP is a regular expression that is used to match the - configury triplet prefix to the compiler. + configury triplet prefix to the compiler; TRIPLET_REGEXP can be + also absolute filename to the computer. The arguments are copied by GCC. ARGV need not be NULL-terminated. The arguments must be set separately for each compilation; that is, after a compile is requested, the diff --git a/libcc1/libcc1.cc b/libcc1/libcc1.cc index d36073d..e2718b0 100644 --- a/libcc1/libcc1.cc +++ b/libcc1/libcc1.cc @@ -322,38 +322,48 @@ libcc1_set_arguments (struct gcc_base_context *s, self->verbose = verbose != 0; - std::string rx = make_regexp (triplet_regexp, COMPILER_NAME); - // Simulate fnotice by fprintf. - if (self->verbose) - fprintf (stderr, _("searching for compiler matching regex %s\n"), - rx.c_str()); - code = regcomp (&triplet, rx.c_str (), REG_EXTENDED | REG_NOSUB); - if (code != 0) + std::string compiler; + if (access (triplet_regexp, X_OK) == 0) { - size_t len = regerror (code, &triplet, NULL, 0); - char err[len]; + compiler = triplet_regexp; + // Simulate fnotice by fprintf. + if (self->verbose) + fprintf (stderr, _("using explicit compiler filename %s\n"), + compiler.c_str()); + } + else + { + std::string rx = make_regexp (triplet_regexp, COMPILER_NAME); + if (self->verbose) + fprintf (stderr, _("searching for compiler matching regex %s\n"), + rx.c_str()); + code = regcomp (&triplet, rx.c_str (), REG_EXTENDED | REG_NOSUB); + if (code != 0) + { + size_t len = regerror (code, &triplet, NULL, 0); + char err[len]; - regerror (code, &triplet, err, len); + regerror (code, &triplet, err, len); - return concat ("Could not compile regexp \"", - rx.c_str (), - "\": ", - err, - (char *) NULL); - } + return concat ("Could not compile regexp \"", + rx.c_str (), + "\": ", + err, + (char *) NULL); + } - std::string compiler; - if (!find_compiler (triplet, &compiler)) - { + if (!find_compiler (triplet, &compiler)) + { + regfree (&triplet); + return concat ("Could not find a compiler matching \"", + rx.c_str (), + "\"", + (char *) NULL); + } regfree (&triplet); - return concat ("Could not find a compiler matching \"", - rx.c_str (), - "\"", - (char *) NULL); + if (self->verbose) + fprintf (stderr, _("found compiler %s\n"), compiler.c_str()); } - regfree (&triplet); - if (self->verbose) - fprintf (stderr, _("found compiler %s\n"), compiler.c_str()); self->args.push_back (compiler);