following up
http://lists.gnu.org/archive/html/bug-libtool/2008-12/msg00006.html
started at
http://lists.gnu.org/archive/html/bug-libtool/2008-11/msg00082.html
On Tue, 2008-12-09 at 06:51 +0100, Ralf Wildenhues wrote:
> * Michael Haubenwallner wrote on Mon, Dec 08, 2008 at 11:19:41PM CET:
> > On Mon, 2008-12-08 at 08:10 +0100, Ralf Wildenhues wrote:
> >
> > > > + _LT_TAGVAR(lt_prog_compiler_shared_as_static,
> > > > $1)='${wl}-bstatic'
> > > > + _LT_TAGVAR(lt_prog_compiler_shared_as_shared,
> > > > $1)='${wl}-bdynamic'
> > >
> > > What is the semantic difference between these switches and this proposal
> > > <http://thread.gmane.org/gmane.comp.gnu.libtool.patches/6727/focus=6730>?
> > > If the difference is too small, we should apply the other patch first
> > > and adjust your patch accordingly, no?
> >
> > Haven't seen this thread before. Agreed, it is related, but it depends
> > on how the per-deplib-flags would interfere with -static-libtool-libs
> > and -static, as - unlike other platforms - the '-bstatic' flag allows
> > (and is necessary when not -static) to statically link a shared-only
> > library.
>
> Yes, that is definitely different in semantics than what the above
> thread tries to achieve.
>
> > So the search for a statically-linkable library would need to know that
> > shared-only libraries can match too when '$shared_as_static' is set.
>
> Yep.
Have extracted the parts to statically link against shared libraries on
AIX, although I don't have an idea how to get better readability for the
additional tests in ltmain.m4sh.
This also applies to the test-cases, which really should utilize
'-static' whenever possible.
Thanks!
/haubi/
diff --git a/doc/notes.texi b/doc/notes.texi
index 44b50d1..a0357f2 100644
--- a/doc/notes.texi
+++ b/doc/notes.texi
@@ -4,6 +4,13 @@
You currently need GNU make to build the Libtool package itself.
@item
+On AIX, everything is PIC, so there is no need to compile two separate objects
+for shared and static libraries. However, AIX can statically link against
+shared libraries (more specifically shared objects) using some linker flags.
+So libtool does not create the static library when shared-library-creation is
+active, but still can link statically against the shared library when requested.
+
+...@item
On AIX there are two different styles of shared linking, one in which symbols
are bound at link-time and one in which symbols are bound at runtime only,
similar to e...@. In case of doubt use @code{LDFLAGS=-Wl,-brtl} for the latter style.
diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index 2769149..2951b69 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -3853,8 +3853,10 @@ func_mode_link ()
fi
if test -n "$link_static_flag"; then
dlopen_self=$dlopen_self_static
+ prefer_static_libs=all
+ else
+ prefer_static_libs=yes
fi
- prefer_static_libs=yes
;;
-static)
if test -z "$pic_flag" && test -n "$link_static_flag"; then
@@ -5478,7 +5480,17 @@ func_mode_link ()
fi
if test "$linkmode" = prog; then
test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
+ # AIX can link 'shared objects' statically:
+ test "$use_static_libs" != no &&
+ test "$use_static_libs" != all &&
+ test -n "$link_shared_as_static_flag" &&
+ eval "compile_deplibs=\"$link_shared_as_static_flag \$compile_deplibs\""
test -n "$add" && compile_deplibs="$add $compile_deplibs"
+ # switch back to link 'shared objects' dynamically:
+ test "$use_static_libs" != no &&
+ test "$use_static_libs" != all &&
+ test -n "$link_shared_as_shared_flag" &&
+ eval "compile_deplibs=\"$link_shared_as_shared_flag \$compile_deplibs\""
else
test -n "$add_dir" && deplibs="$add_dir $deplibs"
test -n "$add" && deplibs="$add $deplibs"
@@ -5533,10 +5545,30 @@ func_mode_link ()
if test "$linkmode" = prog; then
test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
+ # AIX can link 'shared objects' statically:
+ test "$use_static_libs" != no &&
+ test "$use_static_libs" != all &&
+ test -n "$link_shared_as_static_flag" &&
+ eval "finalize_deplibs=\"$link_shared_as_static_flag \$finalize_deplibs\""
test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
+ # switch back to link 'shared objects' dynamically:
+ test "$use_static_libs" != no &&
+ test "$use_static_libs" != all &&
+ test -n "$link_shared_as_shared_flag" &&
+ eval "finalize_deplibs=\"$link_shared_as_shared_flag \$finalize_deplibs\""
else
test -n "$add_dir" && deplibs="$add_dir $deplibs"
+ # AIX can link 'shared objects' statically:
+ test "$use_static_libs" != no &&
+ test "$use_static_libs" != all &&
+ test -n "$link_shared_as_static_flag" &&
+ eval "deplibs=\"$link_shared_as_static_flag \$deplibs\""
test -n "$add" && deplibs="$add $deplibs"
+ # switch back to link 'shared objects' dynamically:
+ test "$use_static_libs" != no &&
+ test "$use_static_libs" != all &&
+ test -n "$link_shared_as_shared_flag" &&
+ eval "deplibs=\"$link_shared_as_shared_flag \$deplibs\""
fi
fi
elif test "$linkmode" = prog; then
@@ -5592,6 +5624,7 @@ func_mode_link ()
if test -n "$dependency_libs" &&
{ test "$hardcode_into_libs" != yes ||
test "$build_old_libs" = yes ||
+ test -n "$link_shared_as_static_flag" ||
test "$link_static" = yes; }; then
# Extract -R from dependency_libs
temp_deplibs=
@@ -6182,7 +6215,8 @@ func_mode_link ()
*) finalize_rpath="$finalize_rpath $libdir" ;;
esac
done
- if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
+ if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes ||
+ test -n "$link_shared_as_static_flag"; then
dependency_libs="$temp_xrpath $dependency_libs"
fi
fi
diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4
index b7b566d..7b0055b 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -3478,6 +3478,8 @@ m4_defun([_LT_COMPILER_PIC],
_LT_TAGVAR(lt_prog_compiler_wl, $1)=
_LT_TAGVAR(lt_prog_compiler_pic, $1)=
_LT_TAGVAR(lt_prog_compiler_static, $1)=
+_LT_TAGVAR(lt_prog_compiler_shared_as_static, $1)=
+_LT_TAGVAR(lt_prog_compiler_shared_as_shared, $1)=
AC_MSG_CHECKING([for $compiler option to produce PIC])
m4_if([$1], [CXX], [
@@ -3492,6 +3494,9 @@ m4_if([$1], [CXX], [
if test "$host_cpu" = ia64; then
# AIX 5 now supports IA64 processor
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ else
+ _LT_TAGVAR(lt_prog_compiler_shared_as_static, $1)='${wl}-bstatic'
+ _LT_TAGVAR(lt_prog_compiler_shared_as_shared, $1)='${wl}-bdynamic'
fi
;;
@@ -3569,6 +3574,8 @@ m4_if([$1], [CXX], [
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
else
_LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+ _LT_TAGVAR(lt_prog_compiler_shared_as_static, $1)='-bstatic'
+ _LT_TAGVAR(lt_prog_compiler_shared_as_shared, $1)='-bdynamic'
fi
;;
chorus*)
@@ -3798,6 +3805,9 @@ m4_if([$1], [CXX], [
if test "$host_cpu" = ia64; then
# AIX 5 now supports IA64 processor
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ else
+ _LT_TAGVAR(lt_prog_compiler_shared_as_static, $1)='${wl}-bstatic'
+ _LT_TAGVAR(lt_prog_compiler_shared_as_shared, $1)='${wl}-bdynamic'
fi
;;
@@ -3887,6 +3897,8 @@ m4_if([$1], [CXX], [
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
else
_LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+ _LT_TAGVAR(lt_prog_compiler_shared_as_static, $1)='-bstatic'
+ _LT_TAGVAR(lt_prog_compiler_shared_as_shared, $1)='-bdynamic'
fi
;;
@@ -4091,6 +4103,10 @@ _LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
[_LT_TAGVAR(lt_prog_compiler_static, $1)=])
_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
[Compiler flag to prevent dynamic linking])
+_LT_TAGDECL([link_shared_as_static_flag], [lt_prog_compiler_shared_as_static], [1],
+ [Compiler flag to link subsequent shared objects statically - AIX can do that])
+_LT_TAGDECL([link_shared_as_shared_flag], [lt_prog_compiler_shared_as_shared], [1],
+ [Compiler flag to link subsequent shared objects dynamically])
])# _LT_COMPILER_PIC
diff --git a/tests/demo/configure.ac b/tests/demo/configure.ac
index ccfc6fb..6880d40 100644
--- a/tests/demo/configure.ac
+++ b/tests/demo/configure.ac
@@ -51,7 +51,7 @@ LT_INIT([dlopen win32-dll])
AC_SUBST([LIBTOOL_DEPS])
STATIC=
-test "X$enable_static" = Xyes && STATIC=-static
+test "X$enable_static" = Xyes -o "X$lt_lt_prog_compiler_shared_as_static" != X && STATIC=-static
AC_SUBST([STATIC])
case $lt_cv_sys_global_symbol_pipe in
diff --git a/tests/depdemo/configure.ac b/tests/depdemo/configure.ac
index 31231f3..95d7c25 100644
--- a/tests/depdemo/configure.ac
+++ b/tests/depdemo/configure.ac
@@ -53,6 +53,7 @@ AC_SUBST([LIBTOOL_DEPS])
## depdemo specific configuration. ##
## ------------------------------- ##
STATIC="\`${CONFIG_SHELL} ./libtool --features | ${SED} -n -e '/enable static/s/^.*\$\$/-static/p'\`"
+test "X$lt_lt_prog_compiler_shared_as_static" != X && STATIC=-static
AC_SUBST([STATIC])
## ------------------------------ ##
diff --git a/tests/mdemo/configure.ac b/tests/mdemo/configure.ac
index c1a88f2..ee90537 100644
--- a/tests/mdemo/configure.ac
+++ b/tests/mdemo/configure.ac
@@ -55,7 +55,7 @@ LT_INIT([dlopen win32-dll])
AC_SUBST(LIBTOOL_DEPS)
STATIC=""
-test "X$enable_static" = Xyes && STATIC="-static"
+test "X$enable_static" = Xyes -o "X$lt_lt_prog_compiler_shared_as_static" != X && STATIC="-static"
AC_SUBST([STATIC])
diff --git a/tests/mdemo2/configure.ac b/tests/mdemo2/configure.ac
index c73ae5f..52c0e0b 100644
--- a/tests/mdemo2/configure.ac
+++ b/tests/mdemo2/configure.ac
@@ -51,7 +51,7 @@ LT_INIT([dlopen])
AC_SUBST(LIBTOOL_DEPS)
STATIC=""
-test "X$enable_static" = Xyes && STATIC="-static"
+test "X$enable_static" = Xyes -o "X$lt_lt_prog_compiler_shared_as_static" != X && STATIC="-static"
AC_SUBST([STATIC])
diff --git a/tests/pdemo/configure.ac b/tests/pdemo/configure.ac
index 83cb5d4..a9c12d4 100644
--- a/tests/pdemo/configure.ac
+++ b/tests/pdemo/configure.ac
@@ -51,7 +51,7 @@ LT_INIT([dlopen])
AC_SUBST([LIBTOOL_DEPS])
STATIC=
-test "X$enable_static" = Xyes && STATIC=-static
+test "X$enable_static" = Xyes -o "X$lt_lt_prog_compiler_shared_as_static" != X && STATIC=-static
AC_SUBST([STATIC])
case $lt_cv_sys_global_symbol_pipe in