Did this work in 1.13?

https://golang.org/issue/35759 is probably related; see especially the TODO 
here 
<https://github.com/golang/go/blob/5a61de3fe160cc8b327ee893cd74c4d0ce9dc13d/src/cmd/go/internal/load/pkg.go#L1612-L1616>
.
Please file an issue <https://golang.org/issue/new> so we don't lose track 
of it.

On Friday, February 28, 2020 at 8:08:05 AM UTC-5 mi...@ridge.co wrote:

> Hello.
>
> I'm trying to build a shared library using `-buildmode=shared` and make a 
> binary link to this shared library.
>
> The packages are:
>
> github.com/misha-ridge/splitlib/a (-> c)
> github.com/misha-ridge/splitlib/b (-> c)
> github.com/misha-ridge/splitlib/c
> github.com/misha-ridge/splitlib (-> a, b, c)
>
> I'd like to package `a` and `c` into the shared library, and put `b` and 
> `splitlib` into the binary.
>
> I've tried the following:
>
> $ go install -buildmode=shared std
> $ go install -buildmode=shared -linkshared  -gcflags='-N -l' ./a
>
> This produced `libgithub.com-misha-ridge-splitlib-a.so` in the current 
> directory
>
> Then
>
> $ go build -o main -linkshared  -gcflags='-N -l' .
>
> This produced `main` in the current directory that only links to a shared 
> libstd, but not to
> the freshly built lib...splitlib-a.so:
>
> $ ldd main
> linux-vdso.so.1 (0x00007ffea3bfe000)
> libstd.so => /usr/local/go/pkg/linux_amd64_dynlink/libstd.so 
> (0x00007f7ea27f6000)
> libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7ea2631000)
> libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f7ea262c000)
> libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 
> (0x00007f7ea260b000)
> /lib64/ld-linux-x86-64.so.2 (0x00007f7ea4f23000)
> $
>
> The shared library does not contain symbols from splitlib/a or splitlib/b:
>
> $ go tool nm libgithub.com-misha-ridge-splitlib-a.so  | grep splitlib
>   104cd0 D go.link.abihash.libgithub.com-misha-ridge-splitlib-a.so
>
> Only the final binary does:
>
> $ go tool nm main  | grep splitlib
>     2180 T github.com/misha-ridge/splitlib/a.SetC
>     2190 T github.com/misha-ridge/splitlib/b.SetC
>     2170 T github.com/misha-ridge/splitlib/c.Get
>     5210 D github.com/misha-ridge/splitlib/c.i
>     2180 t local.github.com/misha-ridge/splitlib/a.SetC
>     2190 t local.github.com/misha-ridge/splitlib/b.SetC
>     2170 t local.github.com/misha-ridge/splitlib/c.Get
>
> Am I missing some step?
>
> The repository with reproducer is at 
> https://github.com/misha-ridge/splitlib
>
> -- 
> Best,
> Misha.
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/7a193949-9177-4314-8620-ab737e72ae47%40googlegroups.com.

Reply via email to