diff mbox

[AIX] Changes for linking gotools on AIX.

Message ID B37989F2852398498001550C29155BE51789E965@FRCRPVV9EX4MSX.ww931.my-it-solutions.net
State New
Headers show

Commit Message

REIX, Tony July 26, 2017, 4:41 p.m. UTC
Description:
 * This patch adds linker options for gotools for AIX.

Tests:
 * Fedora25/x86_64 + GCC trunk : Configure/Build: SUCCESS
   - build remade by means of gmake.
   - some test redone in libgo (gmake check)
 * AIX + GCC 7.1.0 :
   - build remade by means of gmake.
   - some test redone in libgo (gmake check)
 
ChangeLog:
 * Makefile.am (AM_LDFLAGS & GOLINK): Changes for linking on AIX.
 * Makefile.in: Rebuild.

Cordialement,

Tony Reix

Bull - ATOS
IBM Coop Architect & Technical Leader
Office : +33 (0) 4 76 29 72 67
1 rue de Provence - 38432 Échirolles - France
www.atos.net

Comments

David Edelsohn July 26, 2017, 4:58 p.m. UTC | #1
On Wed, Jul 26, 2017 at 12:41 PM, REIX, Tony <tony.reix@atos.net> wrote:
> Description:
>  * This patch adds linker options for gotools for AIX.
>
> Tests:
>  * Fedora25/x86_64 + GCC trunk : Configure/Build: SUCCESS
>    - build remade by means of gmake.
>    - some test redone in libgo (gmake check)
>  * AIX + GCC 7.1.0 :
>    - build remade by means of gmake.
>    - some test redone in libgo (gmake check)
>
> ChangeLog:
>  * Makefile.am (AM_LDFLAGS & GOLINK): Changes for linking on AIX.
>  * Makefile.in: Rebuild.

If this is trying to fix AIX search paths, a better solution would
seem to be the equivalent of -static-libstdc++ -static-libgcc.  The Go
tools should be linked statically and not depend on Go shared
libraries.

Thanks, David
Ian Lance Taylor July 26, 2017, 6:06 p.m. UTC | #2
On Wed, Jul 26, 2017 at 9:58 AM, David Edelsohn <dje.gcc@gmail.com> wrote:
> On Wed, Jul 26, 2017 at 12:41 PM, REIX, Tony <tony.reix@atos.net> wrote:
>> Description:
>>  * This patch adds linker options for gotools for AIX.
>>
>> Tests:
>>  * Fedora25/x86_64 + GCC trunk : Configure/Build: SUCCESS
>>    - build remade by means of gmake.
>>    - some test redone in libgo (gmake check)
>>  * AIX + GCC 7.1.0 :
>>    - build remade by means of gmake.
>>    - some test redone in libgo (gmake check)
>>
>> ChangeLog:
>>  * Makefile.am (AM_LDFLAGS & GOLINK): Changes for linking on AIX.
>>  * Makefile.in: Rebuild.
>
> If this is trying to fix AIX search paths, a better solution would
> seem to be the equivalent of -static-libstdc++ -static-libgcc.  The Go
> tools should be linked statically and not depend on Go shared
> libraries.

On GNU/Linux I used to use -static-libgo, but I changed it because of
https://gcc.gnu.org/PR64738.  Of course on AIX we can do as you
prefer.

Ian
REIX, Tony July 27, 2017, 3:51 p.m. UTC | #3
Hi Ian, David,

On AIX, that is more complicated...

We have to use -static-libgo when building the libgo tests. Because AIX does not work like Linux does and because the Go libgo tests are done by duplicating several .go files of libgo packages that already appear in the libgo.a (libgo.so) library.
On AIX, without -static-libgo, when building/running the libgo tests, we have Go variables defined somewhere and used elsewhere, BUT with different memory addresses... leading to bad issues...

However, when building/linking real Go application code outside of Gcc Go compiler, and thus with NO 2-times compiled libgo internal code, we have another issue and we need to load libgo.a at first, otherwise we have other issues.

In short, this patch is the first step of a global fix we have found for AIX for covering the 2 cases: build/run libgo internal tests, and build real NO-libgo internal customer code. And it works fine.
I'll provide the second step later.


Cordialement,

Tony Reix

Bull - ATOS
IBM Coop Architect & Technical Leader
Office : +33 (0) 4 76 29 72 67
1 rue de Provence - 38432 Échirolles - France
www.atos.net
David Edelsohn July 28, 2017, 1:18 p.m. UTC | #4
On Thu, Jul 27, 2017 at 11:51 AM, REIX, Tony <tony.reix@atos.net> wrote:
> Hi Ian, David,
>
> On AIX, that is more complicated...
>
> We have to use -static-libgo when building the libgo tests. Because AIX does not work like Linux does and because the Go libgo tests are done by duplicating several .go files of libgo packages that already appear in the libgo.a (libgo.so) library.
> On AIX, without -static-libgo, when building/running the libgo tests, we have Go variables defined somewhere and used elsewhere, BUT with different memory addresses... leading to bad issues...
>
> However, when building/linking real Go application code outside of Gcc Go compiler, and thus with NO 2-times compiled libgo internal code, we have another issue and we need to load libgo.a at first, otherwise we have other issues.
>
> In short, this patch is the first step of a global fix we have found for AIX for covering the 2 cases: build/run libgo internal tests, and build real NO-libgo internal customer code. And it works fine.
> I'll provide the second step later.

My concern is that the patch explicitly inserts the build directory
into the search path for the tools.  GCC already is fairly screwed up
with respect to the search path without explicitly making it worse.
Ideally, the libpath should be the install directory, not the build
directory.

If I understand your reply, this is a hack to allow the testsuite to
run in the build tree.

Thanks, David
diff mbox

Patch

Index: gotools/ChangeLog
===================================================================
--- gotools/ChangeLog	(révision 250563)
+++ gotools/ChangeLog	(copie de travail)
@@ -1,3 +1,8 @@ 
+2017-07-26  Tony Reix  <tony.reix@atos.net>
+
+	* Makefile.am (AM_LDFLAGS & GOLINK): Changes for linking on AIX.
+	* Makefile.in: Rebuild.
+
 2017-07-15  Ian Lance Taylor  <iant@golang.org>
 
 	* Makefile.am (CHECK_ENV): Set GOROOT.
Index: gotools/Makefile.am
===================================================================
--- gotools/Makefile.am	(révision 250563)
+++ gotools/Makefile.am	(copie de travail)
@@ -40,7 +40,11 @@  GOCOMPILE = $(GOCOMPILER) $(GOCFLAGS)
 
 AM_GOCFLAGS = -I $(libgodir)
 AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs
-GOLINK = $(GOCOMPILER) $(GOCFLAGS) $(AM_GOCFLAGS) $(LDFLAGS) $(AM_LDFLAGS) -o $@
+ifeq ($(shell uname), AIX)
+    AM_LDFLAGS += -Wl,-blibpath:$(libdir):/usr/lib:/lib
+    GOLINK = LIBRARY_PATH=$(libgodir)/.libs
+endif
+GOLINK += $(GOCOMPILER) $(GOCFLAGS) $(AM_GOCFLAGS) $(LDFLAGS) $(AM_LDFLAGS) -o $@
 
 libgosrcdir = $(srcdir)/../libgo/go
 cmdsrcdir = $(libgosrcdir)/cmd
Index: gotools/Makefile.in
===================================================================
--- gotools/Makefile.in	(révision 250563)
+++ gotools/Makefile.in	(copie de travail)
@@ -260,7 +260,11 @@  LIBGODEP = $(libgodir)/libgo.la
 GOCOMPILE = $(GOCOMPILER) $(GOCFLAGS)
 AM_GOCFLAGS = -I $(libgodir)
 AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs
-GOLINK = $(GOCOMPILER) $(GOCFLAGS) $(AM_GOCFLAGS) $(LDFLAGS) $(AM_LDFLAGS) -o $@
+ifeq ($(shell uname), AIX)
+    AM_LDFLAGS += -Wl,-blibpath:$(libdir):/usr/lib:/lib
+    GOLINK = LIBRARY_PATH=$(libgodir)/.libs
+endif
+GOLINK += $(GOCOMPILER) $(GOCFLAGS) $(AM_GOCFLAGS) $(LDFLAGS) $(AM_LDFLAGS) -o $@
 libgosrcdir = $(srcdir)/../libgo/go
 cmdsrcdir = $(libgosrcdir)/cmd
 libgomiscdir = $(srcdir)/../libgo/misc