diff mbox

Eliminate libgo.so dependency for go and gofmt tools in gotools/

Message ID 562125C4.70107@linux.vnet.ibm.com
State New
Headers show

Commit Message

Lynn A. Boger Oct. 16, 2015, 4:28 p.m. UTC
To make it easier to use gotools go and gofmt, add -static-libgo when 
linking them.  This makes it nicer
in all cases since it eliminates the dependency on libgo.so for these 
tools, but it is mostly helpful for
the cross compiled case.  When building for use in the cross compiled 
case, this allows for go and gofmt
to be built with a gccgo that is available during the build but then 
libgo.so is not a dependency when using go
or gofmt once the build is finished.

The cgo tool is also built here but since that is needed during 
compiling with gccgo I left that as is.

2015-10-16    Lynn Boger <laboger@linux.vnet.ibm.com>

gotools/
                     Makefile.am:  Add -static-libgo to the link for
                     go and gofmt tools.
                     Makefile.in:  Regenerate.

Comments

Ian Lance Taylor Oct. 16, 2015, 4:37 p.m. UTC | #1
On Fri, Oct 16, 2015 at 9:28 AM, Lynn A. Boger
<laboger@linux.vnet.ibm.com> wrote:
> To make it easier to use gotools go and gofmt, add -static-libgo when
> linking them.  This makes it nicer
> in all cases since it eliminates the dependency on libgo.so for these tools,
> but it is mostly helpful for
> the cross compiled case.  When building for use in the cross compiled case,
> this allows for go and gofmt
> to be built with a gccgo that is available during the build but then
> libgo.so is not a dependency when using go
> or gofmt once the build is finished.

This was already tried and rejected.  See http://gcc.gnu.org/PR64738 .

I think that if you really want this you need to make it a configure
option or make variable.  We don't seem to use GOLDFLAGS; perhaps we
should.  Then you could set it from make or configure.

Ian
diff mbox

Patch

Index: gotools/Makefile.am
===================================================================
--- gotools/Makefile.am	(revision 228851)
+++ gotools/Makefile.am	(working copy)
@@ -109,10 +109,12 @@  bin_PROGRAMS = go$(EXEEXT) gofmt$(EXEEXT)
 noinst_PROGRAMS = cgo$(EXEEXT)
 man_MANS = go.1 gofmt.1
 
+# Add -static-libgo to the link for go and gofmt to avoid the libgo.so  
+# dependency.
 go$(EXEEXT): $(go_cmd_go_files) zdefaultcc.go $(LIBGODEP)
-	$(GOLINK) $(go_cmd_go_files) zdefaultcc.go $(LIBS) $(NET_LIBS)
+	$(GOLINK) -static-libgo $(go_cmd_go_files) zdefaultcc.go $(LIBS) $(NET_LIBS)
 gofmt$(EXEEXT): $(go_cmd_gofmt_files) $(LIBGODEP)
-	$(GOLINK) $(go_cmd_gofmt_files) $(LIBS) $(NET_LIBS)
+	$(GOLINK) -static-libgo $(go_cmd_gofmt_files) $(LIBS) $(NET_LIBS)
 cgo$(EXEEXT): $(go_cmd_cgo_files) zdefaultcc.go $(LIBGODEP)
 	$(GOLINK) $(go_cmd_cgo_files) zdefaultcc.go $(LIBS) $(NET_LIBS)
 
Index: gotools/Makefile.in
===================================================================
--- gotools/Makefile.in	(revision 228851)
+++ gotools/Makefile.in	(working copy)
@@ -663,10 +663,12 @@  s-zdefaultcc: Makefile
 	$(SHELL) $(srcdir)/../move-if-change zdefaultcc.go.tmp zdefaultcc.go
 	$(STAMP) $@ 
 
+# Add -static-libgo to the link for go and gofmt to avoid the libgo.so  
+# dependency.
 @NATIVE_TRUE@go$(EXEEXT): $(go_cmd_go_files) zdefaultcc.go $(LIBGODEP)
-@NATIVE_TRUE@	$(GOLINK) $(go_cmd_go_files) zdefaultcc.go $(LIBS) $(NET_LIBS)
+@NATIVE_TRUE@	$(GOLINK) -static-libgo $(go_cmd_go_files) zdefaultcc.go $(LIBS) $(NET_LIBS)
 @NATIVE_TRUE@gofmt$(EXEEXT): $(go_cmd_gofmt_files) $(LIBGODEP)
-@NATIVE_TRUE@	$(GOLINK) $(go_cmd_gofmt_files) $(LIBS) $(NET_LIBS)
+@NATIVE_TRUE@	$(GOLINK) -static-libgo $(go_cmd_gofmt_files) $(LIBS) $(NET_LIBS)
 @NATIVE_TRUE@cgo$(EXEEXT): $(go_cmd_cgo_files) zdefaultcc.go $(LIBGODEP)
 @NATIVE_TRUE@	$(GOLINK) $(go_cmd_cgo_files) zdefaultcc.go $(LIBS) $(NET_LIBS)