diff mbox

libgo patch committed: Build libnetgo.a

Message ID CAOyqgcXkem1v9JZ53TAqGOmN2p_Rr6C_g=Bi8SCrv6m69XQc8g@mail.gmail.com
State New
Headers show

Commit Message

Ian Lance Taylor April 7, 2015, 6:09 p.m. UTC
PR 63731 points out that when using gccgo there is no way to request a
Go program that uses the native Go DNS lookup code rather than using
the system libraries.  This patch from Lynn Boger at least provides a
mechanism for that, by adding a -lnetgo library that can be used to
pick up the Go DNS lookup routines.  This isn't complete fix because
we still need to document it somewhere.  Bootstrapped on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Comments

Lynn A. Boger April 8, 2015, 12:41 p.m. UTC | #1
I see there is some documentation about build constraints in 
go/go/build/doc.go.
There is no mention of netgo on this page now but this seems like an 
appropriate
spot to mention the use of the netgo tag for gc and then how to achieve the
equivalent effect with gccgo.

On 04/07/2015 01:09 PM, Ian Lance Taylor wrote:
> PR 63731 points out that when using gccgo there is no way to request a
> Go program that uses the native Go DNS lookup code rather than using
> the system libraries.  This patch from Lynn Boger at least provides a
> mechanism for that, by adding a -lnetgo library that can be used to
> pick up the Go DNS lookup routines.  This isn't complete fix because
> we still need to document it somewhere.  Bootstrapped on
> x86_64-unknown-linux-gnu.  Committed to mainline.
>
> Ian
diff mbox

Patch

diff -r 9ea7cea1d658 libgo/Makefile.am
--- a/libgo/Makefile.am	Mon Apr 06 18:15:34 2015 -0700
+++ b/libgo/Makefile.am	Tue Apr 07 11:08:23 2015 -0700
@@ -105,7 +105,7 @@ 
 toolexeclib_LIBRARIES = libgobegin-llgo.a
 else
 toolexeclib_LTLIBRARIES = libgo.la
-toolexeclib_LIBRARIES = libgobegin.a
+toolexeclib_LIBRARIES = libgobegin.a libnetgo.a
 endif
 
 toolexeclibgo_DATA = \
@@ -774,9 +774,7 @@ 
 endif
 endif
 
-go_net_files = \
-	go/net/cgo_unix.go \
-	$(go_net_cgo_file) \
+go_net_common_files = \
 	$(go_net_cloexec_file) \
 	go/net/dial.go \
 	go/net/dnsclient.go \
@@ -820,6 +818,15 @@ 
 	go/net/unixsock.go \
 	go/net/unixsock_posix.go
 
+go_net_files = \
+	go/net/cgo_unix.go \
+	$(go_net_cgo_file) \
+	$(go_net_common_files)
+
+go_netgo_files = \
+	go/net/cgo_stub.go \
+	$(go_net_common_files)
+
 if LIBGO_IS_SOLARIS
 if LIBGO_IS_386
 go_os_dir_file = go/os/dir_largefile.go
@@ -2025,6 +2032,9 @@ 
 libgobegin_llgo_a_SOURCES = \
 	runtime/go-main.c
 
+libnetgo_a_SOURCES = $(go_netgo_files)
+libnetgo_a_LIBADD = netgo.o
+
 LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
 
 GOCFLAGS = $(CFLAGS)
@@ -2049,6 +2059,12 @@ 
 	files=`echo $^ | sed -e 's/[^ ]*\.gox//g'`; \
 	$(LTGOCOMPILE) -I . -c -fgo-pkgpath=`echo $@ | sed -e 's/.lo$$//' -e 's/-go$$//'` -o $@ $$files
 
+# Build netgo.o.
+BUILDNETGO = \
+	$(MKDIR_P) $(@D); \
+	files=`echo $^ | sed -e 's/[^ ]*\.gox//g'`; \
+	$(GOCOMPILE) -I . -c -fgo-pkgpath=net -o $@ $$files
+
 GOTESTFLAGS =
 GOBENCH = 
 
@@ -2270,6 +2286,12 @@ 
 	@$(CHECK)
 .PHONY: net/check
 
+@go_include@ netgo.o.dep
+netgo.o.dep: $(go_netgo_files)
+	$(BUILDDEPS)
+netgo.o: $(go_netgo_files)
+	$(BUILDNETGO)
+
 @go_include@ os.lo.dep
 os.lo.dep: $(go_os_files)
 	$(BUILDDEPS)