Hi David,
(moving to libtool-patc...@...)
Den 2009-09-03 20:24 skrev David Byron:
You want to send -DEBUG to link.exe, not to cl.exe. I'm
sure you know this, but simply adding -DEBUG to LDFLAGS is
not the way you do this. The correct way would be to use
-Wl,-DEBUG. If the msvc stuff were complete, libtool would
then feed -DEBUG to the linker. But this does not
currently work, and the main reason is that the -link
option to cl.exe is "different". It feeds all options
(instead of just one) after the -link option on the
command line to the linker, so it would be very bad to
just transform -Wl,foo into -link foo.
Makes sense.
Can someone show me how to do this without hacking the
libtool file?
You can work around the above -Wl,foo limitation in two
ways.
2) Use a response file, like this:
$ cat linkdebug
-link -DEBUG
$ /bin/sh ./libtool --tag=CC --mode=link cl @linkdebug -MD -Zi \
-no-undefined -export-symbols symfile -o libfoo.la \
-rpath /usr/local/lib libfoo_la-public.lo libfoo_la-private.lo
This works well, though way I integrated it with autoconf and automake is a
bit cumbersome. Trouble is, it works so it's harder to motivate to dive in
and fix libtool to do the right thing with -Wl,-DEBUG.
Here's a couple of patches that implements support for -Wl, and
-Xlinker for MSVC. The first one (rename-dashL_envvar-tolinker_envvar.patch)
is just a rename, to reduce confusion, and the second patch
(-Xlinker-msvc.patch) contains the new code...
Ok for the pr-msvc-support branch?
Cheers,
Peter
2009-09-09 Peter Rosin <p...@lysator.liu.se>
Make -Wl,FLAG and -Xlinker FLAG work on MSVC.
* libltdl/m4/libtool.m4 (_LT_COMPILER_PIC) [MSVC]: Set
lt_prog_compiler_wl to @lt_envvar@ to signal that linker options
should be passed via the $linker_envvar variable.
* libltdl/config/ltmain.m4sh (func_to_linker_envvar): Also move
@lt_output@ options to the $linker_envvar variable.
(func_mode_link) [linkmode=lib]: Look for options to move to the
$linker_envvar in $compiler_flags as well. Echo the final
content of the linker_envvar.
(func_mode_link) [linkmode=prog]: Look for options to move to the
$linker_envvar in $compile_command and $finalize_command as well.
* tests/flags.at: Don't expect to find @lt_envvar@ in the output
if $wl is set to that.
* doc/libtool.texi (linker_envvar): Document the @lt_envvar@ hook.
2009-09-09 Peter Rosin <p...@lysator.liu.se>
Rename dashL_envvar into linker_envvar.
* libltdl/m4/libtool.m4 (_LT_LINKER_SHLIBS, _LT_LANG_CXX_CONFIG):
Rename dashL_envvar into linker_envvar. The new name makes it
less confusing to pass other linker options via the variable.
* libltdl/config/ltmain.m4sh (func_dashL_to_envvar): Rename...
(func_to_linker_envvar): ...to this, and operate on linker_envvar
instead of dashL_envvar.
(func_mode_link): Adjust to above renames.
* doc/libtool.texi: Document changes.
diff --git a/doc/libtool.texi b/doc/libtool.texi
index 610117e..9aa3d4b 100644
--- a/doc/libtool.texi
+++ b/doc/libtool.texi
@@ -5876,13 +5876,6 @@ convenience archives or a set of object file names can
be passed via
linker-specific options or linker scripts.
@end defvar
-...@defvar dashL_envvar
-When linking, move all paths specified with @option{-L} options to
-this variable, for toolchains where it makes sense to pass the library
-search paths in an environment variable. Normally disabled (i.e.
-...@var{dashl_envvar} empty).
-...@end defvar
-
@defvar dashL_envvar_spec
When moving library search paths with @var{dashL_envvar}, prepend this
to each @option{-L} path that is added to @var{dashL_envvar}. Unused
@@ -6107,6 +6100,13 @@ Linker flag (passed through the C compiler) used to
prevent dynamic
linking.
@end defvar
+...@defvar linker_envvar
+When linking, move all paths specified with @option{-L} options to
+this variable, for toolchains where it makes sense to pass the library
+search paths in an environment variable. Normally disabled (i.e.
+...@var{linker_envvar} empty).
+...@end defvar
+
@defvar macro_version
@defvarx macro_revision
The release and revision from which the libtool.m4 macros were
diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index 40ff9d3..5fc8d0b 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -634,8 +634,8 @@ func_infer_tag ()
}
-# func_dashL_to_envvar deplibs_variable deplibs...
-func_dashL_to_envvar ()
+# func_to_linker_envvar deplibs_variable deplibs...
+func_to_linker_envvar ()
{
deplibs_variable=$1
shift
@@ -653,7 +653,7 @@ func_dashL_to_envvar ()
env_path=`cygpath -w "$env_path"`
;;
esac
- eval $dashL_envvar="\"\$$dashL_envvar $dashL_envvar_spec$env_path\""
+ eval $linker_envvar="\"\$$linker_envvar $dashL_envvar_spec$env_path\""
;;
*)
tmp_libs="$tmp_libs $deplib"
@@ -7021,16 +7021,16 @@ EOF
test "X$libobjs" = "X " && libobjs=
fi
- case $pass/$dashL_envvar in
+ case $pass/$linker_envvar in
link/) ;;
link/*)
# Move all -L options to the environment variable
- # specified by $dashL_envvar.
- eval save_dashL_envvar="\"\$$dashL_envvar\""
- eval cmds=\"\$cmds~$dashL_envvar="$save_dashL_envvar"\"
+ # specified by $linker_envvar.
+ eval save_linker_envvar="\"\$$linker_envvar\""
+ eval cmds=\"\$cmds~$linker_envvar="$save_linker_envvar"\"
- func_dashL_to_envvar deplibs $deplibs
- export $dashL_envvar
+ func_to_linker_envvar deplibs $deplibs
+ export $linker_envvar
;;
esac
@@ -7262,22 +7262,22 @@ EOF
compile_deplibs="$new_libs"
- case $pass/$dashL_envvar in
+ case $pass/$linker_envvar in
link/) ;;
link/*)
# Move all -L options to the environment variable
- # specified by $dashL_envvar.
- eval save_dashL_envvar="\"\$$dashL_envvar\""
-
- func_dashL_to_envvar compile_deplibs $compile_deplibs
- eval prepend_dashL_envvar="$dashL_envvar=\\\"\$$dashL_envvar\\\""
- compile_command="$prepend_dashL_envvar $compile_command"
- eval $dashL_envvar="\"$save_dashL_envvar\""
-
- func_dashL_to_envvar finalize_deplibs $finalize_deplibs
- eval prepend_dashL_envvar="$dashL_envvar=\\\"\$$dashL_envvar\\\""
- finalize_command="$prepend_dashL_envvar $finalize_command"
- eval $dashL_envvar="\"$save_dashL_envvar\""
+ # specified by $linker_envvar.
+ eval save_linker_envvar="\"\$$linker_envvar\""
+
+ func_to_linker_envvar compile_deplibs $compile_deplibs
+ eval prepend_linker_envvar="$linker_envvar=\\\"\$$linker_envvar\\\""
+ compile_command="$prepend_linker_envvar $compile_command"
+ eval $linker_envvar="\"$save_linker_envvar\""
+
+ func_to_linker_envvar finalize_deplibs $finalize_deplibs
+ eval prepend_linker_envvar="$linker_envvar=\\\"\$$linker_envvar\\\""
+ finalize_command="$prepend_linker_envvar $finalize_command"
+ eval $linker_envvar="\"$save_linker_envvar\""
;;
esac
diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4
index 1a2d7d4..962912c 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -4876,7 +4876,7 @@ _LT_EOF
# Not needed on MinGW
cygwin*) _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' ;;
esac
- _LT_TAGVAR(dashL_envvar, $1)=LINK
+ _LT_TAGVAR(linker_envvar, $1)=LINK
_LT_TAGVAR(dashL_envvar_spec, $1)='-LIBPATH:'
_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
_LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience |
$global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^
]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq
> $export_symbols'
@@ -5450,10 +5450,10 @@ _LT_TAGDECL([], [postlink_cmds], [2],
[Commands necessary for finishing linking programs])
_LT_TAGDECL([], [file_list_spec], [1],
[Specify filename containing input files])
-_LT_TAGDECL([], [dashL_envvar], [1],
- [When linking, move all paths specified with -L options to this variable])
+_LT_TAGDECL([], [linker_envvar], [1],
+ [Pass linker options to the linker via this variable])
_LT_TAGDECL([], [dashL_envvar_spec], [1],
- [When moving paths with dashL_envvar, prepend this to each path])
+ [When moving -L paths with linker_envvar, prepend this to each path])
_LT_TAGDECL([], [compile_tag], [1],
[Add tag specific option for the compiler])
_LT_TAGDECL([], [dashl_xform], [1],
@@ -5880,7 +5880,7 @@ if test "$_lt_caught_CXX_error" != yes; then
# Not needed on MinGW
cygwin*) _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
;;
esac
- _LT_TAGVAR(dashL_envvar, $1)=LINK
+ _LT_TAGVAR(linker_envvar, $1)=LINK
_LT_TAGVAR(dashL_envvar_spec, $1)='-LIBPATH:'
_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
# Don't use ranlib
diff --git a/doc/libtool.texi b/doc/libtool.texi
index 9aa3d4b..2be2703 100644
--- a/doc/libtool.texi
+++ b/doc/libtool.texi
@@ -6103,8 +6103,10 @@ linking.
@defvar linker_envvar
When linking, move all paths specified with @option{-L} options to
this variable, for toolchains where it makes sense to pass the library
-search paths in an environment variable. Normally disabled (i.e.
-...@var{linker_envvar} empty).
+search paths in an environment variable. Linker options passed with
+...@option{-wl,} or @option{-Xlinker} may also be passed via this
+environment variable if @var{wl} is set to @samp{@@lt_envvar@@}.
+Normally disabled (i.e. @var{linker_envvar} empty).
@end defvar
@defvar macro_version
diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index 5fc8d0b..f205e3e 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -642,6 +642,10 @@ func_to_linker_envvar ()
tmp_libs=
for deplib; do
case $deplib in
+ @lt_lin...@*)
+ func_stripname '@lt_linker@' '' "$deplib"
+ eval $linker_envvar="\"\$$linker_envvar $func_stripname_result\""
+ ;;
-L*)
func_stripname '-L' '' "$deplib"
env_path=$func_stripname_result
@@ -7030,7 +7034,9 @@ EOF
eval cmds=\"\$cmds~$linker_envvar="$save_linker_envvar"\"
func_to_linker_envvar deplibs $deplibs
+ func_to_linker_envvar compiler_flags $compiler_flags
export $linker_envvar
+ eval "func_echo $linker_envvar=\\\"\$$linker_envvar\\\""
;;
esac
@@ -7269,11 +7275,13 @@ EOF
# specified by $linker_envvar.
eval save_linker_envvar="\"\$$linker_envvar\""
+ func_to_linker_envvar compile_command $compile_command
func_to_linker_envvar compile_deplibs $compile_deplibs
eval prepend_linker_envvar="$linker_envvar=\\\"\$$linker_envvar\\\""
compile_command="$prepend_linker_envvar $compile_command"
eval $linker_envvar="\"$save_linker_envvar\""
+ func_to_linker_envvar finalize_command $finalize_command
func_to_linker_envvar finalize_deplibs $finalize_deplibs
eval prepend_linker_envvar="$linker_envvar=\\\"\$$linker_envvar\\\""
finalize_command="$prepend_linker_envvar $finalize_command"
diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4
index 962912c..0668dec 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -3759,6 +3759,14 @@ m4_if([$1], [CXX], [
_LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
fi
;;
+ mingw* | cygwin*)
+ case $cc_basename in
+ cl*)
+ # MSVC
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='@lt_linker@'
+ ;;
+ esac
+ ;;
chorus*)
case $cc_basename in
cxch68*)
@@ -4083,6 +4091,12 @@ m4_if([$1], [CXX], [
# built for inclusion in a dll (and should export symbols for example).
m4_if([$1], [GCJ], [],
[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+ case $cc_basename in
+ cl*)
+ # MSVC
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='@lt_linker@'
+ ;;
+ esac
;;
hpux9* | hpux10* | hpux11*)
diff --git a/tests/flags.at b/tests/flags.at
index eceda74..cdf964c 100644
--- a/tests/flags.at
+++ b/tests/flags.at
@@ -77,6 +77,11 @@ case $archive_cmds in
*) maybe_wl=$wl ;;
esac
+# Linker flags passed in a variable w/o prefix flag.
+case $wl in
+...@lt_linker@) maybe_wl= ;;
+esac
+
for flag in -Wc, -Wl, '-Xcompiler ' '-Xlinker '; do
case $flag in
-Wc, | -Xcompiler\ )