On Tue, Apr 28, 2020 at 10:49 PM Vincent Blanchon
<blanchon.vinc...@gmail.com> wrote:
>
> I'm building a simple program that has a dependency to 
> github.com/DataDog/zstd, a wrapper of a C code.
> So by default, Go will use the external linker. When debugging with, I can see
>
> host link: "clang" "-m64" "-Wl,-headerpad,1144" "-Wl,-no_pie" 
> "-Wl,-pagezero_size,4000000" "-o" 
> "/var/folders/bb/w1lgkjdx47qd7695hb5r400h0000gn/T/go-build122622791/b001/exe/a.out"
>  "-Qunused-arguments" 
> "/var/folders/bb/w1lgkjdx47qd7695hb5r400h0000gn/T/go-link-023224426/go.o" 
> "/var/folders/bb/w1lgkjdx47qd7695hb5r400h0000gn/T/go-link-023224426/000000.o" 
> [...] 
> "/var/folders/bb/w1lgkjdx47qd7695hb5r400h0000gn/T/go-link-023224426/000053.o" 
> "/var/folders/bb/w1lgkjdx47qd7695hb5r400h0000gn/T/go-link-023224426/000054.o" 
> "/var/folders/bb/w1lgkjdx47qd7695hb5r400h0000gn/T/go-link-023224426/000055.o" 
> "-g" "-O2" "-g" "-O2" "-g" "-O2" "-lpthread" "-g" "-O2" "-framework" 
> "CoreFoundation" "-framework" "Security" "-no-pie"
>
> It links 55 files, from 000000.o to 000055.oIf I had more custom debug, I can 
> see than those files are mostly duplication:
>
> 000004.o is 
> /path/to/go-build/67/678a3a394ba4feae32a2ddb829ea65c1cf24be64248dcbcc3dae709b8e3b826d-d
>  github.com/DataDog/zstd 
> /path/to/go-build/67/678a3a394ba4feae32a2ddb829ea65c1cf24be64248dcbcc3dae709b8e3b826d-d(_x005.o)
> 000005.o is 
> /path/to/go-build/67/678a3a394ba4feae32a2ddb829ea65c1cf24be64248dcbcc3dae709b8e3b826d-d
>  github.com/DataDog/zstd 
> /path/to/go-build/67/678a3a394ba4feae32a2ddb829ea65c1cf24be64248dcbcc3dae709b8e3b826d-d(_x006.o)
>
> I can see 40 times this zstd package among the 55 files. Is it expected? What 
> is the difference between them?
>
> Also, what would happen to the non known cgo packages (not net, os/user or 
> runtime/cgo) if cgo is not enabled? How the internal linker will manage this 
> cgo package?

I may be missing something, but that doesn't look like duplication to
me.  It looks like different files from an archive.  The first one is
_x005.o and the second one is _x006.o.

You will get files like these for each .c file in a package that uses cgo.

Ian

-- 
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/CAOyqgcXfXPmA5YiVZ39JqvpgqZ7mAn84EYiO-ZUXrn9kqjbSMQ%40mail.gmail.com.

Reply via email to