-buildmode=shared not supported on linux/mipsle

156 views
Skip to first unread message

Daniel Santos

unread,
May 10, 2019, 7:09:18 PM5/10/19
to golang-dev
What would be needed to add this support?  I'm a gonewb, which is like a "gonoob" but with fewer "o"s.

I'm working on an embedded project with limited resources so I would like to use shared libraries instead of static linking.  I was attempting do this:

$(GO) install -pkgdir go/shared-withlibs-go/libs -buildmode=shared std
$
(GO) build -v -linkshared -pkgdir go/shared-withlibs-go/libs -o go/shared-withlibs-go/hello-world hello-world.go

But, of course, I got the "not supported" message.  In the end I'll probably be building shared libraries instead, I just don't want extra copies of shared code in memory.

Thanks!
Daniel

Michael Hudson-Doyle

unread,
May 12, 2019, 6:58:25 PM5/12/19
to Daniel Santos, golang-dev
You can check in the git history to see what was involved for each architecture but based on my recollection:

1) You need to change the compiler to emit position independent code (this might be very easy or very hard depending on the ISA, I certainly don't know about MIPS here)
2) You need to build support in the compiler and linker for "initial exec" mode TLS
3) You need to write a bit of assembly (following the C, not Go, ABI) that stitches the moduledata 
4) Figure out any other strange rules your platform ABI requires for shared libraries (e.g. on ppc64le you must always do an indirect function call via R12)
5) Update the various tests and checks to make the needed flags available on your architecture.

It's hard to say how much work this is without knowing a lot more about MIPS and its ABIs than I do.

It's also worth saying that shared libraries in Go have not ended up being a much used feature so I don't know if all this is worth the effort on your side.

Cheers,
mwh

Reply all
Reply to author
Forward
0 new messages