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 <michael.haubenwall...@ssi-schaefer.com> 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 <michael.haubenwall...@ssi-schaefer.com> 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 to accept both, or the OBJECT_MODE=64 environment variable to switch to 64 bit only. We rely on the new gl_AIX_OBJECT_MODE early gnulib macro to set gl_cv_aix_object_mode and use the -X32_64 flag to search for various tools. * gnulib: Bump, for gl_AIX_OBJECT_MODE macro. * m4/libtool.m4 (_LT_PROG_AR): Use -X32_64 upon gl_cv_aix_object_mode. (LT_PATH_NM): Ditto. (_LT_CMD_OLD_ARCHIVE): Ditto for strip, ranlib. (LT_PATH_LD): Use -b flag for non-GNU ld upon gl_cv_aix_object_mode. --- gnulib | 2 +- m4/libtool.m4 | 30 +++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/gnulib b/gnulib index 5be7728..382a70e 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit 5be7728cf7c0fb61be1ccbfbd302764ef7e6b72d +Subproject commit 382a70efd75241ea495737faeffc32b09f75de31 diff --git a/m4/libtool.m4 b/m4/libtool.m4 index ee292af..28ccb3f 100644 --- a/m4/libtool.m4 +++ b/m4/libtool.m4 @@ -1491,7 +1491,11 @@ need_locks=$enable_libtool_lock # _LT_PROG_AR # ----------- m4_defun([_LT_PROG_AR], -[AC_CHECK_TOOLS(AR, [ar], false) +[if test no != "$gl_cv_aix_object_mode"; then + AC_CHECK_TOOLS(AR, ["ar -X32_64"], false) +else + AC_CHECK_TOOLS(AR, [ar], false) +fi : ${AR=ar} _LT_DECL([], [AR], [1], [The archiver]) @@ -1543,11 +1547,19 @@ _LT_DECL([], [archiver_list_spec], [1], m4_defun([_LT_CMD_OLD_ARCHIVE], [_LT_PROG_AR -AC_CHECK_TOOL(STRIP, strip, :) +if test no != "$gl_cv_aix_object_mode"; then + AC_CHECK_TOOL(STRIP, strip -X32_64, :) +else + AC_CHECK_TOOL(STRIP, strip, :) +fi test -z "$STRIP" && STRIP=: _LT_DECL([], [STRIP], [1], [A symbol stripping program]) -AC_CHECK_TOOL(RANLIB, ranlib, :) +if test no != "$gl_cv_aix_object_mode"; then + AC_CHECK_TOOL(RANLIB, ranlib -X32_64, :) +else + AC_CHECK_TOOL(RANLIB, ranlib, :) +fi test -z "$RANLIB" && RANLIB=: _LT_DECL([], [RANLIB], [1], [Commands used to install an old-style archive]) @@ -3331,6 +3343,9 @@ AC_CACHE_VAL(lt_cv_path_LD, fi done IFS=$lt_save_ifs + if test no = $with_gnu_ld && no != "$gl_cv_aix_object_mode"; then + lt_cv_path_LD="$lt_cv_path_LD -b$gl_cv_aix_object_mode" + fi else lt_cv_path_LD=$LD # Let the user override the test with a path. fi]) @@ -3701,13 +3716,18 @@ else # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty + # AIX nm needs -X32_64 to accept both 32 and 64 bit objects + tmp_nmflags=-B + if test no != "$gl_cv_aix_object_mode"; then + tmp_nmflags='-X32_64 -B' + fi case $build_os in mingw*) lt_bad_file=conftest.nm/nofile ;; *) lt_bad_file=/dev/null ;; esac - case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in + case `"$tmp_nm" $tmp_nmflags $lt_bad_file 2>&1 | sed '1q'` in *$lt_bad_file* | *'Invalid file or object type'*) - lt_cv_path_NM="$tmp_nm -B" + lt_cv_path_NM="$tmp_nm $tmp_nmflags" break 2 ;; *) -- 2.4.6