libtool
[Top][All Lists]
Advanced

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

Re: static/shared libraries on AIX


From: libtool
Subject: Re: static/shared libraries on AIX
Date: Thu, 26 Apr 2001 09:54:59 -0500
User-agent: Mutt/1.1.12i

On Thu, Apr 26, 2001 at 08:31:02AM -0500, address@hidden wrote:
> > From: address@hidden
> > 
> > Can we decide to:
> >   1. On AIX systems that support run-time-linking, make it the
> >      *default* so lib<name>.a is "static" and lib<name>.so is
> >      shared. With this, "-brtl" would be "inserted" automatically
> >      into the compile/link phases.
> 
> I'm not sure if this would work or not.  For run-time-linking to work on
> AIX the "program" must be linked with -brtl, and the shared libraries
> must link with -G (shared libs can be linked with -brtl and -G, but
> -G MUST follow the last -brtl flags).

Ok, with the attached patch:
  $ LDFLAGS="-brtl" CC=xlc ./configure
  $ LDFLAGS="-brtl" CC=xlc gmake MAKE=gmake check
passes all tests for MLB.

Dan and Robert, please review. The patch does the following:
  1. If using runtime-linking, created shared libraries with
     -G as the final option. Remove -bM:SRE if runtime-linking
     in effect and creating shared libraries.
  2. If using runtime-linking, create static libraries *only*
     under lib<name>.a and shared libraries *only* under
     lib<name>.so.
  3. Fix bug in allow_undefined_flag WRT evaluation of
     allow_undefined_flag.
  4. Rename lt_cv_prog_cc_static to ac_cv_prog_cc_static.
  5. Set ac_cv_prog_cc_wl='-Wl,' to fix bug in quote.test.
  6. Set soname_spec='${libname}${release}.so$major' to sync
     with 1.4.

-- 
albert chin (address@hidden)

-- snip snip
Index: ltcf-c.sh
===================================================================
RCS file: /home/cvs/libtool/Attic/ltcf-c.sh,v
retrieving revision 1.1.2.36
diff -u -3 -p -r1.1.2.36 ltcf-c.sh
--- ltcf-c.sh   2001/04/24 23:58:18     1.1.2.36
+++ ltcf-c.sh   2001/04/26 14:37:37
@@ -268,6 +268,27 @@ else
     ;;
 
   aix4* | aix5*)
+    if test "$host_cpu" = ia64; then
+      # On IA64, the linker does run time linking by default, so we don't
+      # have to do anything special.
+      aix_use_runtimelinking=no
+      exp_sym_flag='-Bexport'
+      no_entry_flag=""
+    else
+      # Test if we are trying to use run time linking, or normal AIX
+      # style linking. If -brtl is somewhere in LDFLAGS, we need to
+      # do run time linking.
+      aix_use_runtimelinking=no
+      for ld_flag in $LDFLAGS; do
+        if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl" ); then
+          aix_use_runtimelinking=yes
+          break
+        fi
+      done
+      exp_sym_flag='-bexport'
+      no_entry_flag='-bnoentry'
+    fi
+
     hardcode_direct=yes
     hardcode_libdir_separator=':'
     link_all_deplibs=yes
@@ -303,52 +324,37 @@ else
       if test "$host_cpu" = ia64; then
         shared_flag='${wl}-G'
       else
-        shared_flag='${wl}-bM:SRE'
+        if test "$aix_use_runtimelinking" = yes; then
+          shared_flag='${wl}-G'
+        else
+          shared_flag='${wl}-bM:SRE'
+        fi
       fi
     fi
 
-    if test "$host_cpu" = ia64; then
-      # On IA64, the linker does run time linking by default, so we don't
-      # have to do anything special.
-      aix_use_runtimelinking=no
-      exp_sym_flag='-Bexport'
-      no_entry_flag=""
-    else
-      # Test if we are trying to use run time linking, or normal AIX style 
linking.
-      # If -brtl is somewhere in LDFLAGS, we need to do run time linking.
-      aix_use_runtimelinking=no
-      for ld_flag in $LDFLAGS; do
-        if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl" ); then
-          aix_use_runtimelinking=yes
-          break
-        fi
-      done
-      exp_sym_flag='-bexport'
-      no_entry_flag='-bnoentry'
-    fi
     # -bexpall does not export symbols beginning with underscore (_)
     always_export_symbols=yes
     if test "$aix_use_runtimelinking" = yes; then
-      # Warning - without using the other run time loading flags (-brtl), 
-berok will
-      #           link without error, but may produce a broken library.
-      allow_undefined_flag=' ${wl}-berok'
+      # Warning - without using the other run time loading flags (-brtl),
+      # -berok will link without error, but may produce a broken library.
+      allow_undefined_flag='-berok'
       hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:/usr/lib:/lib'
-      archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname 
$libobjs $deplibs $compiler_flags ${allow_undefined_flag} 
'"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+      archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs 
$compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo 
"${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag 
\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
     else
       if test "$host_cpu" = ia64; then
         hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
         allow_undefined_flag="-z nodefs"
         archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname 
$libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} 
'"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
       else
-        allow_undefined_flag=' ${wl}-berok'
+        allow_undefined_flag='-berok'
         # -bexpall does not export symbols beginning with underscore (_)
         always_export_symbols=yes
         # Exported symbols can be pulled into shared objects from archives
         whole_archive_flag_spec=' '
         build_libtool_need_lc=yes
         hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:/usr/lib:/lib'
-        # This is similar to how AIX traditionally builds it's shared 
libraries.
-        archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname 
$libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols 
${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS 
$output_objdir/$libname$release.a $output_objdir/$soname'
+        # This is similar to how AIX traditionally builds it's shared libraries
+        archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname 
$libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry `if 
test "x${allow_undefined_flag}" != "x"; then echo 
"${wl}${allow_undefined_flag}"; else :; fi`~$AR $AR_FLAGS 
$output_objdir/$libname$release.a $output_objdir/$soname'
       fi
     fi
     ;;
@@ -619,13 +625,7 @@ else
 
     case $host_os in
     aix*)
-      # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
-        # AIX 5 now supports IA64 processor
-        lt_cv_prog_cc_static='-Bstatic'
-      else
-        lt_cv_prog_cc_static='-bnso -bI:/lib/syscalls.exp'
-      fi
+      ac_cv_prog_cc_static="$ac_cv_prog_cc_static ${ac_cv_prog_cc_wl}-lC"
       ;;
     amigaos*)
       # FIXME: we need at least 68020 code to build shared libraries, but
@@ -663,8 +663,14 @@ else
     # PORTME Check for PIC flags for the system compiler.
     case $host_os in
     aix*)
-     # All AIX code is PIC.
-      ac_cv_prog_cc_static="$ac_cv_prog_cc_static ${ac_cv_prog_cc_wl}-lC"
+      ac_cv_prog_cc_wl='-Wl,'
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+        # AIX 5 now supports IA64 processor
+        ac_cv_prog_cc_static='-Bstatic'
+      else
+        ac_cv_prog_cc_static='-bnso -bI:/lib/syscalls.exp'
+      fi
       ;;
 
     hpux9* | hpux10* | hpux11*)
Index: ltcf-cxx.sh
===================================================================
RCS file: /home/cvs/libtool/Attic/ltcf-cxx.sh,v
retrieving revision 1.1.2.42
diff -u -3 -p -r1.1.2.42 ltcf-cxx.sh
--- ltcf-cxx.sh 2001/04/24 21:35:12     1.1.2.42
+++ ltcf-cxx.sh 2001/04/26 14:37:43
@@ -194,8 +194,8 @@ case $host_os in
         archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname 
$libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} 
'"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
       else
         hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:/usr/lib:/lib'
-        # Warning - without using the other run time loading flags, -berok will
-        #           link without error, but may produce a broken library.
+        # Warning - without using the other run time loading flags,
+        # -berok will link without error, but may produce a broken library.
         no_undefined_flag='${wl}-bnoerok'
         allow_undefined_flag='${wl}-berok"
         # -bexpall does not export symbols beginning with underscore (_)
@@ -664,15 +664,6 @@ if test "$with_gcc" = yes; then
   ac_cv_prog_cc_static='-static'
 
   case $host_os in
-  aix*)
-    # All AIX code is PIC.
-    if test "$host_cpu" = ia64; then
-      # AIX 5 now supports IA64 processor
-      lt_cv_prog_cc_static='-Bstatic'
-    else
-      lt_cv_prog_cc_static='-bnso -bI:/lib/syscalls.exp'
-    fi
-    ;;
   amigaos*)
     # FIXME: we need at least 68020 code to build shared libraries, but
     # adding the `-m68020' flag to GCC prevents building anything better,
@@ -708,12 +699,13 @@ if test "$with_gcc" = yes; then
 else
   case $host_os in
     aix4* | aix5*)
+      ac_cv_prog_cc_wl='-Wl,'
       # All AIX code is PIC.
       if test "$host_cpu" = ia64; then
         # AIX 5 now supports IA64 processor
-        lt_cv_prog_cc_static='-Bstatic'
+        ac_cv_prog_cc_static='-Bstatic'
       else
-        lt_cv_prog_cc_static='-bnso -bI:/lib/syscalls.exp'
+        ac_cv_prog_cc_static='-bnso -bI:/lib/syscalls.exp'
       fi
       ;;
     chorus*)
Index: ltconfig.in
===================================================================
RCS file: /home/cvs/libtool/Attic/ltconfig.in,v
retrieving revision 1.246.2.58
diff -u -3 -p -r1.246.2.58 ltconfig.in
--- ltconfig.in 2001/04/24 22:20:08     1.246.2.58
+++ ltconfig.in 2001/04/26 14:38:06
@@ -984,6 +984,7 @@ aix3*)
   ;;
 
 aix4* | aix5*)
+  version_type=linux
   if test "$host_cpu" = ia64; then
     # AIX 5 supports IA64
     library_names_spec='${libname}${release}.so$versuffix 
${libname}${release}.so$major $libname.so'
@@ -1002,7 +1003,7 @@ aix4* | aix5*)
       # We preserve .a as extension for shared libraries though AIX4.2
       # and later when we are not doing run time linking.
       library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}.so$major.o'
+      soname_spec='${libname}${release}.so$major'
     fi
     # If we're using GNU nm, then we don't want the "-C" option.
     # -C means demangle to AIX nm, but means don't demangle with GNU nm
@@ -1535,8 +1536,8 @@ esac
 echo $ac_n "checking whether to build shared libraries... $ac_c" 1>&6
 test "$can_build_shared" = "no" && enable_shared=no
 
-# On AIX, shared libraries and static libraries use the same namespace, and
-# are all built from PIC.
+# On AIX 3, shared libraries and static libraries use the same namespace,
+# and are all built from PIC.
 case $host_os in
 aix3*)
   test "$enable_shared" = yes && enable_static=no
@@ -1547,7 +1548,9 @@ aix3*)
   ;;
 
 aix4*)
-  test "$enable_shared" = yes && enable_static=no
+  if test "$aix_use_runtimelinking" != yes; then
+    test "$enable_shared" = yes && enable_static=no
+  fi
   ;;
 esac
 



reply via email to

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