commit | 09c6d13ac248eefd1d47e20457125ab5ac8b3246 | [log] [tgz] |
---|---|---|
author | Ian Lance Taylor <iant@golang.org> | Sat Sep 26 18:37:06 2015 -0700 |
committer | Ian Lance Taylor <iant@golang.org> | Mon Sep 28 04:37:31 2015 +0000 |
tree | a0e7ff23d82029e5235229f2c3a8f05dcbcb7973 | |
parent | 82a9d90eda1e1aba06883727756c1e4a06abe772 [diff] |
cmd/cgo: only declare real function in gccgo exported header file When exporting a function using gccgo, we generate two functions: a Go function with a leading Cgoexp_ prefix, and a C function that calls the Go function. The Go function has a name that can not be represented in C, so the C code needs a declaration with an __asm__ qualifier giving the name of the Go function. Before this CL we put that declaration in the exported header file. Because code would sometimes #include "_cgo_export.h", we added a macro definition for the C function giving it the name of the declaration. We then added a macro undefine in the actual C code, so that we could declare the C function we wanted. This rounadabout process worked OK until we started exporting the header file for use with -buildmode=c-archive and c-shared. Doing that caused the code to see the define and thus call the Go function rather than the C function. That often works fine, but the C function calls _cgo_wait_runtime_init_done before calling the Go function, and that sometimes matters. This didn't show up in tests because we don't test using gccgo. That is something we should fix, but not now. Fix that by simplifying the code to declare the C function in the header file as one would expect, and move the __asm__ declaration to the C code. Change-Id: I33547e028152ff98e332630994b4f33285feec32 Reviewed-on: https://go-review.googlesource.com/15043 Reviewed-by: Minux Ma <minux@golang.org>
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
For documentation about how to install and use Go, visit https://golang.org/ or load doc/install-source.html in your web browser.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Please report issues here: https://golang.org/issue/new
Go is the work of hundreds of contributors. We appreciate your help!
To contribute, please read the contribution guidelines: https://golang.org/doc/contribute.html
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
If you have just untarred a binary Go distribution, you need to set the environment variable $GOROOT to the full path of the go directory (the one containing this file). You can omit the variable if you unpack it into /usr/local/go, or if you rebuild from sources by running all.bash (see doc/install-source.html). You should also add the Go binary directory $GOROOT/bin to your shell's path.
For example, if you extracted the tar file into $HOME/go, you might put the following in your .profile:
export GOROOT=$HOME/go export PATH=$PATH:$GOROOT/bin
See https://golang.org/doc/install or doc/install.html for more details.