On Wednesday, March 22, 2017 at 11:00:24 PM UTC+1, Ian Lance Taylor wrote:
>
> On Wed, Mar 22, 2017 at 3:06 AM, Basile Starynkevitch 
> <bas...@starynkevitch.net <javascript:>> wrote: 
> > 
> > First, is Svetlin's golang-sharing-libraries tutorial still exactly 
> correct 
> > for Go1.8 specifically? Its title  Sharing Golang packages to C and Go 
> is a 
> > bit misleading. I just want all my non-main packages to be "shared 
> objects" 
> > in Linux parlance 
> > (because I really don't want them to be compiled twice, once for the 
> main 
> > program and once for the plugin). I don't care if each of my package has 
> its 
> > own *.so file, or if all of them are agglomerated in one single *.so 
> file. 
> > BTW, I would 
> > prefer to avoid having tons of *.so files (what I would probably prefer 
> is 
> > to have all the non-main code of my thing as a single *.so file shared 
> > between main program & plugins). 
>
> As far as I know that is correct. 
>
> > In particular, is issue 12236 still relevant for Go 1.8 ? 
>
> It is fixed in 1.8. 
>
> You may find it helpful to read https://golang.org/s/execmodes . 
>
>
> > I am not sure to understand well how -buildmode=shared & -linkshared 
> should 
> > be used. Is there an up to date tutorial in how to use them precisely? 
>
> Not that I know of. 
>
>
> > So how to force Go to systematically use -buildmode=shared? Is there 
> some 
> > comment directive for that? Or should I provide my own shell script to 
> build 
> > (I do know that the current one build-monimelt.sh is very buggy). 
>
> You would have to use a shell script or something.  There is no way to 
> make it the default, and really that wouldn't even make sense: you 
> would not to use -buildmode=shared when building your main executable, 
> only when building the packages that it imports. 
>
> > Is -buildmode=pie useful for me (I believe that not)? 
>
> I doubt that it is useful. 
>
> > The documentation of -linkshared  is saying just: 
> > 
> >> -linkshared 
> >> link against shared libraries previously created with 
> >> -buildmode=shared. 
> > 
> > 
> > and I find that explanation too short (what happens if by mistake a 
> previous 
> > package was compiled twice, both with -buildmode=shared & 
> -buildmode=default 
> > and what happens if two weeks ago I have compiled my purple package -in 
> some 
> > older version- with -buildmode=default and today I am compiling it -an 
> > improved version- with -buildmode=shared) ? 
>
> -linkshared is going to find the last package you built and installed 
> using `go install -buildmode=shared ...`. 
>
>

Thanks for the help. Using plugins is really difficult in practice.
 https://blog.ksub.org/bytes/2017/02/12/exploring-shared-objects-in-go/ is 
very helpful.

To Go implementors: the multiple roots error message is *really* cryptic. 
It should be a lot more explicit.

Thanks for reading

-- 
Basile Starynkevitch <http://starynkevitch.net/Basile/> (France)

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to