https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63731
Bug ID: 63731 Summary: Fallback to netgo does not work Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: go Assignee: ian at airs dot com Reporter: yohei at jp dot ibm.com CC: cmang at google dot com When the DNS resolver with CGO fails for statically linked binaries, it should fall back to the pure-go DNS resolver, if I understand correctly. This fallback mechanism does work at least on Linux for x86_64 and ppc64le. The variable ok in lookupIP in go/net/lookup_unix.go seems always set to true, so the fallback mechanism would never be called. Here is an example code to demonstrate the problem. $ gccgo -v Using built-in specs. COLLECT_GCC=gccgo COLLECT_LTO_WRAPPER=/usr/local/gccgo-216834/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../src/configure --enable-threads=posix --enable-shared --enable-__cxa_atexit --enable-languages=c,c++,go --enable-secureplt --enable-checking=yes --with-long-double-128 --enable-decimal-float --disable-bootstrap --disable-alsa --disable-multilib --prefix=/usr/local/gccgo-216834 Thread model: posix gcc version 5.0.0 20141029 (experimental) (GCC) $ cat lookup.go package main import ( "fmt" "net" ) func main() { addrs, err := net.LookupHost("gcc.gnu.org") if err != nil { fmt.Println(err) } else { for i := 0; i < len(addrs); i++ { fmt.Println(addrs[i]) } } } $ gccgo lookup.go $ ./a.out 209.132.180.131 $ gccgo -static lookup.go /usr/local/gccgo-216834/lib/gcc/x86_64-unknown-linux-gnu/5.0.0/../../../../lib64/libgo.a(net.o): In function `net.cgoLookupPort': /home/yohei/gccgo.216834/bld/x86_64-unknown-linux-gnu/libgo/../../../src/libgo/go/net/cgo_unix.go:83: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking $ ./a.out lookup gcc.gnu.org: Name or service not known $ LD_LIBRARY_PATH=/lib/x86_64-linux-gnu ./a.out 209.132.180.131