From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: Phil Muldoon <pmuldoon@redhat.com>
Subject: [PATCH v2 3/4] libcc1: Add 'set compile-gcc'
Date: Thu, 23 Apr 2015 20:38:00 -0000 [thread overview]
Message-ID: <20150423203841.23973.90252.stgit@host1.jankratochvil.net> (raw)
In-Reply-To: <20150423203827.23973.72954.stgit@host1.jankratochvil.net>
Hi,
already approved, reposting just to keep it a part of the series:
https://gcc.gnu.org/ml/gcc-patches/2015-04/msg01299.html
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 v2 2/2] compile: Add 'set compile-gcc'
https://sourceware.org/ml/gdb-patches/2015-04/msg00910.html
Message-ID: <20150423203402.23140.92757.stgit@host1.jankratochvil.net>
Jan
include/ChangeLog
2015-04-21 Jan Kratochvil <jan.kratochvil@redhat.com>
* 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 <jan.kratochvil@redhat.com>
* 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 21cc403..95b9b12 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,
};
@@ -104,7 +106,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 06a91f6..c2a1d5f 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);
next prev parent reply other threads:[~2015-04-23 20:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-23 20:38 [PATCH v2 1/4] libcc1: Introduce GCC_FE_VERSION_1 Jan Kratochvil
2015-04-23 20:38 ` [PATCH v2 2/4] libcc1: set debug compile: Display GCC driver filename Jan Kratochvil
2015-04-23 20:42 ` Jan Kratochvil
2015-04-23 21:56 ` Jeff Law
2015-04-23 20:38 ` Jan Kratochvil [this message]
2015-04-23 21:57 ` [PATCH v2 3/4] libcc1: Add 'set compile-gcc' Jeff Law
2015-04-27 15:23 ` Pedro Alves
2015-04-23 20:38 ` [PATCH v2 4/4] libcc1: 'set debug compile': Display absolute GCC driver filename Jan Kratochvil
2015-04-23 21:57 ` Jeff Law
2015-04-23 21:54 ` [PATCH v2 1/4] libcc1: Introduce GCC_FE_VERSION_1 Jeff Law
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150423203841.23973.90252.stgit@host1.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=pmuldoon@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).