Re: Make -Wc,foo behave like -Xcompiler foo in link mode.

2009-09-08 Thread Ralf Wildenhues
Hi Peter,

* Peter Rosin wrote on Tue, Sep 08, 2009 at 09:44:46AM CEST:
> Den 2009-09-07 21:09 skrev Ralf Wildenhues:
> >>>+  eval "`$LIBTOOL --tag=$tag --config | $EGREP 
> >>>'^(wl|archive_cmds|reload_cmds)='`"
> >>You are not using $reload_cmds anywhere.
> >
> >Indeed; I added it because I thought of running a reload command, until
> >I realized that it wouldn't contain these flags anyway.  Removing it.
> >Thanks.
> 
> Still there :-)

D'oh.  Save before sending.  Thanks for checking!

> >Yeah, stresstest is ugly to debug.  I always run with -v -x to get as
> >many clues as possible.  But if you'd like to add more markers, feel
> >free to.

> Adding -x really helps, thanks for the hint! But it isn't really
> optimal when all commands seem to originate from line 24. E.g.

> ../../tests/flags.at:24: { test -n "$CC" && test "X$CC" != Xno; } || (exit 77)
> ../../tests/flags.at:24: $LIBTOOL --tag=CC --mode=compile $compile -c $source
> ../../tests/flags.at:24: $LIBTOOL -n --tag=CC --mode=compile $compile
> $flag-foo -c $source
> ../../tests/flags.at:24: $FGREP " -foo" stdout

Ouch.  Hmm, that's due to the m4_foreach construct.  I don't know how to
fix that, short of expanding the test into one for each tag.  Maybe
something can be done upstream at the Autotest level about this.

> But the test isn't that long so not a major problem.

OK.  Anyway, the -x output shows variables expanded, that should help to
see what the particular command was about.

> >Does it pass for you?
> 
> Yes. gcc-3.4/cygwin-1.5 and msvc/msys are both ok. At least after I
> apply my "-Wc,"-patch, didn't have that originally on the msvc branch
> which threw me off track for a while... So, I can report that the test
> only seems to catch the original bug if $wl is non-empty. Probably
> good enough though...

Well, if $wl is empty, then it would seem to me that it doesn't really
matter on this particular system whether libtool prepends that to flags
or not.  You can't really expect the testsuite to expose a system-
specific bug on every other system.  We can try to make tests as widely
exposing as possible, but we shouldn't do so beyond reasonable effort.

My idea of the ideal Libtool test suite is to get as many semantics
covered as possible for the system and compiler combination at hand,
and then before a release do regression tests on as many systems and
with as many compilers as possible, to then be reasonably sure that
we don't regress.  I don't see another realistic way.

Of course, things like tests for Darwin-specific bugs, where the test
happens to be pretty much system-agnostic, can only help if run on all
systems.

BTW, you are free to merge from master to pr-msvc-support (after testing
that the merged tree still works as desired, of course) when you like.
That can only help.

Thanks,
Ralf




Re: Make -Wc,foo behave like -Xcompiler foo in link mode.

2009-09-08 Thread Peter Rosin

Den 2009-09-07 21:09 skrev Ralf Wildenhues:

+  eval "`$LIBTOOL --tag=$tag --config | $EGREP 
'^(wl|archive_cmds|reload_cmds)='`"

You are not using $reload_cmds anywhere.


Indeed; I added it because I thought of running a reload command, until
I realized that it wouldn't contain these flags anyway.  Removing it.
Thanks.


Still there :-)


[...]

+done
+  done
+done
+
+AT_CLEANUP

There needs to be some markers about what is being done when
there is a repetetive loop like this (48 times through the
innermost loop in the "worst case"). I remember hardship
trying to deduce exactly what failed when I had a failure
inside stresstest.at...


Yeah, stresstest is ugly to debug.  I always run with -v -x to get as
many clues as possible.  But if you'd like to add more markers, feel
free to.


An example: If the following line fails, the test as written
doesn't give too many hints as to what it's trying to do:

../../tests/flags.at:89: $LIBTOOL -n --tag=$tag --mode=link $link  
-o $output a.lo -rpath /nowhere $flag-foo

Maybe it's as simple as using LT_AT_CHECK instead of AT_CHECK?


Well, the following already splits it up into four tests with 12
commands each.  Maybe that is enough to make it feasible?


Adding -x really helps, thanks for the hint! But it isn't really
optimal when all commands seem to originate from line 24. E.g.

../../tests/flags.at:24: { test -n "$CC" && test "X$CC" != Xno; } || (exit 77)
../../tests/flags.at:24: $LIBTOOL --tag=CC --mode=compile $compile -c $source
../../tests/flags.at:24: $LIBTOOL -n --tag=CC --mode=compile $compile
$flag-foo -c $source
../../tests/flags.at:24: $FGREP " -foo" stdout
../../tests/flags.at:24: $LIBTOOL -n --tag=CC --mode=link $link  -o 
$output a.lo -rpath /nowhere $flag-foo

But the test isn't that long so not a major problem.


Does it pass for you?


Yes. gcc-3.4/cygwin-1.5 and msvc/msys are both ok. At least after I
apply my "-Wc,"-patch, didn't have that originally on the msvc branch
which threw me off track for a while... So, I can report that the test
only seems to catch the original bug if $wl is non-empty. Probably
good enough though...

Cheers,
Peter




Re: Make -Wc,foo behave like -Xcompiler foo in link mode.

2009-09-07 Thread Ralf Wildenhues
* Peter Rosin wrote on Sun, Sep 06, 2009 at 07:57:52PM CEST:
> Den 2009-09-06 11:44 skrev Ralf Wildenhues:
> >* Peter Rosin wrote on Fri, Sep 04, 2009 at 10:31:14PM CEST:
> >>If the test is going to be good enough on w32 I don't know. For gcc
> >>it should behave just as on any unix, so what's left is my msvc branch
> >>where -Wl, isn't supported ATM so I really can't say if the test has
> >>to be tweaked when/if I add that.
> >
> >Does the branch just pass through -Wl,-foo then, as -foo, or does it
> >just drop the flag?
> 
> -Wl, is simply stripped for msvc in the branch (wl=""). That's not right
> of course. I think collecting the linker options and feeding them via
> a response file is the way to go. -L options are currently fed with the
> LINK environment variable, but that could perhaps also be reworked to
> use the same response file...

Well, the test will probably need to be fixed for response files or
environment variables then.

Cheers,
Ralf




Re: Make -Wc,foo behave like -Xcompiler foo in link mode.

2009-09-07 Thread Ralf Wildenhues
Hello Peters,

* Peter O'Gorman wrote on Mon, Sep 07, 2009 at 05:35:33AM CEST:
> On Sep 6, 2009, at 2:44 AM, Ralf Wildenhues wrote:
> >+for tag in CC CXX F77 FC; do
> >+  if $LIBTOOL --tag=$tag 2>&1 | grep 'unknown tag'; then
> >+continue
> >+  fi

> I get test failures for this test on a darwin system with no fortran
> compiler installed. The available tags in the libtool script that
> gets built always contains all tags:

Bummer.  I wasn't sure whether this was the case, and the system I
tested on has all compilers installed.  :-/

> Why available_tags has tags for compilers that don't exist, I do not
> remember, but it looks like you need to check that the compiler
> exists (a.la LT_AT_TAG) in this test.

Yes, that sounds like a good idea.  However, I don't want the full test
to be skipped merely because one compiler is not installed, so I'm
splitting it up into one test per tag, similar to convenience.at.

* Peter Rosin wrote on Mon, Sep 07, 2009 at 09:33:09AM CEST:
> Den 2009-09-06 11:44 skrev Ralf Wildenhues:
> >--- /dev/null
> >+++ b/tests/flags.at

> >+AT_SETUP([passing flags through libtool])
> >+AT_KEYWORDS([libtool])
> >+AT_KEYWORDS([CXX F77 FC])
> >+
> >+LDFLAGS="$LDFLAGS -no-undefined"
> >+eval "`$LIBTOOL --config | $EGREP '^(FGREP)='`"
> >+
> >+AT_DATA([a.c],
> >+[[int main () { return 0; }
> >+]])
> 
> Maybe some platform will barf if you try to create a shared
> library that exports the symbol 'main'? Maybe we'll just find
> out when someone stumbles :-)

Thing is, this test doesn't ever link anything at all.  It only ever
really calls the compiler once, and then runs a bunch of 'libtool -n'
commands that merely show what would be done, but don't do it.  Then
it checks the output of that command for presence of the bogus flag
we passed.  So I think we're safe here.

> >+# Linker flags are not passed to the archiver, so don't test static 
> >libraries.
> >+if $LIBTOOL --features | grep 'enable shared libraries'; then
> >+  library_and_module='library.la "module.la -module -avoid-version"'
> >+else
> >+  library_and_module=
> >+fi
> 
> Is it possible to have shared libraries for some tags but not
> others? I honestly have no clue...

It might not work correctly in practice, but yes, in theory that is very
possible.  We support some Fortran compilers that are not yet up to the
task of properly creating shared libraries.

> >+  case $tag in
> >+  CC) compile="$CC $CPPFLAGS $CFLAGS" link="$CC $CFLAGS $LDFLAGS" 
> >source=a.c ;;
> >+  CXX) compile="$CXX $CPPFLAGS $CXXFLAGS" link="$CXX $CXXFLAGS $LDFLAGS" 
> >source=a.cpp;;
> >+  F77) compile="$CC $CPPFLAGS $CFLAGS" link="$CC $CFLAGS $LDFLAGS" 
> >source=a.f ;;
> >+  FC) compile="$CC $CPPFLAGS $CFLAGS" link="$CC $CFLAGS $LDFLAGS" 
> >source=a.f90 ;;

Gaah, the last two lines were completely wrong.  :-(

> >+  esac
> >+
> >+  eval "`$LIBTOOL --tag=$tag --config | $EGREP 
> >'^(wl|archive_cmds|reload_cmds)='`"
> 
> You are not using $reload_cmds anywhere.

Indeed; I added it because I thought of running a reload command, until
I realized that it wouldn't contain these flags anyway.  Removing it.
Thanks.

[...]
> >+done
> >+  done
> >+done
> >+
> >+AT_CLEANUP
> 
> There needs to be some markers about what is being done when
> there is a repetetive loop like this (48 times through the
> innermost loop in the "worst case"). I remember hardship
> trying to deduce exactly what failed when I had a failure
> inside stresstest.at...

Yeah, stresstest is ugly to debug.  I always run with -v -x to get as
many clues as possible.  But if you'd like to add more markers, feel
free to.

> An example: If the following line fails, the test as written
> doesn't give too many hints as to what it's trying to do:
> 
> ../../tests/flags.at:89: $LIBTOOL -n --tag=$tag --mode=link $link 
>  -o $output a.lo -rpath /nowhere $flag-foo
> 
> Maybe it's as simple as using LT_AT_CHECK instead of AT_CHECK?

Well, the following already splits it up into four tests with 12
commands each.  Maybe that is enough to make it feasible?
Does it pass for you?

Thanks,
Ralf

2009-09-07  Ralf Wildenhues  

Fix and split recent testsuite addition for compile/link flags.
* tests/flags.at (passing flags through libtool): Split into ...
(passing CC flags through libtool)
(passing CXX flags through libtool)
(passing F77 flags through libtool)
(passing FC flags through libtool)
(passing GCJ flags through libtool): ... these five tests,
factorized with m4_foreach.  Fix F77 and FC compile and link
commands; add GCJ tag.  Use LT_AT_TAG to correctly skip tags
for which no compiler exists.  Use $EXEEXT where appropriate.
Drop unneeded use of reload_cmds.
Reports by Peter Rosin and Peter O'Gorman.

diff --git a/tests/flags.at b/tests/flags.at
index 3de1fcb..8965353 100644
--- a/tests/flags.at
+++ b/tests/flags.at
@@ -21,24 +21,42 @@
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 

Re: Make -Wc,foo behave like -Xcompiler foo in link mode.

2009-09-07 Thread Peter Rosin

Oops, one more thing:


+eval set program "$library_and_module"


I guess you can prevent a future patch from Roumen by changing
that to program$EXEEXT

Cheers,
Peter




Re: Make -Wc,foo behave like -Xcompiler foo in link mode.

2009-09-07 Thread Peter Rosin

Hi Ralf,

Den 2009-09-06 11:44 skrev Ralf Wildenhues:

Hi Peter,

* Peter Rosin wrote on Fri, Sep 04, 2009 at 10:31:14PM CEST:

Den 2009-09-04 19:44 skrev Ralf Wildenhues:

Further, the patch needs a testsuite addition, but I can do that later
if you don't want to.  I was thinking of a new set of tests flags.at and
running a bunch of
 libtool -n --mode=X ... $flag-foo

for $flag in -Wl, -Wc, '-Xcompiler ' and '-Xlinker ', both library and
program output, and grepping the output for ${wl}-foo and similar (I
don't remember whether that was general enough for all compilers, you
know w32 better).

Sigh, tests. I'd rather not, sorry. Maybe later, I hope someone
beats me to it though...


Proposed patch below.  Comments before I apply?


Thanks for letting me off the hook :-) Comments inline and below
patch...


Thanks,
Ralf

Add testsuite exposure for passing of compiler and linker flags.

* tests/flags.at (passing flags through libtool): New file, new

test, for bug fixed in previous commit.
* Makefile.am (TESTSUITE_AT): Add tests/flags.at.

diff --git a/Makefile.am b/Makefile.am
index a18955e..e22fcc2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -455,6 +455,7 @@ TESTSUITE_AT= tests/testsuite.at \
  tests/duplicate_members.at \
  tests/duplicate_conv.at \
  tests/duplicate_deps.at \
+ tests/flags.at \
  tests/inherited_flags.at \
  tests/convenience.at \
  tests/link-order.at \
diff --git a/tests/flags.at b/tests/flags.at
new file mode 100644
index 000..3de1fcb
--- /dev/null
+++ b/tests/flags.at
@@ -0,0 +1,96 @@
+# flags.at -- libtool passing of flags -*- Autotest -*-
+#
+#   Copyright (C) 2009 Free Software Foundation, Inc.
+#
+#   This file is part of GNU Libtool.
+#
+# GNU Libtool is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# GNU Libtool is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from  http://www.gnu.org/licenses/gpl.html,
+# or obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+
+AT_SETUP([passing flags through libtool])
+AT_KEYWORDS([libtool])
+AT_KEYWORDS([CXX F77 FC])
+
+LDFLAGS="$LDFLAGS -no-undefined"
+eval "`$LIBTOOL --config | $EGREP '^(FGREP)='`"
+
+AT_DATA([a.c],
+[[int main () { return 0; }
+]])



Maybe some platform will barf if you try to create a shared
library that exports the symbol 'main'? Maybe we'll just find
out when someone stumbles :-)



+
+AT_DATA([a.f],
+[[  program main
+  end
+]])
+
+cp a.c a.cpp
+cp a.f a.f90
+
+# Linker flags are not passed to the archiver, so don't test static libraries.
+if $LIBTOOL --features | grep 'enable shared libraries'; then
+  library_and_module='library.la "module.la -module -avoid-version"'
+else
+  library_and_module=
+fi



Is it possible to have shared libraries for some tags but not
others? I honestly have no clue...



+for tag in CC CXX F77 FC; do
+  if $LIBTOOL --tag=$tag 2>&1 | grep 'unknown tag'; then
+continue
+  fi
+  case $tag in
+  CC) compile="$CC $CPPFLAGS $CFLAGS" link="$CC $CFLAGS $LDFLAGS" source=a.c ;;
+  CXX) compile="$CXX $CPPFLAGS $CXXFLAGS" link="$CXX $CXXFLAGS $LDFLAGS" 
source=a.cpp;;
+  F77) compile="$CC $CPPFLAGS $CFLAGS" link="$CC $CFLAGS $LDFLAGS" source=a.f 
;;
+  FC) compile="$CC $CPPFLAGS $CFLAGS" link="$CC $CFLAGS $LDFLAGS" source=a.f90 
;;
+  esac
+
+  eval "`$LIBTOOL --tag=$tag --config | $EGREP 
'^(wl|archive_cmds|reload_cmds)='`"



You are not using $reload_cmds anywhere.



+
+  AT_CHECK([$LIBTOOL --tag=$tag --mode=compile $compile -c $source],
+  [], [ignore], [ignore])
+
+  # Linker flags are prefixed with ${wl} iff they are passed to the
+  # compiler driver, instead of directly to the linker.
+  case $archive_cmds in
+  *\$LD*\$linker_flags*) maybe_wl= ;;
+  *) maybe_wl=$wl ;;
+  esac
+
+  for flag in -Wc, -Wl, '-Xcompiler ' '-Xlinker '; do
+case $flag in
+-Wc, | -Xcompiler\ )
+  AT_CHECK([$LIBTOOL -n --tag=$tag --mode=compile $compile ]dnl
+  [$flag-foo -c $source], [], [stdout], [ignore])
+  AT_CHECK([$FGREP " -foo" stdout], [], [ignore])
+  flag_prefix=
+  ;;
+-Wl, | -Xlinker\ )
+  flag_prefix=$maybe_wl
+  ;;
+esac
+
+eval set program "$library_and_module"
+for output
+do
+  AT_CHECK([$LIBTOOL -n --tag=$tag --mode=link $link ]dnl
+  [-o $outpu

Re: Make -Wc,foo behave like -Xcompiler foo in link mode.

2009-09-06 Thread Peter O'Gorman


On Sep 6, 2009, at 2:44 AM, Ralf Wildenhues wrote:



   Add testsuite exposure for passing of compiler and linker flags.

   * tests/flags.at (passing flags through libtool): New file, new
   test, for bug fixed in previous commit.
   * Makefile.am (TESTSUITE_AT): Add tests/flags.at.

+
+for tag in CC CXX F77 FC; do
+  if $LIBTOOL --tag=$tag 2>&1 | grep 'unknown tag'; then
+continue
+  fi


Hi Ralf,

I get test failures for this test on a darwin system with no fortran  
compiler installed. The available tags in the libtool script that gets  
built always contains all tags:

# The names of the tagged configurations supported by this script.
available_tags="CXX F77 FC GCJ RC "

So the test fails with:
./flags.at:63: $LIBTOOL --tag=$tag --mode=compile $compile -c $source
stderr:
i686-apple-darwin9-gcc-4.0.1: a.f: Fortran compiler not installed on  
this system

stdout:
libtool: compile:  gcc -g -O2 -c a.f  -o .libs/a.o
./flags.at:63: exit code was 1, expected 0
20. flags.at:24: 20. passing flags through libtool (flags.at:24):  
FAILED (flags.

at:63)


Why available_tags has tags for compilers that don't exist, I do not  
remember, but it looks like you need to check that the compiler exists  
(a.la LT_AT_TAG) in this test.


Thanks,
Peter
--
Peter O'Gorman
http://pogma.com






Re: Make -Wc,foo behave like -Xcompiler foo in link mode.

2009-09-06 Thread Peter Rosin

Hi Ralf,

Den 2009-09-06 11:44 skrev Ralf Wildenhues:

* Peter Rosin wrote on Fri, Sep 04, 2009 at 10:31:14PM CEST:

If the test is going to be good enough on w32 I don't know. For gcc
it should behave just as on any unix, so what's left is my msvc branch
where -Wl, isn't supported ATM so I really can't say if the test has
to be tweaked when/if I add that.


Does the branch just pass through -Wl,-foo then, as -foo, or does it
just drop the flag?


-Wl, is simply stripped for msvc in the branch (wl=""). That's not right
of course. I think collecting the linker options and feeding them via
a response file is the way to go. -L options are currently fed with the
LINK environment variable, but that could perhaps also be reworked to
use the same response file...

I'll check flags.at later, short of time atm...

Cheers,
Peter




Re: Make -Wc,foo behave like -Xcompiler foo in link mode.

2009-09-06 Thread Ralf Wildenhues
Hi Peter,

* Peter Rosin wrote on Fri, Sep 04, 2009 at 10:31:14PM CEST:
> Den 2009-09-04 19:44 skrev Ralf Wildenhues:
> >Further, the patch needs a testsuite addition, but I can do that later
> >if you don't want to.  I was thinking of a new set of tests flags.at and
> >running a bunch of
> >  libtool -n --mode=X ... $flag-foo
> >
> >for $flag in -Wl, -Wc, '-Xcompiler ' and '-Xlinker ', both library and
> >program output, and grepping the output for ${wl}-foo and similar (I
> >don't remember whether that was general enough for all compilers, you
> >know w32 better).
> 
> Sigh, tests. I'd rather not, sorry. Maybe later, I hope someone
> beats me to it though...

Proposed patch below.  Comments before I apply?

> If the test is going to be good enough on w32 I don't know. For gcc
> it should behave just as on any unix, so what's left is my msvc branch
> where -Wl, isn't supported ATM so I really can't say if the test has
> to be tweaked when/if I add that.

Does the branch just pass through -Wl,-foo then, as -foo, or does it
just drop the flag?

Thanks,
Ralf

Add testsuite exposure for passing of compiler and linker flags.

* tests/flags.at (passing flags through libtool): New file, new
test, for bug fixed in previous commit.
* Makefile.am (TESTSUITE_AT): Add tests/flags.at.

diff --git a/Makefile.am b/Makefile.am
index a18955e..e22fcc2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -455,6 +455,7 @@ TESTSUITE_AT= tests/testsuite.at \
  tests/duplicate_members.at \
  tests/duplicate_conv.at \
  tests/duplicate_deps.at \
+ tests/flags.at \
  tests/inherited_flags.at \
  tests/convenience.at \
  tests/link-order.at \
diff --git a/tests/flags.at b/tests/flags.at
new file mode 100644
index 000..3de1fcb
--- /dev/null
+++ b/tests/flags.at
@@ -0,0 +1,96 @@
+# flags.at -- libtool passing of flags -*- Autotest -*-
+#
+#   Copyright (C) 2009 Free Software Foundation, Inc.
+#
+#   This file is part of GNU Libtool.
+#
+# GNU Libtool is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# GNU Libtool is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from  http://www.gnu.org/licenses/gpl.html,
+# or obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+
+AT_SETUP([passing flags through libtool])
+AT_KEYWORDS([libtool])
+AT_KEYWORDS([CXX F77 FC])
+
+LDFLAGS="$LDFLAGS -no-undefined"
+eval "`$LIBTOOL --config | $EGREP '^(FGREP)='`"
+
+AT_DATA([a.c],
+[[int main () { return 0; }
+]])
+
+AT_DATA([a.f],
+[[  program main
+  end
+]])
+
+cp a.c a.cpp
+cp a.f a.f90
+
+# Linker flags are not passed to the archiver, so don't test static libraries.
+if $LIBTOOL --features | grep 'enable shared libraries'; then
+  library_and_module='library.la "module.la -module -avoid-version"'
+else
+  library_and_module=
+fi
+
+for tag in CC CXX F77 FC; do
+  if $LIBTOOL --tag=$tag 2>&1 | grep 'unknown tag'; then
+continue
+  fi
+  case $tag in
+  CC) compile="$CC $CPPFLAGS $CFLAGS" link="$CC $CFLAGS $LDFLAGS" source=a.c ;;
+  CXX) compile="$CXX $CPPFLAGS $CXXFLAGS" link="$CXX $CXXFLAGS $LDFLAGS" 
source=a.cpp;;
+  F77) compile="$CC $CPPFLAGS $CFLAGS" link="$CC $CFLAGS $LDFLAGS" source=a.f 
;;
+  FC) compile="$CC $CPPFLAGS $CFLAGS" link="$CC $CFLAGS $LDFLAGS" source=a.f90 
;;
+  esac
+
+  eval "`$LIBTOOL --tag=$tag --config | $EGREP 
'^(wl|archive_cmds|reload_cmds)='`"
+
+  AT_CHECK([$LIBTOOL --tag=$tag --mode=compile $compile -c $source],
+  [], [ignore], [ignore])
+
+  # Linker flags are prefixed with ${wl} iff they are passed to the
+  # compiler driver, instead of directly to the linker.
+  case $archive_cmds in
+  *\$LD*\$linker_flags*) maybe_wl= ;;
+  *) maybe_wl=$wl ;;
+  esac
+
+  for flag in -Wc, -Wl, '-Xcompiler ' '-Xlinker '; do
+case $flag in
+-Wc, | -Xcompiler\ )
+  AT_CHECK([$LIBTOOL -n --tag=$tag --mode=compile $compile ]dnl
+  [$flag-foo -c $source], [], [stdout], [ignore])
+  AT_CHECK([$FGREP " -foo" stdout], [], [ignore])
+  flag_prefix=
+  ;;
+-Wl, | -Xlinker\ )
+  flag_prefix=$maybe_wl
+  ;;
+esac
+
+eval set program "$library_and_module"
+for output
+do
+  AT_CHECK([$LIBTOOL -n --tag=$tag --mode=link $link ]dnl
+  [-o $output a.lo -rpath /nowhere $flag-foo], [], [stdout], 
[ignore])
+ 

Re: Make -Wc,foo behave like -Xcompiler foo in link mode.

2009-09-05 Thread Peter Rosin

Den 2009-09-05 09:05 skrev Ralf Wildenhues:

* Peter Rosin wrote on Fri, Sep 04, 2009 at 10:31:14PM CEST:

Ok to commit this?


Yes, thanks.


Pushed. Thanks for reviewing!

Cheer,
Peter




Re: Make -Wc,foo behave like -Xcompiler foo in link mode.

2009-09-05 Thread Ralf Wildenhues
* Peter Rosin wrote on Fri, Sep 04, 2009 at 10:31:14PM CEST:
> Ok to commit this?

Yes, thanks.

Cheers,
Ralf

> 2009-09-04  Peter Rosin  
> 
>   Make -Wc,FLAG behave like -Xcompiler FLAG in link mode.
>   * libltdl/config/ltmain.m4sh (func_mode_link): Remove "-Wc,"
>   instead of replacing it with "$wl" when linking programs
>   through the compiler driver, just as is the case when linking
>   libraries.
>   * NEWS: Update.




Re: Make -Wc,foo behave like -Xcompiler foo in link mode.

2009-09-04 Thread Peter Rosin

Hi Ralf,

Den 2009-09-04 19:44 skrev Ralf Wildenhues:

Hello Peter,

* Peter Rosin wrote on Fri, Sep 04, 2009 at 12:38:48PM CEST:

Make -Wc,foo behave like -Xcompiler foo in link mode.
* libltdl/config/ltmain.m4sh (func_mode_link): Remove "-Wc,"
instead of replacing it with "$wl".


This patch is ok, but please state clearly that this affects linking
of programs only, not linking of libraries, and restores consistency
of the former with respect to the latter (not sure if this is a
regression).  Also, it needs a NEWS entry.


Ok, added more words and a NEWS entry. And the bug has been there since
the feature was added back in -99, if I read the history right...


Further, the patch needs a testsuite addition, but I can do that later
if you don't want to.  I was thinking of a new set of tests flags.at and
running a bunch of
  libtool -n --mode=X ... $flag-foo

for $flag in -Wl, -Wc, '-Xcompiler ' and '-Xlinker ', both library and
program output, and grepping the output for ${wl}-foo and similar (I
don't remember whether that was general enough for all compilers, you
know w32 better).


Sigh, tests. I'd rather not, sorry. Maybe later, I hope someone
beats me to it though...

If the test is going to be good enough on w32 I don't know. For gcc
it should behave just as on any unix, so what's left is my msvc branch
where -Wl, isn't supported ATM so I really can't say if the test has
to be tweaked when/if I add that.

Ok to commit this?

2009-09-04  Peter Rosin  

Make -Wc,FLAG behave like -Xcompiler FLAG in link mode.
* libltdl/config/ltmain.m4sh (func_mode_link): Remove "-Wc,"
instead of replacing it with "$wl" when linking programs
through the compiler driver, just as is the case when linking
libraries.
* NEWS: Update.


Cheers,
Peter
diff --git a/NEWS b/NEWS
index 15ed32b..d6a35aa 100644
--- a/NEWS
+++ b/NEWS
@@ -43,6 +43,9 @@ New in 2.2.8 2009-??-??: git version 2.2.7a, Libtool team:
 extraction of convenience archives with a lock.
   - The Libtool macro files do not contain instances of __oline__ any more,
 easing merges for configure scripts that are added to version control.
+  - Fix ancient bug where "-Wc," was turned into "$wl" (typically "-Wl,")
+when using the compiler driver to link programs. Now "-Wc," is stripped
+just as it is when linking libraries through the compiler driver.
 
 * Miscellaneous changes:
 
diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index 9e4cfdb..4633ff2 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -4299,7 +4299,7 @@ func_mode_link ()
for flag in $args; do
  IFS="$save_ifs"
   func_quote_for_eval "$flag"
- arg="$arg $wl$func_quote_for_eval_result"
+ arg="$arg $func_quote_for_eval_result"
  compiler_flags="$compiler_flags $func_quote_for_eval_result"
done
IFS="$save_ifs"


Re: Make -Wc,foo behave like -Xcompiler foo in link mode.

2009-09-04 Thread Ralf Wildenhues
Hello Peter,

* Peter Rosin wrote on Fri, Sep 04, 2009 at 12:38:48PM CEST:
>   Make -Wc,foo behave like -Xcompiler foo in link mode.
>   * libltdl/config/ltmain.m4sh (func_mode_link): Remove "-Wc,"
>   instead of replacing it with "$wl".

This patch is ok, but please state clearly that this affects linking
of programs only, not linking of libraries, and restores consistency
of the former with respect to the latter (not sure if this is a
regression).  Also, it needs a NEWS entry.

Further, the patch needs a testsuite addition, but I can do that later
if you don't want to.  I was thinking of a new set of tests flags.at and
running a bunch of
  libtool -n --mode=X ... $flag-foo

for $flag in -Wl, -Wc, '-Xcompiler ' and '-Xlinker ', both library and
program output, and grepping the output for ${wl}-foo and similar (I
don't remember whether that was general enough for all compilers, you
know w32 better).

Thanks,
Ralf




Make -Wc,foo behave like -Xcompiler foo in link mode.

2009-09-04 Thread Peter Rosin

Hello!

I noticed something that appears strange:

$ echo "int main(void) { return 0; }" > foo.c
$ ./libtool --tag=CC   --mode=compile gcc -o foo.lo -c foo.c
libtool: compile:  gcc -c foo.c  -DDLL_EXPORT -DPIC -o .libs/foo.o
libtool: compile:  gcc -c foo.c -o foo.o >/dev/null 2>&1
$ ./libtool --tag=CC   --mode=link gcc -o foo foo.lo
libtool: link: gcc -o .libs/foo .libs/foo.o

The above went fine, now try to pass a silly arg (-time) to gcc:

$ ./libtool --tag=CC   --mode=link gcc -time -o foo foo.lo
libtool: link: gcc -time -o .libs/foo .libs/foo.o

Fine, gcc didn't complain. So pass -time with -Xcompiler instead:

$ ./libtool --tag=CC   --mode=link gcc -Xcompiler -time -o foo foo.lo
libtool: link: gcc -time -o .libs/foo .libs/foo.o

As expected. So try to pass -time with -Wc, instead:

$ ./libtool --tag=CC   --mode=link gcc -Wc,-time -o foo foo.lo
libtool: link: gcc -Wl,-time -o .libs/foo .libs/foo.o
c:/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: bad 
-rpath option
collect2: ld returned 1 exit status

Crash boom bang. How did -Wl end up in there?

Excerpt from "./libtool --mode=link --help":

  -weak LIBNAME declare that the target provides the LIBNAME interface
  -Wc,FLAG
  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
  -Wl,FLAG
  -Xlinker FLAG pass linker-specific FLAG directly to the linker

I interpret that as: -Wc,FLAG is equivalent to -Xcompiler FLAG but
distinctly different from what -Wl,FLAG is doing in gcc.

So, proposing this patch:

2009-09-04  Peter Rosin  

    Make -Wc,foo behave like -Xcompiler foo in link mode.
* libltdl/config/ltmain.m4sh (func_mode_link): Remove "-Wc,"
instead of replacing it with "$wl".


Cheers,
Peter
diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index 9e4cfdb..4633ff2 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -4299,7 +4299,7 @@ func_mode_link ()
for flag in $args; do
  IFS="$save_ifs"
   func_quote_for_eval "$flag"
- arg="$arg $wl$func_quote_for_eval_result"
+ arg="$arg $func_quote_for_eval_result"
  compiler_flags="$compiler_flags $func_quote_for_eval_result"
done
IFS="$save_ifs"