Skip to content

cmd/go: With Go 1.4, cannot statically link a program which imports net #9344

@glyn

Description

@glyn

In Go 1.3.x, it was possible to statically link a program which imports the net package. This is important when building programs for cut-down environments, for example busybox.

The problem can be reproduced on Ubuntu as reported by Vasiliy Tolstov:

package main 
import "net" 
func main() { 
        _, _ = net.ResolveIPAddr("ip", "google.com") 
} 

It is possible to statically link this program in Go 1.3.x by issuing:

CGO_ENABLED=0 go build -a -x

but with Go 1.4, the same technique creates the following runtime dependencies:

linux-vdso.so.1 (0x00007fff603fe000) 
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f3bd0608000) 
libc.so.6 => /lib64/libc.so.6 (0x00007f3bd0260000) 
/lib64/ld-linux-x86-64.so.2 (0x00007f3bd0825000) 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions