From 2adb671d186febfe9610f8d8ac8ba296b79d2c90 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 30 Aug 2016 03:27:43 +0000 Subject: compiler: add -fgo-c-header=FILE to create a C header The new -fgo-c-header=FILE option will write a C header file defining all the struct types and numeric const values in package scope. This will be used when building the Go runtime package (libgo/go/runtime) to generate a C header file that may be included by the C code in the C runtime package (libgo/runtime). This will ensure that the Go code and C code are working with the same data structures as we convert the runtime from C to Go to upgrade to the current GC runtime, notably the concurrent garbage collector. Reviewed-on: https://go-review.googlesource.com/28000 * lang.opt (fgo-c-header, fgo-compiling-runtime): New options. * go-c.h (struct go_create_gogo_args): Define. (go_create_gogo): Change declaration to take struct pointer. * go-lang.c (go_c_header): New static variable. (go_langhook_init): Update call to go_create_gogo. * gccgo.texi (Invoking gccgo): Document -fgo-c-header and -fgo-compiling-runtime. From-SVN: r239852 --- gcc/go/go-lang.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'gcc/go/go-lang.c') diff --git a/gcc/go/go-lang.c b/gcc/go/go-lang.c index 570f5e0..88667e0 100644 --- a/gcc/go/go-lang.c +++ b/gcc/go/go-lang.c @@ -83,6 +83,7 @@ struct GTY(()) language_function 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; /* Language hooks. */ @@ -99,9 +100,18 @@ go_langhook_init (void) to, e.g., unsigned_char_type_node) but before calling build_common_builtin_nodes (because it calls, indirectly, go_type_for_size). */ - go_create_gogo (INT_TYPE_SIZE, POINTER_SIZE, go_pkgpath, go_prefix, - go_relative_import_path, go_check_divide_zero, - go_check_divide_overflow, go_debug_escape_level); + struct go_create_gogo_args args; + args.int_type_size = INT_TYPE_SIZE; + args.pointer_size = POINTER_SIZE; + args.pkgpath = go_pkgpath; + args.prefix = go_prefix; + args.relative_import_path = go_relative_import_path; + args.c_header = go_c_header; + args.check_divide_by_zero = go_check_divide_zero; + args.check_divide_overflow = go_check_divide_overflow; + args.compiling_runtime = go_compiling_runtime; + args.debug_escape_level = go_debug_escape_level; + go_create_gogo (&args); build_common_builtin_nodes (); @@ -247,6 +257,10 @@ go_langhook_handle_option ( go_relative_import_path = arg; break; + case OPT_fgo_c_header_: + go_c_header = arg; + break; + default: /* Just return 1 to indicate that the option is valid. */ break; -- cgit v1.1