On Wed, Sep 28, 2016 at 10:29 AM, Dave Goehrig <d...@dloh.org> wrote:
>
> On x86_64-linux, golang 1.7.1 in cmd/cgo/out.go  lines 248-277 explicitly
> creates a dynamically linked elf file when compiling via go (but not gccgo,
> cf line 3359 of cmd/go/build.go.
> It appears that there is no way to build a static /bin/go as a result of
> this code.  Is this correct?
>
> I ask because the environment I'm trying to build go for doesn't support
> shared libraries or dynamic loading (no ld-linux), and would love to know if
> there is a way to do it.

The code you mention in the cgo tool is used when doing a dynamic
link, but not when doing a static link.

If you don't need cgo, set CGO_ENABLED=0 when you build the go tools,
and you will get statically linked binaries.

If you do need cgo, you will to pass -extldflags=-static to tell the
external linker to do a static link.

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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to