Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1022)

Issue 9738047: code review 9738047: runtime: Add shared library support (linux/amd64)

Can't Edit
Can't Publish+Mail
Start Review
Created:
6 years, 4 months ago by elias.naur
Modified:
5 years, 2 months ago
Visibility:
Public.

Description

runtime: 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/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+554 lines, -51 lines) Patch
A misc/cgo/testshared/main.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +18 lines, -0 lines 0 comments Download
A misc/cgo/testshared/mainadv.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +67 lines, -0 lines 0 comments Download
A misc/cgo/testshared/mainmult.c View 1 2 3 4 5 6 7 1 chunk +14 lines, -0 lines 0 comments Download
A misc/cgo/testshared/shared.go View 1 2 3 4 5 6 7 1 chunk +34 lines, -0 lines 0 comments Download
A misc/cgo/testshared/shared2.go View 1 2 3 4 5 6 7 8 1 chunk +18 lines, -0 lines 0 comments Download
A misc/cgo/testshared/test.bash View 1 2 3 4 5 6 7 8 1 chunk +42 lines, -0 lines 0 comments Download
M src/cmd/cgo/out.go View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/runtime/asm_386.s View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +5 lines, -0 lines 0 comments Download
M src/pkg/runtime/asm_amd64.s View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 5 chunks +13 lines, -4 lines 0 comments Download
M src/pkg/runtime/asm_arm.s View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +4 lines, -0 lines 0 comments Download
A src/pkg/runtime/cgo/gcc_sharedlib_linux.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +130 lines, -0 lines 0 comments Download
M src/pkg/runtime/cgo/libcgo.h View 1 1 chunk +10 lines, -0 lines 0 comments Download
A src/pkg/runtime/cgo/sharedlib_linux.c View 1 2 3 4 5 6 7 8 1 chunk +22 lines, -0 lines 0 comments Download
M src/pkg/runtime/os_linux_arm.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 chunks +54 lines, -22 lines 0 comments Download
M src/pkg/runtime/proc.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 4 chunks +30 lines, -5 lines 0 comments Download
M src/pkg/runtime/rt0_linux_amd64.s View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +6 lines, -0 lines 0 comments Download
M src/pkg/runtime/rt0_linux_arm.s View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +5 lines, -0 lines 0 comments Download
M src/pkg/runtime/runtime.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +1 line, -0 lines 0 comments Download
M src/pkg/runtime/runtime.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 chunks +12 lines, -2 lines 0 comments Download
M src/pkg/runtime/softfloat_arm.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +10 lines, -0 lines 0 comments Download
M src/pkg/runtime/vdso_linux_amd64.c View 1 2 chunks +44 lines, -17 lines 0 comments Download
M src/run.bash View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +14 lines, -0 lines 0 comments Download

Messages

Total messages: 10
elias.naur
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://go.googlecode.com/hg/
6 years, 4 months ago (2013-05-29 20:18:51 UTC) #1
rsc
I'd like to see the design fleshed out more before checking in or reviewing code. ...
6 years, 4 months ago (2013-06-03 20:12:02 UTC) #2
elias.naur
Added linux/arm support and updated to apply to tip.
6 years, 3 months ago (2013-06-24 15:22:28 UTC) #3
gobot
Replacing golang-dev with golang-codereviews.
5 years, 9 months ago (2013-12-20 16:11:03 UTC) #4
oleku
On 2013/06/24 15:22:28, elias.naur wrote: > Added linux/arm support and updated to apply to tip. ...
5 years, 6 months ago (2014-04-04 10:56:44 UTC) #5
rsc
This won't be in Go 1.3. We still need to work out and agree on ...
5 years, 6 months ago (2014-04-07 13:57:03 UTC) #6
oleku
Thanks for the update .. would remind you after the 1.3 release ... On Monday, ...
5 years, 6 months ago (2014-04-07 17:05:18 UTC) #7
rsc
R=close please 'hg mail' after 1.3 to reopen https://codereview.appspot.com/9738047/diff/37001/src/pkg/runtime/os_linux_arm.c File src/pkg/runtime/os_linux_arm.c (right): https://codereview.appspot.com/9738047/diff/37001/src/pkg/runtime/os_linux_arm.c#newcode35 src/pkg/runtime/os_linux_arm.c:35: #pragma ...
5 years, 6 months ago (2014-04-17 02:53:50 UTC) #8
ishan.anand
Now that 1.3 is out, any shot of this going in the next release? Working ...
5 years, 3 months ago (2014-07-17 20:38:30 UTC) #9
minux
5 years, 2 months ago (2014-07-18 19:22:51 UTC) #10
On Thu, Jul 17, 2014 at 4:38 PM, <ishan.anand@gmail.com> wrote:

> Now that 1.3 is out, any shot of this going in the next release? Working
> on an open source Go library that would be great to distribute as a
> runtime that C programs can link to.
>
I think we need to discuss the details first on golang-dev.
One such detail is: if I load two Go shared libraries, should them be able
to
communicate directly? e.g. can i pass a channel from one to another?

limited linux/arm dyanmic library support is already in the tree to support
android/arm.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b