From ffde4970d06fd0b03a3e06893ae916894f2cce8f Mon Sep 17 00:00:00 2001
From: Ian Lance Taylor
-The GCC 4.7.0 release includes Go support that is very close to -Go 1. Due to release timing it will not -include the last few changes to the Go 1 libraries. The GCC 4.7.1 -release should include a complete Go 1 compiler and libraries. +The GCC 4.7.1 release and all later 4.7 releases include a complete +Go 1 compiler and libraries. +
+ ++Due to timing, the GCC 4.8.0 and 4.8.1 releases are close to but not +identical to Go 1.1. The GCC 4.8.2 release is expected to include a +complete Go 1.1.1 implementation.
configure
script.
+The prerequisite libraries can be conveniently downloaded using the
+script contrib/download_prerequisites
in the GCC sources.
-Current versions of Ubuntu and current versions of gcc disagree on +Current versions of Ubuntu and versions of GCC before 4.8 disagree on where system libraries and header files are found. This is not a -gccgo issue, and we hope this will be resolved soon. Until it is, -setting these environment variables while configuring and building -gccgo may fix the problem. +gccgo issue. When building older versions of GCC, setting these +environment variables while configuring and building gccgo may fix the +problem.
@@ -309,7 +315,7 @@ gccgo. Both options take directories to search. The-The gccgo compiler does not currently (2012-03-20) record +The gccgo compiler does not currently (2013-06-20) record the file name of imported packages in the object file. You must arrange for the imported data to be linked into the program.
@@ -385,23 +391,23 @@ struct __go_slice {
-The type of a Go function with no receiver is equivalent to a C function -whose parameter types are equivalent. When a Go function returns more -than one value, the C function returns a struct. For example, these -functions have equivalent types: +The type of a Go function is a pointer to a struct (this is +subject to change). The first field in the +struct points to the code of the function, which will be equivalent to +a pointer to a C function whose parameter types are equivalent, with +an additional trailing parameter. The trailing parameter is the +closure, and the argument to pass is a pointer to the Go function +struct. + +When a Go function returns more than one value, the C function returns +a struct. For example, these functions are roughly equivalent:
func GoFunction(int) (int, float64) -struct { int i; float64 f; } CFunction(int) +struct { int i; float64 f; } CFunction(int, void*)-
-A pointer to a Go function is equivalent to a pointer to a C function -when the functions have equivalent types (this is -subject to change). -
-
Go interface
, channel
, and map
types have no corresponding C type (interface
is a
@@ -457,6 +463,14 @@ i := c_open(&name[0], syscall.O_RDONLY, 0);
os.Open
function instead).
+Note that if the C function can block, such as in a call
+to read
, calling the C function may block the Go program.
+Unless you have a clear understanding of what you are doing, all calls
+between C and Go should be implemented through cgo or SWIG, as for
+the gc
compiler.
+
The name of Go functions accessed from C is subject to change. At present the name of a Go function that does not have a receiver is