libtool-patches
[Top][All Lists]
Advanced

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

Patch for IA64 HP-UX PIC mode compilation


From: sje
Subject: Patch for IA64 HP-UX PIC mode compilation
Date: Wed, 06 Aug 2008 11:01:40 -0700

I would like to modify libtool to specify the -fPIC flag when using GCC
to compile code for shared libraries on the IA64 HP-UX platform.

GCC does generate PIC code by default on IA64 HP-UX but it also does
a couple of other things differently based on whether or not the PIC
flag is given.  Specifically, it uses a different default thread local
storage model based on whether or not the PIC flag is given and also
the optimizer turns off some inlining when the PIC flag is seen.

While working on GCC I found that the shared libgomp (which uses TLS)
would not work if the objects were not compiled with -fPIC (or -fpic)
because it was using a TLS model that didn't work in shared libraries.

I did consider changing GCC to do both of these things in the PIC way
by default (regardless of the pic flag setting) but that would slow down
non-PIC code unecessarily so it seems better to have libtool set the PIC
flag when building code for shared libraries.  The HP compiler does not
behave in the same way as GCC so we do not need to use the PIC flag (+Z)
when using the HP compiler.

I tested with the libtool testsuite and by building GCC with the modified
libtool.m4.  Could someone approve this and check it in for me if it
looks OK?

Steve Ellcey
address@hidden


2008-08-06  Steve Ellcey  <address@hidden>

        * libltdl/m4/libtool.m4 (ia64): Specify -fPIC when
        using GCC to build shared libraries.


diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4
index d4891ca..7f59698 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -3602,10 +3602,11 @@ m4_if([$1], [CXX], [
       fi
       ;;
     hpux*)
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
+      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
+      # sets the default TLS model and affects inlining.
       case $host_cpu in
-      hppa*64*|ia64*)
+      hppa*64*)
        ;;
       *)
        _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
@@ -3897,10 +3898,11 @@ m4_if([$1], [CXX], [
       ;;
 
     hpux*)
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
+      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
+      # sets the default TLS model and affects inlining.
       case $host_cpu in
-      hppa*64*|ia64*)
+      hppa*64*)
        # +Z the default
        ;;
       *)
@@ -4769,7 +4771,7 @@ _LT_EOF
          _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o 
$lib $libobjs $deplibs $compiler_flags'
          ;;
        ia64*)
-         _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname 
${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+         _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname 
${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
          ;;
        *)
          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname 
${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'




reply via email to

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