Descriptionruntime: Add shared library support (linux/amd64+linux/arm)
Add the nescessary hooks to enable Go programs to be output
to a shared library and called from foreign programs, e.g. C.
The linker registers _rt0_amd64|arm_linux_lib to be run as a library
initialization function. On the first cgo callback from the main
program, _cgo_lib_init is called. _cgo_lib_init in turn
starts a new thread that runs the Go runtime initialization,
_rt0_amd64/_rt0_arm_linux1. _cgo_lib_init uses a barrier to wait for
the runtime to complete inititialization before continuing.
Other than running on a new thread, the Go runtime itself is not changed,
except for allowing (and expecting) the Go main() function to complete.
Since argc and argv cannot be reliably accessed from a shared library
initializer, the runtime is changed to allow os.Args to have zero length.
In that case, auxv is fetched from /proc/auxv instead.
The environment is fetched from the global variable environ.
Deadlock detection is effectively disabled in shared library mode, even when
no Cgo calls have been made, since it is not possible to determine whether
the main program will call into Go at some later time.
On amd64 the test must be run manually,
since -shared is only supported when the standard library have been built
with -largeflags:
GO_GCFLAGS=-largemodel GO_CCFLAGS=-largemodel ./all.bash
On ARM the test is run as part of the test suite in run.bash.
Updates issue 4848.
Updates issue 256.
Updates issue 2790.
Design proposal at https://groups.google.com/forum/?fromgroups#!topic/golang-nuts/zmjXkGrEx6Q
Patch Set 1 #Patch Set 2 : diff -r 3f530b76de99 https://go.googlecode.com/hg/ #Patch Set 3 : diff -r 3f530b76de99 https://go.googlecode.com/hg/ #Patch Set 4 : diff -r 41702da0dcc4 https://go.googlecode.com/hg/ #Patch Set 5 : diff -r 1c764773c6ce https://go.googlecode.com/hg/ #Patch Set 6 : diff -r 1c764773c6ce https://go.googlecode.com/hg/ #Patch Set 7 : diff -r a3545f2fb0a2 https://go.googlecode.com/hg/ #Patch Set 8 : diff -r f70198907de7 https://go.googlecode.com/hg/ #Patch Set 9 : diff -r 39a7093ee8db69539235d88e325df1dbabd82cc5 https://go.googlecode.com/hg/ #Patch Set 10 : diff -r 39a7093ee8db69539235d88e325df1dbabd82cc5 https://go.googlecode.com/hg/ #Patch Set 11 : diff -r 39a7093ee8db69539235d88e325df1dbabd82cc5 https://go.googlecode.com/hg/ #Patch Set 12 : diff -r 39a7093ee8db69539235d88e325df1dbabd82cc5 https://go.googlecode.com/hg/ #Patch Set 13 : diff -r 39a7093ee8db69539235d88e325df1dbabd82cc5 https://go.googlecode.com/hg/ #Patch Set 14 : diff -r a69e4649cb34d02cbda7eb751e255da1e5cfa355 https://go.googlecode.com/hg/ #
Total comments: 2
Patch Set 15 : diff -r 3833ddddde2b1a2741a396c4e965b04d525a133b https://go.googlecode.com/hg/ #
MessagesTotal messages: 10
|