diff mbox

[LIBTOOL] AIX PIC compiler options

Message ID CAGWvnym5=2BAUnzQSJtapmiERp8SyW+CXknuBYe5RCUTpvq2PA@mail.gmail.com
State New
Headers show

Commit Message

David Edelsohn Aug. 20, 2012, 5:05 p.m. UTC
The GCC -fpic/-fPIC option has evolved to mean code generation for a
shared library and changes the optimization behavior of the compiler.
Code for AIX PowerPC always is PIC, but the optimization behavior is
affecting AIX.

libtool exports all global symbols on AIX while GCC binds_local_p()
determines that some function calls are local, causing GCC to emit the
local (non-external) form of function calls, which generates AIX
linker warnings.

The IBM XL compiler defaults to the equivalent of -fpic.  GCC could
try to match that, but it requires working around other GCC bootstrap
problems and continually chasing compatibility.  The other option is
to assume that developers using GCC to build shared libraries either
are using libtool or copying FOSS Makefiles designed for GNU/Linux or
expecting GNU/Linux compatibility.

The following patch starts to implement the latter by adding "-fPIC"
to the compiler command line options when building objects for a
shared library.  Because this places control in the hands of the user
with a command line option and matches GNU/Linux, this seems better
than playing with defaults and fighting GCC semantics for building
shared libraries.

I also will post this patch upstream to Libtool.

Comments?

Thanks, David

        * libtool.m4 (_LT_COMPILER_PIC): Add -fPIC to GCC and GXX for AIX.
        * configure: Regenerate.
diff mbox

Patch

Index: libtool.m4
===================================================================
--- libtool.m4  (revision 190521)
+++ libtool.m4  (working copy)
@@ -3580,6 +3580,7 @@ 
        # AIX 5 now supports IA64 processor
        _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       fi
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
       ;;

     amigaos*)
@@ -3891,6 +3892,7 @@ 
        # AIX 5 now supports IA64 processor
        _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       fi
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
       ;;

     amigaos*)