Re: [PATCH 2/4] AIX: Do not rely on OBJECT_MODE env var being set.

2016-03-15 Thread Michael Haubenwallner

On 03/10/2016 10:01 AM, Michael Haubenwallner wrote:
> To compile 64-bit, AIX toolchain provides support to set the environment
> variable OBJECT_MODE=64, to avoid the need for changing anything else in
> the build environment. However, gcc ignores OBJECT_MODE, and does not
> set it while building gcc itself during its multi-lib build either.
> Also, CC may be some wrapper to operate in 64-bit mode. So we cannot
> rely on OBJECT_MODE being set to properly support 64-bit builds.
> 
> Instead, we better identify the object mode in use by looking at the
> file type of an object file generated by CC, to properly set the
> commandline flags for additional tools used within libtool. While there
> is similar code for LD in _LT_ENABLE_LOCK, this is too late for NM.
> 
> * m4/libtool.m4 (_LT_CACHE_CHECK_OBJECT_FILE_TYPE): New. Provides object
> file type identified using /usr/bin/file.
> (_LT_PREPARE_TOOLS_ABI_FLAGS): New. Defines func_set_tool_abi_flag.
> Define AIX specific ABI flags for LD, AR, NM, STRIP, RANLIB.
> Set AIX_OBJECT_MODE as well.
> (_LT_SET_TOOL_ABI_FLAG): New. Uses func_set_tool_abi_flag to set host
> specific ABI flags into tool commands.
> (_LT_PROG_AR): Use _LT_SET_TOOL_ABI_FLAG.
> (LT_PATH_LD): Ditto.
> (LT_PATH_NM): Ditto.
> (_LT_CMD_OLD_ARCHIVE): Use _LT_SET_TOOL_ABI_FLAG for STRIP, RANLIB.
> (_LT_LINKER_SHLIBS): Use AIX_OBJECT_MODE.
> (_LT_LANG_CXX_CONFIG): Ditto.
> * m4/ltoptions.m4 (_LT_WITH_AIX_SONAME): Ditto.

Unfortunately, this patch does not work as expected (as in not requiring
OBJECT_MODE=64 environment variable being set for 64 bits any more), as
gnulib does early run AM_PROG_AR. Unsure if I fooled my tests last year,
or something else has changed since.

Anyway: I'm proposing these two simpler patches now, one as gnulib patch,
which the libtool patch depends on.

Thoughts?

Thanks!
/haubi/
>From 382a70efd75241ea495737faeffc32b09f75de31 Mon Sep 17 00:00:00 2001
From: Michael Haubenwallner 
Date: Tue, 15 Mar 2016 15:50:39 +0100
Subject: [PATCH] early detect AIX object mode for toolchain search

AIX tools do accept only 32 bit objects by default. They either need
the -X32_64 commandline flag to accept both, or the OBJECT_MODE=64
environment variable to switch to accepting 64 bit objects only, while
the GNU toolchain ignores both the -X32_64 flag and the environment
variable. As this affects the whole toolchain, we separately set the
gl_cv_aix_object_mode configure variable.
* m4/gnulib-common.m4 (gl_AIX_OBJECT_MODE): New.
(gl_PROG_AR_RANLIB): AC_REQUIRE gl_AIX_OBJECT_MODE. Search for AR and
RANLIB accepting the -X32_64 when gl_cv_aix_object_mode != no.
---
 m4/gnulib-common.m4 | 33 +
 1 file changed, 33 insertions(+)

diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index f8454c8..a3a691f 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -245,6 +245,33 @@ AC_DEFUN([gl_PROG_CC_C99],
 [AC_REQUIRE([AC_PROG_CC_STDC])])
 ])
 
+# gl_AIX_OBJECT_MODE
+# Determines the current object mode used by the compiler for AIX.
+AC_DEFUN([gl_AIX_OBJECT_MODE],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_CACHE_CHECK([for AIX object mode], [gl_cv_aix_object_mode],
+[
+  AC_EGREP_CPP([OBJECT_MODE=64],
+	[
+#if defined(_AIX) && defined(__64BIT__)
+OBJECT_MODE=64
+#endif
+	],
+	[gl_cv_aix_object_mode=64],
+	[
+	  AC_EGREP_CPP([OBJECT_MODE=32],
+	[
+#if defined(_AIX) && !defined(__64BIT__)
+OBJECT_MODE=32
+#endif
+	],
+	[gl_cv_aix_object_mode=32],
+	[gl_cv_aix_object_mode=no])
+	])
+])
+])
+
 # gl_PROG_AR_RANLIB
 # Determines the values for AR, ARFLAGS, RANLIB that fit with the compiler.
 # The user can set the variables AR, ARFLAGS, RANLIB if he wants to override
@@ -256,6 +283,7 @@ AC_DEFUN([gl_PROG_AR_RANLIB],
   dnl library formats. In particular, the GNU binutils programs ar and ranlib
   dnl produce libraries that work only with gcc, not with cc.
   AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([gl_AIX_OBJECT_MODE])
   AC_BEFORE([$0], [AM_PROG_AR])
   AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler],
 [
@@ -279,6 +307,11 @@ Amsterdam
   ARFLAGS='-o'
 fi
   else
+if test $gl_cv_aix_object_mode != no; then
+  dnl AIX toolchain does accept 32 bit objects by default only.
+  AC_CHECK_TOOL([AR], [ar -X32_64], [ar])
+  AC_CHECK_TOOL([RANLIB], [ranlib -X32_64], [ranlib])
+fi
 dnl AM_PROG_AR was added in automake v1.11.2.  AM_PROG_AR does not AC_SUBST
 dnl ARFLAGS variable (it is filed into Makefile.in directly by automake
 dnl script on-demand, if not specified by ./configure of course).
-- 
2.4.6

>From 40813812c4e721bf02e9d65e589238ed559991f6 Mon Sep 17 00:00:00 2001
From: Michael Haubenwallner 
Date: Tue, 15 Mar 2016 16:10:41 +0100
Subject: [PATCH] AIX: use -X32_64 flag in search for toolchain

The AIX toolchain does accept only 32 bit objects by default. They
either need the -X32_64 flag 

[PATCH] bump gl-mod/bootstrap for AIX sed

2016-03-15 Thread Michael Haubenwallner
gl-mod/bootstrap: Update.
bootstrap: Recreate.
---
 bootstrap| 10 +-
 gl-mod/bootstrap |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/bootstrap b/bootstrap
index 82b28d7..d1f54d3 100755
--- a/bootstrap
+++ b/bootstrap
@@ -2302,20 +2302,20 @@ func_version ()
 /^# Written by /!b
 s|^# ||; p; n
 
-:fwd2blank
+:fwd2blnk
 /./ {
   n
-  b fwd2blank
+  b fwd2blnk
 }
 p; n
 
-:holdwarranty
+:holdwrnt
 s|^# ||
 s|^# *$||
-/^Copyright /! {
+/^Copyright /!{
   /./H
   n
-  b holdwarranty
+  b holdwrnt
 }
 
 s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
diff --git a/gl-mod/bootstrap b/gl-mod/bootstrap
index eabfd9c..3395ec0 16
--- a/gl-mod/bootstrap
+++ b/gl-mod/bootstrap
@@ -1 +1 @@
-Subproject commit eabfd9c429f02d36695529a96ee2247c9bd2ca4e
+Subproject commit 3395ec04c42ab16ccbee05941f5b6ccee5907fdc
-- 
2.4.6