Creating 64-bit AIX executable is not quite as straight forward as in other platforms if you are using Autotools' Libtool. Actually, even if you don't use Autotools' Libtool, it would still be not really as straightforward as in other platform supported by GNU Autotools. I'm not going to present an example code that runs on AIX as 64-bit executable in this post. However, I'll show you how to build such program with the correct build script, with the assumption that you are using GNU Autotools.
- The first thing to know is: AIX is not trivial with respect to Autotools (see: Libtool Platform-specific configuration notes).
- The second thing is: You should never pass compiler-specific flags (e.g. -g, -O2 ) via your Autotools "build system" files, such as Makefile.am, configure.ac, etc. It's against Autotools philosophy. See: The importance of reading autoconf and automake manual.
#!/bin/sh ## NOTE: ## ----- ## - Passing native linker flag via LDFLAGS worked as documented in libtool (as shown below). ## ## - For more info on native AIX ar archiver, see: ## https://www-01.ibm.com/support/knowledgecenter/ssw_aix_53/com.ibm.aix.cmds/doc/aixcmds1/ar.htm?lang=en ## ## - For more info on native AIX linker, see: ## https://www-01.ibm.com/support/knowledgecenter/ssw_aix_53/com.ibm.aix.cmds/doc/aixcmds3/ld.htm?lang=en ## case "$1" in AIX) ./configure CFLAGS="-DDEBUG -fstrict-aliasing -Wstrict-aliasing=2 -g -O0 -maix64" \ LDFLAGS="-Wl,-b64" AR='ar -X32_64' && make V=1 ;; ###... esac
Mind you that I'm using libtool in the autotools project that uses the build script above. As you see, you need to pass the correct flags to the compiler (I'm using GCC on AIX), the linker and tools invoked by libtool (if you're using libtool). The -Wl flag is a libtool flag used for passing flags directly to the underlying linker. In this particular case, the linker is AIX native linker (see: AIX ld Command). The next thing to pay attention to is the ar archiver is AIX native archiver. This archiver only supports 32-bit object file by default. Therefore, you must explicitly override ar setting to force it to switch to support 64-bit object code, as shown above. See AIX ar command for more details on the archiver.
The release version of the build script is not that different from the debug version. I think you could figure it out already.
Hopefully this helps those working with Autotools projects in AIX.