libgo: correctly handle AIX FAT library creation
authorClément Chigot <clement.chigot@atos.net>
Fri, 7 Aug 2020 12:45:34 +0000 (14:45 +0200)
committerIan Lance Taylor <iant@golang.org>
Wed, 12 Aug 2020 18:33:54 +0000 (11:33 -0700)
The previous patch wasn't working everytime. Especially when AR had
"-X32_64", the new .so would replace the default one and not just being
added.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/247377

gcc/go/gofrontend/MERGE
libgo/Makefile.am
libgo/Makefile.in
libgo/configure
libgo/configure.ac
libgo/testsuite/Makefile.in

index 08daa1a..e443282 100644 (file)
@@ -1,4 +1,4 @@
-e08f1d7d1bc14c0a29eb9ee17980f14fa2397239
+fe5d94c5792f7f990004c3dee0ea501835512200
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 88ea272..1112ee2 100644 (file)
@@ -1244,8 +1244,15 @@ endif
 all-local: $(ALL_LOCAL_DEPS)
 
 MAJOR=$(firstword $(subst :, ,$(libtool_VERSION)))
 all-local: $(ALL_LOCAL_DEPS)
 
 MAJOR=$(firstword $(subst :, ,$(libtool_VERSION)))
+
+# If we want to use "AR -r" when creating AIX FAT archives,
+# AR must be stripped of all its -X flags.
+# Otherwize, if AR was defined with -X32_64, the replace option would
+# erase the default .so when adding the extra one. There is no
+# order priority within -X flags.
 add-aix-fat-library: all-multi
        @if test "$(MULTIBUILDTOP)" = ""; then \
 add-aix-fat-library: all-multi
        @if test "$(MULTIBUILDTOP)" = ""; then \
-         ${AR} -X$(AIX_DEFAULT_ARCH) rc .libs/$(PACKAGE).a ../ppc$(AIX_DEFAULT_ARCH)/$(PACKAGE)/.libs/$(PACKAGE).so.$(MAJOR); \
-         ${AR} -X$(AIX_DEFAULT_ARCH) rc ../pthread/$(PACKAGE)/.libs/$(PACKAGE).a ../pthread/ppc$(AIX_DEFAULT_ARCH)/$(PACKAGE)/.libs/$(PACKAGE).so.$(MAJOR); \
+         arx=`echo $(AR) | sed -e 's/-X[^ ]*//g'`; \
+         $${arx} -X$(AIX_EXTRA_ARCH) rc .libs/$(PACKAGE).a ../ppc$(AIX_EXTRA_ARCH)/$(PACKAGE)/.libs/$(PACKAGE).so.$(MAJOR); \
+         $${arx} -X$(AIX_EXTRA_ARCH) rc ../pthread/$(PACKAGE)/.libs/$(PACKAGE).a ../pthread/ppc$(AIX_EXTRA_ARCH)/$(PACKAGE)/.libs/$(PACKAGE).so.$(MAJOR); \
        fi
        fi
index 4aa9e98..1fb8da6 100644 (file)
@@ -380,7 +380,7 @@ CTAGS = ctags
 CSCOPE = cscope
 DIST_SUBDIRS = testsuite
 ACLOCAL = @ACLOCAL@
 CSCOPE = cscope
 DIST_SUBDIRS = testsuite
 ACLOCAL = @ACLOCAL@
-AIX_DEFAULT_ARCH = @AIX_DEFAULT_ARCH@
+AIX_EXTRA_ARCH = @AIX_EXTRA_ARCH@
 ALLGOARCH = @ALLGOARCH@
 ALLGOARCHFAMILY = @ALLGOARCHFAMILY@
 ALLGOOS = @ALLGOOS@
 ALLGOARCH = @ALLGOARCH@
 ALLGOARCHFAMILY = @ALLGOARCHFAMILY@
 ALLGOOS = @ALLGOOS@
@@ -3118,10 +3118,17 @@ clean-local: clean-multi
 distclean-local: distclean-multi
 maintainer-clean-local: maintainer-clean-multi
 all-local: $(ALL_LOCAL_DEPS)
 distclean-local: distclean-multi
 maintainer-clean-local: maintainer-clean-multi
 all-local: $(ALL_LOCAL_DEPS)
+
+# If we want to use "AR -r" when creating AIX FAT archives,
+# AR must be stripped of all its -X flags.
+# Otherwize, if AR was defined with -X32_64, the replace option would
+# erase the default .so when adding the extra one. There is no
+# order priority within -X flags.
 add-aix-fat-library: all-multi
        @if test "$(MULTIBUILDTOP)" = ""; then \
 add-aix-fat-library: all-multi
        @if test "$(MULTIBUILDTOP)" = ""; then \
-         ${AR} -X$(AIX_DEFAULT_ARCH) rc .libs/$(PACKAGE).a ../ppc$(AIX_DEFAULT_ARCH)/$(PACKAGE)/.libs/$(PACKAGE).so.$(MAJOR); \
-         ${AR} -X$(AIX_DEFAULT_ARCH) rc ../pthread/$(PACKAGE)/.libs/$(PACKAGE).a ../pthread/ppc$(AIX_DEFAULT_ARCH)/$(PACKAGE)/.libs/$(PACKAGE).so.$(MAJOR); \
+         arx=`echo $(AR) | sed -e 's/-X[^ ]*//g'`; \
+         $${arx} -X$(AIX_EXTRA_ARCH) rc .libs/$(PACKAGE).a ../ppc$(AIX_EXTRA_ARCH)/$(PACKAGE)/.libs/$(PACKAGE).so.$(MAJOR); \
+         $${arx} -X$(AIX_EXTRA_ARCH) rc ../pthread/$(PACKAGE)/.libs/$(PACKAGE).a ../pthread/ppc$(AIX_EXTRA_ARCH)/$(PACKAGE)/.libs/$(PACKAGE).so.$(MAJOR); \
        fi
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
        fi
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
index 74bf072..7be9571 100755 (executable)
@@ -733,7 +733,7 @@ SED
 MAINT
 MAINTAINER_MODE_FALSE
 MAINTAINER_MODE_TRUE
 MAINT
 MAINTAINER_MODE_FALSE
 MAINTAINER_MODE_TRUE
-AIX_DEFAULT_ARCH
+AIX_EXTRA_ARCH
 am__fastdepCCAS_FALSE
 am__fastdepCCAS_TRUE
 CCASDEPMODE
 am__fastdepCCAS_FALSE
 am__fastdepCCAS_TRUE
 CCASDEPMODE
@@ -4716,10 +4716,10 @@ case ${host} in
     GOCFLAGS="$GOCFLAGS -fno-section-anchors"
 
     # Check default architecture for FAT library creation
     GOCFLAGS="$GOCFLAGS -fno-section-anchors"
 
     # Check default architecture for FAT library creation
-    if test -z "`$(CC) -x c -E /dev/null -g3 -o - | grep 64BIT`" ; then
-        AIX_DEFAULT_ARCH='64'
+    if test -z "`$CC -x c -E /dev/null -g3 -o - | grep 64BIT`" ; then
+        AIX_EXTRA_ARCH='64'
     else
     else
-        AIX_DEFAULT_ARCH='32'
+        AIX_EXTRA_ARCH='32'
     fi
 
     ;;
     fi
 
     ;;
index db5848e..abc58b8 100644 (file)
@@ -38,12 +38,12 @@ case ${host} in
     GOCFLAGS="$GOCFLAGS -fno-section-anchors"
 
     # Check default architecture for FAT library creation
     GOCFLAGS="$GOCFLAGS -fno-section-anchors"
 
     # Check default architecture for FAT library creation
-    if test -z "`$(CC) -x c -E /dev/null -g3 -o - | grep 64BIT`" ; then
-        AIX_DEFAULT_ARCH='64'
+    if test -z "`$CC -x c -E /dev/null -g3 -o - | grep 64BIT`" ; then
+        AIX_EXTRA_ARCH='64'
     else
     else
-        AIX_DEFAULT_ARCH='32'
+        AIX_EXTRA_ARCH='32'
     fi
     fi
-    AC_SUBST(AIX_DEFAULT_ARCH)
+    AC_SUBST(AIX_EXTRA_ARCH)
     ;;
 esac
 
     ;;
 esac
 
index ae42fad..7869265 100644 (file)
@@ -131,7 +131,7 @@ am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
 DEJATOOL = $(PACKAGE)
 RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir
 ACLOCAL = @ACLOCAL@
 DEJATOOL = $(PACKAGE)
 RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir
 ACLOCAL = @ACLOCAL@
-AIX_DEFAULT_ARCH = @AIX_DEFAULT_ARCH@
+AIX_EXTRA_ARCH = @AIX_EXTRA_ARCH@
 ALLGOARCH = @ALLGOARCH@
 ALLGOARCHFAMILY = @ALLGOARCHFAMILY@
 ALLGOOS = @ALLGOOS@
 ALLGOARCH = @ALLGOARCH@
 ALLGOARCHFAMILY = @ALLGOARCHFAMILY@
 ALLGOOS = @ALLGOOS@