libtool-patches
[Top][All Lists]
Advanced

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

[PATCH 4/4] Add $pic_flag to archive_cmds and archive_expsym_cmds.


From: Ralf Wildenhues
Subject: [PATCH 4/4] Add $pic_flag to archive_cmds and archive_expsym_cmds.
Date: Sun, 4 Apr 2010 10:57:04 +0200
User-agent: Mutt/1.5.20 (2009-10-28)

* libltdl/m4/libtool.m4 (_LT_LINKER_SHLIBS)
<archive_cmds, archive_expsym_cmds>
[GNU ld, netbsd]: Add $pic_flag if ELF.
[GNU ld, solaris]: Likewise.
[GNU ld, default case]: Likewise.
[!GNU ld, freebsd, dragonfly]: Add $pic_flag.
[!GNU ld, GCC, hpux9]: Add $pic_flag.
[!GNU ld, GCC, hpux10]: Replace -fPIC with $pic_flag
[!GNU ld, GCC, hpux11, !hppa*64]: Replace -fPIC with $pic_flag.
[!GNU ld, GCC, irix5, irix6, nonstopux]: Add $pic_flag.
[!GNU ld, GCC, osf4, osf5]: Likewise.
[!GNU ld, GCC, solaris]: Likewise.
(_LT_LANG_CXX_CONFIG) <archive_cmds, archive_expsym_cmds>
[hpux9]: Add $pic_flag if $GXX.
[hpux10, hpux11, !hppa*64]: Replace -fPIC with $pic_flag.
[irix5, irix6]: Add $pic_flag if $GXX.
[osf4, osf5]: Likewise.
[solaris]: Add $pic_flag if $GXX and not GCC 2.7.

Signed-off-by: Ralf Wildenhues <address@hidden>
---

Hello,

This untested patch cleans up a number of hard-coded -fPIC
entries in archive_cmds and archive_expsym_cmds settings,
and adds $pic_flag to all that use GCC on ELF systems.
However, the patch may also change the link command lines
for some non-GCC compilers as well.  It needs testing.


In _LT_LANG_CXX_CONFIG, hpux10|hpux11, GXX, hppa*64* case,
the -fPIC there is probably bogus and can be removed, but
that can be another patch (and I haven't tested that either.)

Thanks,
Ralf

 ChangeLog             |   20 ++++++++++++++++++++
 libltdl/m4/libtool.m4 |   48 ++++++++++++++++++++++++------------------------
 2 files changed, 44 insertions(+), 24 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 245452b..b7918e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,25 @@
 2010-04-04  Ralf Wildenhues  <address@hidden>
 
+       Add $pic_flag to archive_cmds and archive_expsym_cmds.
+       * libltdl/m4/libtool.m4 (_LT_LINKER_SHLIBS)
+       <archive_cmds, archive_expsym_cmds>
+       [GNU ld, netbsd]: Add $pic_flag if ELF.
+       [GNU ld, solaris]: Likewise.
+       [GNU ld, default case]: Likewise.
+       [!GNU ld, freebsd, dragonfly]: Add $pic_flag.
+       [!GNU ld, GCC, hpux9]: Add $pic_flag.
+       [!GNU ld, GCC, hpux10]: Replace -fPIC with $pic_flag
+       [!GNU ld, GCC, hpux11, !hppa*64]: Replace -fPIC with $pic_flag.
+       [!GNU ld, GCC, irix5, irix6, nonstopux]: Add $pic_flag.
+       [!GNU ld, GCC, osf4, osf5]: Likewise.
+       [!GNU ld, GCC, solaris]: Likewise.
+       (_LT_LANG_CXX_CONFIG) <archive_cmds, archive_expsym_cmds>
+       [hpux9]: Add $pic_flag if $GXX.
+       [hpux10, hpux11, !hppa*64]: Replace -fPIC with $pic_flag.
+       [irix5, irix6]: Add $pic_flag if $GXX.
+       [osf4, osf5]: Likewise.
+       [solaris]: Add $pic_flag if $GXX and not GCC 2.7.
+
        Uniform const'ness of symlist variable lt_preloaded_symbols.
        On some systems, lt_preloaded_symbols may not be declared
        const due to relocation issues.  C99 requires qualification to
diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4
index ef587b9..da976ba 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -4534,8 +4534,8 @@ _LT_EOF
        _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs 
$linker_flags -o $lib'
        wlarc=
       else
-       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs 
$compiler_flags ${wl}-soname $wl$soname -o $lib'
-       _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs 
$compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file 
$wl$export_symbols -o $lib'
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs 
$compiler_flags ${wl}-soname $wl$soname -o $lib'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs 
$deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file 
$wl$export_symbols -o $lib'
       fi
       ;;
 
@@ -4553,8 +4553,8 @@ _LT_EOF
 
 _LT_EOF
       elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; 
then
-       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs 
$compiler_flags ${wl}-soname $wl$soname -o $lib'
-       _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs 
$compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file 
$wl$export_symbols -o $lib'
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs 
$compiler_flags ${wl}-soname $wl$soname -o $lib'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs 
$deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file 
$wl$export_symbols -o $lib'
       else
        _LT_TAGVAR(ld_shlibs, $1)=no
       fi
@@ -4600,8 +4600,8 @@ _LT_EOF
 
     *)
       if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs 
$compiler_flags ${wl}-soname $wl$soname -o $lib'
-       _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs 
$compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file 
$wl$export_symbols -o $lib'
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs 
$compiler_flags ${wl}-soname $wl$soname -o $lib'
+       _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs 
$deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file 
$wl$export_symbols -o $lib'
       else
        _LT_TAGVAR(ld_shlibs, $1)=no
       fi
@@ -4837,7 +4837,7 @@ _LT_EOF
 
     # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
     freebsd* | dragonfly*)
-      _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs 
$compiler_flags'
+      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs 
$deplibs $compiler_flags'
       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
       _LT_TAGVAR(hardcode_direct, $1)=yes
       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
@@ -4845,7 +4845,7 @@ _LT_EOF
 
     hpux9*)
       if test "$GCC" = yes; then
-       _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared 
-fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs 
$compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname 
$lib'
+       _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared 
$pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs 
$deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv 
$output_objdir/$soname $lib'
       else
        _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b 
$install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test 
$output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
       fi
@@ -4861,7 +4861,7 @@ _LT_EOF
 
     hpux10*)
       if test "$GCC" = yes && test "$with_gnu_ld" = no; then
-       _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname 
${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h 
${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs 
$compiler_flags'
       else
        _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o 
$lib $libobjs $deplibs $linker_flags'
       fi
@@ -4885,10 +4885,10 @@ _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 -fPIC ${wl}+h ${wl}$soname 
${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+         _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${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'
+         _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h 
${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs 
$compiler_flags'
          ;;
        esac
       else
@@ -4935,14 +4935,14 @@ _LT_EOF
 
     irix5* | irix6* | nonstopux*)
       if test "$GCC" = yes; then
-       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs 
$compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && 
func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry 
${wl}${output_objdir}/so_locations -o $lib'
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs 
$compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && 
func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry 
${wl}${output_objdir}/so_locations -o $lib'
        # Try to use the -exported_symbol ld option, if it does not
        # work, assume that -exports_file does not work either and
        # implicitly export all symbols.
         save_LDFLAGS="$LDFLAGS"
         LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo 
${wl}-update_registry ${wl}/dev/null"
         AC_LINK_IFELSE(int foo(void) {},
-          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs 
$compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && 
func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry 
${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o 
$lib'
+          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs 
$deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && 
func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry 
${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o 
$lib'
         )
         LDFLAGS="$save_LDFLAGS"
       else
@@ -5029,7 +5029,7 @@ _LT_EOF
     osf4* | osf5*)     # as osf3* with the addition of -msym flag
       if test "$GCC" = yes; then
        _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
-       _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} 
$libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n 
"$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` 
${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} 
$pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname 
${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version 
${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o 
$lib'
        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
       else
        _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
@@ -5048,9 +5048,9 @@ _LT_EOF
       _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
       if test "$GCC" = yes; then
        wlarc='${wl}'
-       _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h 
${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text 
${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat 
$export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> 
$lib.exp~
-         $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h 
${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+         $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h 
${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
       else
        case `$CC -V 2>&1` in
        *"Compilers 5.0"*)
@@ -5827,7 +5827,7 @@ if test "$_lt_caught_CXX_error" != yes; then
             ;;
           *)
             if test "$GXX" = yes; then
-              _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC 
-shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname 
$predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test 
$output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+              _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC 
-shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o 
$output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects 
$compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname 
$lib'
             else
               # FIXME: insert proper C++ library support
               _LT_TAGVAR(ld_shlibs, $1)=no
@@ -5898,10 +5898,10 @@ if test "$_lt_caught_CXX_error" != yes; then
                    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC 
${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects 
$compiler_flags'
                    ;;
                  ia64*)
-                   _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC 
${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs 
$deplibs $postdep_objects $compiler_flags'
+                   _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib 
$pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects 
$libobjs $deplibs $postdep_objects $compiler_flags'
                    ;;
                  *)
-                   _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC 
${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects 
$libobjs $deplibs $postdep_objects $compiler_flags'
+                   _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib 
$pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib 
$predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
                    ;;
                esac
              fi
@@ -5942,9 +5942,9 @@ if test "$_lt_caught_CXX_error" != yes; then
           *)
            if test "$GXX" = yes; then
              if test "$with_gnu_ld" = no; then
-               _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib 
$predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname 
${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version 
${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o 
$lib'
+               _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib 
$predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname 
${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version 
${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o 
$lib'
              else
-               _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib 
$predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname 
${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version 
${wl}$verstring"` -o $lib'
+               _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib 
$predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname 
${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version 
${wl}$verstring"` -o $lib'
              fi
            fi
            _LT_TAGVAR(link_all_deplibs, $1)=yes
@@ -6222,7 +6222,7 @@ if test "$_lt_caught_CXX_error" != yes; then
                  _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib 
${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects 
$compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && 
func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry 
${wl}${output_objdir}/so_locations -o $lib'
                  ;;
                *)
-                 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib 
${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects 
$compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && 
func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry 
${wl}${output_objdir}/so_locations -o $lib'
+                 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib 
${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects 
$compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && 
func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry 
${wl}${output_objdir}/so_locations -o $lib'
                  ;;
              esac
 
@@ -6309,9 +6309,9 @@ if test "$_lt_caught_CXX_error" != yes; then
            if test "$GXX" = yes && test "$with_gnu_ld" = no; then
              _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
              if $CC --version | $GREP -v '^2\.7' > /dev/null; then
-               _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS 
$predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h 
$wl$soname -o $lib'
+               _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib 
$LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags 
${wl}-h $wl$soname -o $lib'
                _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > 
$lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: 
*; };" >> $lib.exp~
-                 $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib 
$predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+                 $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib 
$predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
                # Commands to make compiler produce verbose output that lists
                # what "hidden" libraries, object files and flags are used when
-- 
1.7.0.rc1.161.g90487





reply via email to

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