Thanks very much Karan, that's indeed a good approach for this challenge.

Here is the output from a dynamically linked executable:

abort
__errno_location
fprintf
fputc
free
freeaddrinfo
fwrite
gai_strerror
getaddrinfo
getnameinfo
malloc
mmap
munmap
nanosleep
pthread_attr_destroy
pthread_attr_getstacksize
pthread_attr_init
pthread_cond_broadcast
pthread_cond_wait
pthread_create
pthread_mutex_lock
pthread_mutex_unlock
pthread_sigmask
setenv
sigaction
sigaddset
sigemptyset
sigfillset
sigismember
stderr
strerror
unsetenv
vfprintf

Now this initiative of go compiler producing a dynamic executable looks 
quite redundant.

I shall find some time to reduce this go project, file an issue, and see if 
go developers can share more insights.

Kind regards,
Howard

On Tuesday, 7 November 2017 11:21:26 UTC+1, Karan Chaudhary wrote:
>
> With a quick look,  it seems "net" is not the only pkg which depends on 
> cgo,  though by default it uses pure Go DNS resolver only.
>
> I tested on small program:
> package main
>
> import (
>         "fmt"
>         "net/http"
> )
>
> func main() {
>
>         fmt.Println("Hello, playground")
>         http.ListenAndServe(":9999", nil)
>
> }
>
> Which is dynamically linked if CGO_ENABLED=1 is set,  and statically 
> linked if CGO_ENABLED=0 is set,  irrespective of GODEBUG=netdns=go .
> Diffing the cgo symbols from ELFs from the 2 cases shows that enabling cgo 
> adds 61 more functions:
> _cgo_b0c710f30cfd_C2func_
> _cgo_b0c710f30cfd_C2func_
> _cgo_b0c710f30cfd_Cfunc__
> _cgo_b0c710f30cfd_Cfunc_f
> _cgo_b0c710f30cfd_Cfunc_f
> _cgo_b0c710f30cfd_Cfunc_g
> _cgo_b0c710f30cfd_Cfunc_g
> _cgo_b0c710f30cfd_Cfunc_g
> cgo_context_function
> _cgo_get_context_function
> _cgo_panic
> _cgo_panic
> _cgo_release_context
> _cgo_sys_thread_start
> _cgo_topofstack
> _cgo_topofstack
> _cgo_try_pthread_create
> _cgo_wait_runtime_init_do
> net._cgo_b0c710f30cfd_C2f
> net._cgo_b0c710f30cfd_Cfu
> net._cgo_b0c710f30cfd_Cfu
> net._cgo_b0c710f30cfd_Cfu
> net._cgo_b0c710f30cfd_Cfu
> net._cgo_cmalloc
> net.cgoIPLookup
> net.cgoLookupIP
> net.cgoLookupIPCNAME
> net.cgoLookupIPCNAME.func
> net.cgoLookupIPCNAME.func
> net.cgoLookupIPCNAME.func
> net.cgoLookupPort
> net.cgoLookupServicePort
> net.cgoLookupServicePort.
> net.cgoLookupServicePort.
> net.cgoLookupServicePort.
> net.cgoPortLookup
> runtime.cgoAlwaysFalse
> runtime/cgo(.bss)
> runtime.cgocallback
> runtime.cgoCheckArg
> runtime.cgoCheckPointer
> runtime.cgoCheckUnknownPo
> runtime._cgo_panic_intern
> runtime/cgo(.rodata)
> runtime/cgo(.rodata.str1.
> runtime/cgo(.rodata.str1.
> runtime/cgo(.text)
> runtime.cgoUse
> x_cgo_callers
> x_cgo_init
> x_cgo_inittls
> x_cgo_mmap
> x_cgo_munmap
> x_cgo_notify_runtime_init
> x_cgo_set_context_functio
> x_cgo_setenv
> x_cgo_sigaction
> x_cgo_sys_thread_create
> x_cgo_threadentry
> x_cgo_thread_start
> x_cgo_unsetenv
>
> Here we can see "net" is not the only pkg that uses CGO,  but runtime uses 
> it as well.
> These can be explored to understand more.
>

-- 
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