[Top][All Lists]

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

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

From: Peter Rosin
Subject: Re: Make -Wc,foo behave like -Xcompiler foo in link mode.
Date: Mon, 07 Sep 2009 09:33:09 +0200
User-agent: Thunderbird (Windows/20090812)

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 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


    Add testsuite exposure for passing of compiler and linker flags.
* tests/ (passing flags through libtool): New file, new
    test, for bug fixed in previous commit.
    * (TESTSUITE_AT): Add tests/

diff --git a/ b/
index a18955e..e22fcc2 100644
--- a/
+++ b/
@@ -455,6 +455,7 @@ TESTSUITE_AT        = tests/ \
                  tests/ \
                  tests/ \
                  tests/ \
+                 tests/ \
                  tests/ \
                  tests/ \
                  tests/ \
diff --git a/tests/ b/tests/
new file mode 100644
index 0000000..3de1fcb
--- /dev/null
+++ b/tests/
@@ -0,0 +1,96 @@
+# -- 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
+# 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,
+# 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])
+LDFLAGS="$LDFLAGS -no-undefined"
+eval "`$LIBTOOL --config | $EGREP '^(FGREP)='`"
+[[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 :-)

+[[      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=' " -module -avoid-version"'
+  library_and_module=

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 ;;
+  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 

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 $output a.lo -rpath /nowhere $flag-foo], [], [stdout], 
+      AT_CHECK([$FGREP " $flag_prefix-foo" stdout], [], [ignore])
+    done
+  done

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

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/ $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?


reply via email to

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