[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: per-deplib static/dynamic flags
From: |
Ralf Wildenhues |
Subject: |
Re: per-deplib static/dynamic flags |
Date: |
Mon, 30 Jan 2006 22:32:45 +0100 |
User-agent: |
Mutt/1.5.9i |
* Ralf Wildenhues wrote on Mon, Jan 30, 2006 at 02:01:53PM CET:
>
> I will followup to this mail (to libtool-patches only for size) with a
> patch to implement per-deplib flags for programs (for CVS HEAD) and add
> comprehensive tests for the static flags.
Here goes the per-deplib implementation. The patch depends upon the
pending `-static-libtool-libs' patch and the `-static' hardcoding fix.
Comments and test results appreciated.
Tested with
- some GNU/Linux (also CC=g++),
- AIX 5.3 (rtl and non-rtl),
- Solaris, GCC and Sun Studio 5.8.
All other platforms mentioned in _LT_LINKER_STATIC_DYNAMIC are basically
guesses, so please test and report back here or on the mentioned wiki
page.
OK to apply to HEAD?
Cheers,
Ralf
Implement per-deplib static/dynamic linking flags for programs.
* libltdl/config/ltmain.m4sh (help output, func_mode_link)
< -Bstatic, -Bdynamic >: New user flags to control per-deplib
linking mode for creating programs. The flags may be specified
multiple times, are position-dependent, and set the preferred
linking mode for libraries following on the link line (including
pulled in dependencies).
* libltdl/m4/libtool.m4 (_LT_LINKER_STATIC_DYNAMIC): New
macro to specify new tag variables `per_deplib_static_flag'
and `per_deplib_dynamic_flag'.
(_LT_LANG_C_CONFIG, _LT_LANG_CXX_CONFIG, _LT_LANG_F77_CONFIG)
(_LT_LANG_FC_CONFIG, _LT_LANG_GCJ_CONFIG): Call it.
* doc/libtool.texi (Link mode): Document the new user flags.
diff -ur libtool/NEWS libtool2/NEWS
--- libtool/NEWS 2006-01-30 18:33:32.000000000 +0100
+++ libtool2/NEWS 2006-01-30 18:34:21.000000000 +0100
@@ -31,6 +31,8 @@
* Support for Interix 3 (Windows SFU).
* Basic support for PIE (position-independent executables).
* Initial support for RDOS.
+* Support for per-deplib linking flags `-Bstatic' and `-Bdynamic' when
+ creating programs.
* Bug fixes.
New in 1.9f: 2004-10-23; CVS version 1.9e, Libtool team:
diff -ur libtool/doc/libtool.texi libtool2/doc/libtool.texi
--- libtool/doc/libtool.texi 2006-01-30 18:34:06.000000000 +0100
+++ libtool2/doc/libtool.texi 2006-01-30 18:34:21.000000000 +0100
@@ -1329,6 +1329,26 @@
i.e.@: no version information is stored and no symbolic links are created.
If the platform requires versioning, this option has no effect.
address@hidden -Bstatic
+If @var{output-file} is a program, prefer linking statically against the
+libraries following on the command line, if the linker allows to specify
+the preferred link address@hidden that depending on the system, this
+may link against shared @file{*.a} archives, for example on AIX without
+runtimelinking.} This switch may be used multiple times and is reverted
+by @option{-Bdynamic}. In case no suitable library of the preferred type
+is found, it is unspecified whether the link will fail or succeed with a
+library of different type. It is usually necessary to reset the preferred
+link mode with @option{-Bdynamic} at the end of the command line so that
+system libraries are added correctly.
+
+If @var{output-file} is a library, or if @option{-Bstatic} or
@option{-Bdynamic}
+and either one of @option{-static}, @option{-static-libtool-libs}, or
address@hidden are used together, the action is unspecified and may
+change in a future version.
+
address@hidden -Bdynamic
+This switch undoes @option{-Bstatic}, see there for more information.
+
@item -dlopen @var{file}
Same as @option{-dlpreopen @var{file}}, if native dlopening is not
supported on the host platform (@pxref{Dlopened modules}) or if
diff -ur libtool/libltdl/config/ltmain.m4sh libtool2/libltdl/config/ltmain.m4sh
--- libtool/libltdl/config/ltmain.m4sh 2006-01-30 18:34:06.000000000 +0100
+++ libtool2/libltdl/config/ltmain.m4sh 2006-01-30 18:34:21.000000000 +0100
@@ -327,6 +327,8 @@
-all-static do not do any dynamic linking at all
-avoid-version do not add a version suffix if possible
+ -Bstatic prefer static linking for following libraries
+ -Bdynamic prefer dynamic linking for following libraries
-dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
-dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
-export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
@@ -2205,8 +2207,10 @@
no_install=no
objs=
non_pic_objects=
+ per_deplib_static=no
precious_files_regex=
prefer_static_libs=no
+ prefer_static_mode=default
preload=no
prev=
prevarg=
@@ -2263,6 +2267,9 @@
build_old_libs=yes
break
;;
+ -Bstatic | -Bdynamic)
+ per_deplib_static=yes
+ ;;
esac
done
@@ -2530,6 +2537,9 @@
case $arg in
-all-static)
# The effects of -all-static are defined in a previous loop.
+ if test "$per_deplib_static" = yes; then
+ func_fatal_error "cannot have \`-all-static' together with per-deplib
\`-Bstatic' flag."
+ fi
continue
;;
@@ -2543,6 +2553,12 @@
continue
;;
+ -Bstatic | -Bdynamic)
+ # deplibs=$deplibs\ `$ECHO "X$arg" | $Xsed -e "s^/$wl//"`
+ deplibs="$deplibs $arg"
+ continue
+ ;;
+
-dlopen)
prev=dlfiles
continue
@@ -3056,6 +3072,7 @@
for deplib in $deplibs; do
if $opt_duplicate_deps ; then
case "$libs " in
+ "-Bstatic " | "-Bdynamic ") ;;
*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
esac
fi
@@ -3167,6 +3184,16 @@
lib=
found=no
case $deplib in
+ -Bstatic|-Bdynamic)
+ if test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ deplibs="$deplib $deplibs"
+ fi
+ prefer_static_mode=$deplib
+ continue
+ ;;
-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
if test "$linkmode,$pass" = "prog,link"; then
compile_deplibs="$deplib $compile_deplibs"
@@ -3190,7 +3217,11 @@
func_stripname '-l' '' "$deplib"
name=$func_stripname_result
for searchdir in $newlib_search_path $lib_search_path
$sys_lib_search_path $shlib_search_path; do
- for search_ext in .la $std_shrext .so .a; do
+ case $prefer_static_mode in
+ -Bstatic) search_exts=".la .a" ;;
+ *) search_exts=".la $std_shrext .so .a" ;;
+ esac
+ for search_ext in $search_exts; do
# Search the libtool library
lib="$searchdir/lib${name}${search_ext}"
if test -f "$lib"; then
@@ -3605,8 +3636,9 @@
if test "$linkmode,$pass" = "prog,link"; then
if test -n "$library_names" &&
- { { test "$prefer_static_libs" = no ||
- test "$prefer_static_libs,$installed" = "built,yes"; } ||
+ { { { test "$prefer_static_libs" = no ||
+ test "$prefer_static_libs,$installed" = "built,yes"; } &&
+ test "$prefer_static_mode" != "-Bstatic"; } ||
test -z "$old_library"; }; then
# We need to hardcode the library path
if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
@@ -3652,6 +3686,9 @@
if test "$use_static_libs" = built && test "$installed" = yes; then
use_static_libs=no
fi
+ if test "$prefer_static_mode" = "-Bstatic"; then
+ use_static_libs=yes
+ fi
if test -n "$library_names" &&
{ test "$use_static_libs" = no || test -z "$old_library"; }; then
case $host in
@@ -4084,7 +4121,7 @@
# Pragmatically, this seems to cause very few problems in
# practice:
case $deplib in
- -L*) new_libs="$deplib $new_libs" ;;
+ -L*|-Bstatic|-Bdynamic) new_libs="$deplib $new_libs" ;;
-R*) ;;
*)
# And here is the reason: when a library appears more
@@ -5546,6 +5585,17 @@
done
compile_deplibs="$new_libs"
+ # substitute per-deplib flags; make sure `$wl' is expanded in shell
wrapper.
+ if test "$per_deplib_static" = yes; then
+ eval per_deplib_static_flag=`$ECHO "X$per_deplib_static_flag" | $Xsed`
+ eval per_deplib_dynamic_flag=`$ECHO "X$per_deplib_dynamic_flag" | $Xsed`
+ compile_deplibs=`$ECHO "X $compile_deplibs " | $Xsed -e "\
+ s% -Bstatic % $per_deplib_static_flag %g
+ s% -Bdynamic % $per_deplib_dynamic_flag %g"`
+ finalize_deplibs=`$ECHO "X $finalize_deplibs " | $Xsed -e "\
+ s% -Bstatic % $per_deplib_static_flag %g
+ s% -Bdynamic % $per_deplib_dynamic_flag %g"`
+ fi
compile_command="$compile_command $compile_deplibs"
finalize_command="$finalize_command $finalize_deplibs"
diff -ur libtool/libltdl/m4/libtool.m4 libtool2/libltdl/m4/libtool.m4
--- libtool/libltdl/m4/libtool.m4 2006-01-30 18:33:32.000000000 +0100
+++ libtool2/libltdl/m4/libtool.m4 2006-01-30 18:34:21.000000000 +0100
@@ -3899,6 +3899,55 @@
])# _LT_COMPILER_PIC
+# _LT_LINKER_STATIC_DYNAMIC([TAGNAME])
+# ------------------------------------
+# per-deplib flags for static or dynamic linking
+m4_defun([_LT_LINKER_STATIC_DYNAMIC],
+[_LT_TAGVAR(lt_prog_linker_static, $1)=
+_LT_TAGVAR(lt_prog_linker_dynamic, $1)=
+
+AC_MSG_CHECKING([for per-deplib static/dynamic linking flags])
+if test "$lt_cv_prog_gnu_ld" = yes; then
+ _LT_TAGVAR(lt_prog_linker_static, $1)='${wl}-Bstatic'
+ _LT_TAGVAR(lt_prog_linker_dynamic, $1)='${wl}-Bdynamic'
+else
+ case $host_os in
+ aix4.[[23]]|aix4.[[23]].*|aix5*)
+ _LT_TAGVAR(lt_prog_linker_static, $1)='${wl}-bstatic'
+ _LT_TAGVAR(lt_prog_linker_dynamic, $1)='${wl}-bshared'
+ ;;
+ hpux*)
+ _LT_TAGVAR(lt_prog_linker_static, $1)='${wl}-a ${wl}archive_shared'
+ _LT_TAGVAR(lt_prog_linker_dynamic, $1)='${wl}-a ${wl}shared_archive'
+ ;;
+ solaris*)
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(lt_prog_linker_static, $1)='${wl}-Bstatic'
+ _LT_TAGVAR(lt_prog_linker_dynamic, $1)='${wl}-Bdynamic'
+ else
+ _LT_TAGVAR(lt_prog_linker_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_linker_dynamic, $1)='-Bdynamic'
+ fi
+ ;;
+ irix* | \
+ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+ _LT_TAGVAR(lt_prog_linker_static, $1)='${wl}-Bstatic'
+ _LT_TAGVAR(lt_prog_linker_dynamic, $1)='${wl}-Bdynamic'
+ ;;
+ osf*)
+ _LT_TAGVAR(lt_prog_linker_static, $1)='${wl}-noso'
+ _LT_TAGVAR(lt_prog_linker_dynamic, $1)='${wl}-noarchive'
+ ;;
+ esac
+fi
+AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_linker_static,
$1)/$_LT_TAGVAR(lt_prog_linker_dynamic, $1)])
+_LT_TAGDECL([per_deplib_static_flag], [lt_prog_linker_static], [1],
+ [Flag to prefer static linking for following libraries.])
+_LT_TAGDECL([per_deplib_dynamic_flag], [lt_prog_linker_dynamic], [1],
+ [Flag to prefer dynamic linking for following libraries.])
+])# _LT_LINKER_STATIC_DYNAMIC
+
+
# _LT_LINKER_SHLIBS([TAGNAME])
# ----------------------------
# See if the linker supports building shared libraries.
@@ -5018,6 +5074,7 @@
_LT_COMPILER_C_O($1)
_LT_COMPILER_FILE_LOCKS($1)
_LT_LINKER_SHLIBS($1)
+ _LT_LINKER_STATIC_DYNAMIC($1)
_LT_SYS_DYNAMIC_LINKER($1)
_LT_LINKER_HARDCODE_LIBPATH($1)
LT_SYS_DLOPEN_SELF
@@ -6083,6 +6140,7 @@
_LT_COMPILER_C_O($1)
_LT_COMPILER_FILE_LOCKS($1)
_LT_LINKER_SHLIBS($1)
+ _LT_LINKER_STATIC_DYNAMIC($1)
_LT_SYS_DYNAMIC_LINKER($1)
_LT_LINKER_HARDCODE_LIBPATH($1)
@@ -6410,6 +6468,7 @@
_LT_COMPILER_C_O($1)
_LT_COMPILER_FILE_LOCKS($1)
_LT_LINKER_SHLIBS($1)
+ _LT_LINKER_STATIC_DYNAMIC($1)
_LT_SYS_DYNAMIC_LINKER($1)
_LT_LINKER_HARDCODE_LIBPATH($1)
@@ -6544,6 +6603,7 @@
_LT_COMPILER_C_O($1)
_LT_COMPILER_FILE_LOCKS($1)
_LT_LINKER_SHLIBS($1)
+ _LT_LINKER_STATIC_DYNAMIC($1)
_LT_SYS_DYNAMIC_LINKER($1)
_LT_LINKER_HARDCODE_LIBPATH($1)
@@ -6608,6 +6668,7 @@
_LT_COMPILER_C_O($1)
_LT_COMPILER_FILE_LOCKS($1)
_LT_LINKER_SHLIBS($1)
+ _LT_LINKER_STATIC_DYNAMIC($1)
_LT_SYS_DYNAMIC_LINKER($1)
_LT_LINKER_HARDCODE_LIBPATH($1)