libtool-patches
[Top][All Lists]
Advanced

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

[PATCH] AIX SONAME emulation, simplified implementation


From: Daniel Ruoso (BLOOMBERG/ 731 LEX)
Subject: [PATCH] AIX SONAME emulation, simplified implementation
Date: Wed, 24 Jun 2015 13:34:27 -0000

This patch offers a simplified implementation of a SONAME-like behavior emulation. This is different in the sense that it doesn't add archives disguised as .so files, and instead relies on the fact that the AIX linker will take an import file when looking for -l<foo>, and will record what the import file says.

---
build-aux/ltmain.in | 20 ++++++++++++++++++++
m4/libtool.m4 | 31 ++++++++++++++++++++++++-------
2 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
index d5cf07a..4bf8cd1 100644
--- a/build-aux/ltmain.in
+++ b/build-aux/ltmain.in
@@ -2429,6 +2429,17 @@ func_mode_install ()
do
test "$linkname" != "$realname" \
&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
+ # implement AIX import file SONAME-like behavior trick
+ # (see libtool.m4 for details).
+ case $host in
+ *aix*)
+ if test "$linkname" == `echo "$linkname" | sed 's/\.so.*$/.so/'`; then
+ # this is not a symlink, we re-use the file that
+ # was previously generated
+ func_show_eval '($RM "$destdir/$linkname" && cp "$dir/$linkname" "$destdir/$linkname")'
+ fi
+ ;;
+ esac
done
fi
@@ -8151,6 +8162,15 @@ EOF
if test "$realname" != "$linkname"; then
func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
fi
+ # implement AIX import file SONAME-like behavior trick
+ # (see libtool.m4 for details).
+ case $module,$host in
+ no,*aix*)
+ if test "$linkname" == "$libname$shared_ext"; then
+ func_show_eval '($RM "$output_objdir/$linkname" && echo "#!$soname" > "$output_objdir/$linkname" && cat "$export_symbols" >> "$output_objdir/$linkname")'
+ fi
+ ;;
+ esac
done
# If -module or -export-dynamic was specified, set the dlname.
diff --git a/m4/libtool.m4 b/m4/libtool.m4
index a3bc337..8995745 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -2445,11 +2445,28 @@ aix[[4-9]]*)
# soname into executable. Probably we can add versioning support to
# collect2, so additional links can be useful in future.
aix,yes) # traditional libtool
- dynamic_linker='AIX unversionable lib.so'
- # If using run time linking (on AIX 4.2 or later) use lib<name>.so
- # instead of lib<name>.a to let people know that these are not
- # typical AIX shared libraries.
+ dynamic_linker='AIX libtool SONAME emulation lib.so'
+ # If using run time linking (on AIX 4.2 or later) use
+ # lib<name>.so instead of lib<name>.a to let people know that
+ # these are not typical AIX shared libraries. However, we can
+ # emulate the libtool behavior further by using lib.so as the
+ # import file at build time. The AIX linker will accept import
+ # files to be found by -l<name>, and if the given import file
+ # has the first line in the format
+ #
+ # #!lib<name>.so.0
+ # symbol0
+ # symbol1
+ #
+ # it will record the versioned name in the resulting executable or
+ # shared library, effectively emulating the SONAME behavior.
+ #
+ # for the sake of this implementation, the value ending in the
+ # shared_ext on library_names_spec will be considered the
+ # 'development-time' file, which will contain the import
+ # instructions instead of the actual object.
library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
;;
aix,no) # traditional AIX only
dynamic_linker='AIX lib.a[(]lib.so.V[)]'
@@ -5494,12 +5511,12 @@ _LT_EOF
# empty executable.
_LT_SYS_MODULE_PATH_AIX([$1])
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$realname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
else
if test ia64 = "$host_cpu"; then
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib'
_LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
- _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$realname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
else
# Determine the default libpath from the value encoded in an
# empty executable.
@@ -5522,7 +5539,7 @@ _LT_EOF
compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`'
if test svr4 != "$with_aix_soname"; then
# This is similar to how AIX traditionally builds its shared libraries.
- _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+ _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$realname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$realname'
fi
if test aix != "$with_aix_soname"; then
_LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp'
--
2.4.3


reply via email to

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