libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AIX PIC shared library support


From: David Edelsohn
Subject: AIX PIC shared library support
Date: Mon, 20 Aug 2012 13:12:59 -0400

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.

Comments?

Thanks, David

        * m4/libtool.m4 (_LT_COMPILER_PIC): Add -fPIC to GCC and GXX for AIX.

diff --git a/m4/libtool.m4 b/m4/libtool.m4
index a8ecbc3..d0a5577 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -3874,6 +3874,7 @@ m4_if([$1], [CXX], [
        # AIX 5 now supports IA64 processor
        _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       fi
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
       ;;

     amigaos*)
@@ -4191,6 +4192,7 @@ m4_if([$1], [CXX], [
        # AIX 5 now supports IA64 processor
        _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
       fi
+      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
       ;;

     amigaos*)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]