libtool-patches
[Top][All Lists]
Advanced

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

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


From: Ralf Wildenhues
Subject: Re: Make -Wc,foo behave like -Xcompiler foo in link mode.
Date: Mon, 7 Sep 2009 21:09:47 +0200
User-agent: Mutt/1.5.20 (2009-08-09)

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  <address@hidden>

        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, USA.
 ####
 
-AT_SETUP([passing flags through libtool])
+m4_foreach([lt_tag], [CC, CXX, F77, FC, GCJ],
+[AT_SETUP([passing lt_tag flags through libtool])
 AT_KEYWORDS([libtool])
-AT_KEYWORDS([CXX F77 FC])
+LT_AT_TAG([lt_tag])
 
 LDFLAGS="$LDFLAGS -no-undefined"
 eval "`$LIBTOOL --config | $EGREP '^(FGREP)='`"
 
-AT_DATA([a.c],
+m4_case(lt_tag,
+[CC], [AT_DATA([a.c],
 [[int main () { return 0; }
 ]])
-
-AT_DATA([a.f],
+compile="$CC $CPPFLAGS $CFLAGS" link="$CC $CFLAGS $LDFLAGS" source=a.c
+],
+[CXX], [AT_DATA([a.cpp],
+[[int main () { return 0; }
+]])
+compile="$CXX $CPPFLAGS $CXXFLAGS" link="$CXX $CXXFLAGS $LDFLAGS" source=a.cpp
+],
+[F77], [AT_DATA([a.f],
 [[      program main
       end
 ]])
-
-cp a.c a.cpp
-cp a.f a.f90
+compile="$F77 $FFLAGS" link="$F77 $FFLAGS $LDFLAGS" source=a.f
+],
+[FC], [AT_DATA([a.f90],
+[[      program main
+      end
+]])
+compile="$FC $FCFLAGS" link="$FC $FCFLAGS $LDFLAGS" source=a.f90
+],
+[GCJ], [AT_DATA([a.java],
+[[class a {}
+]])
+compile="$GCJ $GCJFLAGS" link="$GCJ $GCJFLAGS $LDFLAGS" source=a.java
+])
 
 # Linker flags are not passed to the archiver, so don't test static libraries.
 if $LIBTOOL --features | grep 'enable shared libraries'; then
@@ -47,50 +65,39 @@ 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=lt_tag --config | $EGREP 
'^(wl|archive_cmds|reload_cmds)='`"
 
-  eval "`$LIBTOOL --tag=$tag --config | $EGREP 
'^(wl|archive_cmds|reload_cmds)='`"
+AT_CHECK([$LIBTOOL --tag=lt_tag --mode=compile $compile -c $source],
+        [], [ignore], [ignore])
 
-  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
 
-  # 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 ;;
+for flag in -Wc, -Wl, '-Xcompiler ' '-Xlinker '; do
+  case $flag in
+  -Wc, | -Xcompiler\ )
+    AT_CHECK([$LIBTOOL -n --tag=lt_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
 
-  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])
-      AT_CHECK([$FGREP " $flag_prefix-foo" stdout], [], [ignore])
-    done
+  eval set program$EXEEXT "$library_and_module"
+  for output
+  do
+    AT_CHECK([$LIBTOOL -n --tag=lt_tag --mode=link $link ]dnl
+            [-o $output a.lo -rpath /nowhere $flag-foo], [], [stdout], 
[ignore])
+    AT_CHECK([$FGREP " $flag_prefix-foo" stdout], [], [ignore])
   done
 done
 
 AT_CLEANUP
+])dnl m4_foreach(tag)




reply via email to

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