Re: [PATCH] Use darwin's -force_load flag if available for whole_archive_flag_spec

2009-09-06 Thread Peter O'Gorman


On Sep 6, 2009, at 12:29 PM, Ralf Wildenhues wrote:


Hi Peter,

* Peter O'Gorman wrote on Sun, Sep 06, 2009 at 05:28:52PM CEST:

Well, Mac OS X 10.6 has been released, and its linker now has support
for an option similar to --whole-archive. -force_load libfoo.a will  
load
all members of libfoo.a into the output. -force_load  can be  
given

multiple times on the command line.

This patch (and a test case that checks that gdb can find the  
debugging

symbols) makes libtool use this new option.


I think this is ok, with nits below addressed.  Did you run the
testsuite with it, esp. the tests in convenience.at?


Of course :)



Any reason to go with a compile test rather than a simple system  
version

test?


Yes, the compile test will work when cross-compiling to darwin using  
the odcctools that I released last month (which includes the - 
force_load option).


This is that patch that I pushed.

Thank you.

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


0001-Use-darwin-s-force_load-flag-if-available-for-whole.patch
Description: Binary data




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: unattended testing on w32

2009-09-06 Thread Ralf Wildenhues
* Ralf Wildenhues wrote on Sun, Aug 23, 2009 at 07:33:41AM CEST:
> Testsuite keyword 'interactive' and check-* rules.
> 
> * Makefile.am (testsuite_deps, testsuite_deps_uninstalled):
> New variables.
> (check-local, installcheck-local): Use them.
> (check-interactive, check-noninteractive): New rules.
> * tests/link-order2.at (Link order of deplibs),
> tests/static.at (static linking flags for programs): Add keyword
> `interactive'.
> * doc/libtool.texi (Test descriptions): Document all keywords
> used in the Libtool test suite.
> * NEWS: Update.

Nobody complained about this, so I pushed it now.

Cheers,
Ralf




Re: [PATCH] Use darwin's -force_load flag if available for whole_archive_flag_spec

2009-09-06 Thread Ralf Wildenhues
Hi Peter,

* Peter O'Gorman wrote on Sun, Sep 06, 2009 at 05:28:52PM CEST:
> Well, Mac OS X 10.6 has been released, and its linker now has support
> for an option similar to --whole-archive. -force_load libfoo.a will load
> all members of libfoo.a into the output. -force_load  can be given
> multiple times on the command line.
> 
> This patch (and a test case that checks that gdb can find the debugging
> symbols) makes libtool use this new option.

I think this is ok, with nits below addressed.  Did you run the
testsuite with it, esp. the tests in convenience.at?

Any reason to go with a compile test rather than a simple system version
test?

Thanks!
Ralf

> 2009-09-06  Peter O'Gorman  
> 
>   Use darwin's -force_load flag if available for whole_archive_flag_spec
>   * libltdl/m4/libtool.m4 (_LT_REQUIRED_DARWIN_CHECKS): Check for
>   -force_load and use it if there.
>   * tests/darwin.at: Add a simple test.


> --- a/tests/darwin.at
> +++ b/tests/darwin.at
> @@ -148,3 +148,56 @@ AT_CHECK([$LIBTOOL --dry-run --mode=link $CC $CFLAGS 
> $LDFLAGS ]dnl
>  AT_CHECK([grep stamp $lockfile], [], [ignore])
>  
>  AT_CLEANUP
> +
> +AT_SETUP([darwin gdb debug information])

There is nothing Darwin-specific in this particular test (which is
good!), besides maybe this part:

> +AT_XFAIL_IF([
> +case `$LIBTOOL --config | grep whole_archive_flag_spec=` in
> +*-force_load*)  false ;;
> +*) : ;;
> +esac ])
> +
> +# Remove any dSYM bundle
> +rm -rf .libs/*.dSYM

The XFAIL should be limited to darwin systems only; I get an XPASS for
this on GNU/Linux x86.  For a truly portable test you should probably
skip if 'gdb --version' doesn't work as expected (e.g., gdb isn't
installed), though.

> +AT_CHECK([echo quit | $LIBTOOL --mode=execute gdb main 2>err2],
> +  [ignore], [ignore], [ignore])

Please do not redirect 2> here, but instead put 'stderr' in the fourth
argument, instead of 'ignore'.  Then you can grep the 'stderr' file in
the next check:

> +AT_CHECK([grep 'Could not find object file' err2],[1],[ignore],[ignore])

There was another instance of this issue earlier in the test.




[PATCH] Use darwin's -force_load flag if available for whole_archive_flag_spec

2009-09-06 Thread Peter O'Gorman
Hi,

Well, Mac OS X 10.6 has been released, and its linker now has support
for an option similar to --whole-archive. -force_load libfoo.a will load
all members of libfoo.a into the output. -force_load  can be given
multiple times on the command line.

This patch (and a test case that checks that gdb can find the debugging
symbols) makes libtool use this new option.

Ok?


2009-09-06  Peter O'Gorman  

Use darwin's -force_load flag if available for whole_archive_flag_spec
* libltdl/m4/libtool.m4 (_LT_REQUIRED_DARWIN_CHECKS): Check for
-force_load and use it if there.
* tests/darwin.at: Add a simple test.

Peter
-- 
Peter O'Gorman
http://pogma.com
>From b1b56b0c0678d4c4e7b25c155d53145ca579effc Mon Sep 17 00:00:00 2001
From: Peter O'Gorman 
Date: Sun, 6 Sep 2009 09:59:19 -0500
Subject: [PATCH] Use darwin's -force_load flag if available for whole_archive_flag_spec

libltdl/m4/libtool.m4 (_LT_REQUIRED_DARWIN_CHECKS): Check for
-force_load and use it if there.
tests/darwin.at: Add a simple test.
---
 libltdl/m4/libtool.m4 |   31 ++-
 tests/darwin.at   |   53 +
 2 files changed, 82 insertions(+), 2 deletions(-)

diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4
index b081f7b..48f7993 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -971,6 +971,29 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
 	[lt_cv_ld_exported_symbols_list=no])
 	LDFLAGS="$save_LDFLAGS"
 ])
+AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load],
+  [lt_cv_ld_force_load=no
+  cat > conftest.c << _LT_EOF
+int forced_loaded() { return 2;}
+_LT_EOF
+  echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD
+  $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD
+  echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD
+  $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD
+  cat > conftest.c << _LT_EOF
+int main() { return 0;}
+_LT_EOF
+  echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD
+  $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
+  _lt_result=$?
+  if test -f conftest && test ! -s conftest.err && test $_lt_result = 0 && $GREP forced_load conftest 2>&1 >/dev/null; then
+	lt_cv_ld_force_load=yes
+  else
+	cat conftest.err >&AS_MESSAGE_LOG_FD
+  fi
+rm -f conftest.err conftest.a conftest conftest.c
+rm -rf conftest.dSYM
+])
 case $host_os in
 rhapsody* | darwin1.[[012]])
   _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
@@ -998,7 +1021,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
 else
   _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
 fi
-if test "$DSYMUTIL" != ":"; then
+if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
   _lt_dsymutil='~$DSYMUTIL $lib || :'
 else
   _lt_dsymutil=
@@ -1018,7 +1041,11 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES],
   _LT_TAGVAR(hardcode_direct, $1)=no
   _LT_TAGVAR(hardcode_automatic, $1)=yes
   _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
-  _LT_TAGVAR(whole_archive_flag_spec, $1)=''
+  if test "$lt_cv_ld_force_load" = "yes"; then
+_LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+  else
+_LT_TAGVAR(whole_archive_flag_spec, $1)=''
+  fi
   _LT_TAGVAR(link_all_deplibs, $1)=yes
   _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
   case $cc_basename in
diff --git a/tests/darwin.at b/tests/darwin.at
index 8884fd2..fe442f7 100644
--- a/tests/darwin.at
+++ b/tests/darwin.at
@@ -148,3 +148,56 @@ AT_CHECK([$LIBTOOL --dry-run --mode=link $CC $CFLAGS $LDFLAGS ]dnl
 AT_CHECK([grep stamp $lockfile], [], [ignore])

 AT_CLEANUP
+
+AT_SETUP([darwin gdb debug information])
+
+AT_DATA([foo.c], [[
+int foo (void) { return 0; }
+]])
+
+AT_DATA([bar.c], [[
+extern int foo (void);
+int bar (void) { return foo (); }
+]])
+
+AT_DATA([main.c], [[
+extern int bar(void);
+
+int main() { return bar();}
+]])
+
+AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c bar.c],
+	 [], [ignore], [ignore])
+AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c foo.c],
+	 [], [ignore], [ignore])
+AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c main.c],
+	 [], [ignore], [ignore])
+
+AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o libfoo.la foo.lo],
+	 [], [ignore], [ignore])
+
+AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS ]dnl
+	 [  -o libbar.la bar.lo -rpath /foo libfoo.la ],
+	 [], [ignore], [ignore])
+
+AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS ]dnl
+	 [  -o main main.lo libbar.la],[], [ignore], [ignore])
+AT_CHECK([echo quit | $LIBTOOL --mode=execu

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])
+