public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Go patch committed: Accept -fgo-embedcfg option
@ 2021-01-05  1:41 Ian Lance Taylor
  2021-01-05 10:06 ` Andreas Schwab
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Lance Taylor @ 2021-01-05  1:41 UTC (permalink / raw)
  To: gcc-patches, gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 628 bytes --]

This patch adds a new -fgo-embedcfg option.  This will be used by the
go command to implement the go:embed directive that is new in the
upcoming Go 1.16 release.  The option doesn't yet do anything, this is
just framework.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian

* lang.opt (fgo-embedcfg): New option.
* go-c.h (struct go_create_gogo_args): Add embedcfg field.
* go-lang.c (go_embedcfg): New static variable.
(go_langhook_init): Set go_create_gogo_args embedcfg field.
(go_langhook_handle_option): Handle OPT_fgo_embedcfg_.
* gccgo.texi (Invoking gccgo): Document -fgo-embedcfg.

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 2698 bytes --]

19d240387d930c7c049927f47351ccd6cbde0853
diff --git a/gcc/go/gccgo.texi b/gcc/go/gccgo.texi
index 37adf20d55b..ce6b518bb7b 100644
--- a/gcc/go/gccgo.texi
+++ b/gcc/go/gccgo.texi
@@ -262,6 +262,15 @@ Apply special rules for compiling the runtime package.  Implicit
 memory allocation is forbidden.  Some additional compiler directives
 are supported.
 
+@item -fgo-embedcfg=@var{file}
+@cindex @option{-fgo-embedcfg}
+Identify a JSON file used to map patterns used with special
+@code{//go:embed} comments to the files named by the patterns.  The
+JSON file should have two components: @code{Patterns} maps each
+pattern to a list of file names, and @code{Files} maps each file name
+to a full path to the file.  This option is intended for use by the
+@command{go} command to implement @code{//go:embed}.
+
 @item -g
 @cindex @option{-g for gccgo}
 This is the standard @command{gcc} option (@pxref{Debugging Options, ,
diff --git a/gcc/go/go-c.h b/gcc/go/go-c.h
index 651a787088a..5930eadf7fd 100644
--- a/gcc/go/go-c.h
+++ b/gcc/go/go-c.h
@@ -41,6 +41,7 @@ struct go_create_gogo_args
   const char* prefix;
   const char* relative_import_path;
   const char* c_header;
+  const char* embedcfg;
   Backend* backend;
   Linemap* linemap;
   bool check_divide_by_zero;
diff --git a/gcc/go/go-lang.c b/gcc/go/go-lang.c
index eba40e471a2..a01db8dbdcd 100644
--- a/gcc/go/go-lang.c
+++ b/gcc/go/go-lang.c
@@ -89,6 +89,7 @@ static const char *go_pkgpath = NULL;
 static const char *go_prefix = NULL;
 static const char *go_relative_import_path = NULL;
 static const char *go_c_header = NULL;
+static const char *go_embedcfg = NULL;
 
 /* Language hooks.  */
 
@@ -112,6 +113,7 @@ go_langhook_init (void)
   args.prefix = go_prefix;
   args.relative_import_path = go_relative_import_path;
   args.c_header = go_c_header;
+  args.embedcfg = go_embedcfg;
   args.check_divide_by_zero = go_check_divide_zero;
   args.check_divide_overflow = go_check_divide_overflow;
   args.compiling_runtime = go_compiling_runtime;
@@ -282,6 +284,10 @@ go_langhook_handle_option (
       go_c_header = arg;
       break;
 
+    case OPT_fgo_embedcfg_:
+      go_embedcfg = arg;
+      break;
+
     default:
       /* Just return 1 to indicate that the option is valid.  */
       break;
diff --git a/gcc/go/lang.opt b/gcc/go/lang.opt
index 454a118695e..7d6780eb0cd 100644
--- a/gcc/go/lang.opt
+++ b/gcc/go/lang.opt
@@ -57,6 +57,10 @@ fgo-dump-
 Go Joined RejectNegative
 -fgo-dump-<type>	Dump Go frontend internal information.
 
+fgo-embedcfg=
+Go Joined RejectNegative
+-fgo-embedcfg=<file>	List embedded files via go:embed
+
 fgo-optimize-
 Go Joined
 -fgo-optimize-<type>	Turn on optimization passes in the frontend.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Go patch committed: Accept -fgo-embedcfg option
  2021-01-05  1:41 Go patch committed: Accept -fgo-embedcfg option Ian Lance Taylor
@ 2021-01-05 10:06 ` Andreas Schwab
  2021-01-05 15:15   ` Jakub Jelinek
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2021-01-05 10:06 UTC (permalink / raw)
  To: Ian Lance Taylor via Gcc-patches; +Cc: gofrontend-dev, Ian Lance Taylor

FAIL: compiler driver --help=go option(s): "^ +-.*[^:.]$" absent from output: "  -fgo-embedcfg=<file>        List embedded files via go:embed"

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Go patch committed: Accept -fgo-embedcfg option
  2021-01-05 10:06 ` Andreas Schwab
@ 2021-01-05 15:15   ` Jakub Jelinek
  2021-01-05 19:49     ` Ian Lance Taylor
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2021-01-05 15:15 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: Ian Lance Taylor via Gcc-patches, Ian Lance Taylor, gofrontend-dev

On Tue, Jan 05, 2021 at 11:06:27AM +0100, Andreas Schwab wrote:
> FAIL: compiler driver --help=go option(s): "^ +-.*[^:.]$" absent from output: "  -fgo-embedcfg=<file>        List embedded files via go:embed"

Fixed thusly, committed as obvious.

2021-01-05  Jakub Jelinek  <jakub@redhat.com>

	* lang.opt (fgo-embedcfg=): Add full stop at the end of description.

--- gcc/go/lang.opt.jj	2021-01-05 09:17:24.754566798 +0100
+++ gcc/go/lang.opt	2021-01-05 16:11:22.647352215 +0100
@@ -59,7 +59,7 @@ Go Joined RejectNegative
 
 fgo-embedcfg=
 Go Joined RejectNegative
--fgo-embedcfg=<file>	List embedded files via go:embed
+-fgo-embedcfg=<file>	List embedded files via go:embed.
 
 fgo-optimize-
 Go Joined

	Jakub


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Go patch committed: Accept -fgo-embedcfg option
  2021-01-05 15:15   ` Jakub Jelinek
@ 2021-01-05 19:49     ` Ian Lance Taylor
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Lance Taylor @ 2021-01-05 19:49 UTC (permalink / raw)
  To: Jakub Jelinek
  Cc: Andreas Schwab, Ian Lance Taylor via Gcc-patches, gofrontend-dev

On Tue, Jan 5, 2021 at 7:15 AM Jakub Jelinek via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> On Tue, Jan 05, 2021 at 11:06:27AM +0100, Andreas Schwab wrote:
> > FAIL: compiler driver --help=go option(s): "^ +-.*[^:.]$" absent from output: "  -fgo-embedcfg=<file>        List embedded files via go:embed"
>
> Fixed thusly, committed as obvious.
>
> 2021-01-05  Jakub Jelinek  <jakub@redhat.com>
>
>         * lang.opt (fgo-embedcfg=): Add full stop at the end of description.

Thanks.

Ian

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-05 19:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-05  1:41 Go patch committed: Accept -fgo-embedcfg option Ian Lance Taylor
2021-01-05 10:06 ` Andreas Schwab
2021-01-05 15:15   ` Jakub Jelinek
2021-01-05 19:49     ` Ian Lance Taylor

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).