automake-patches
[Top][All Lists]
Advanced

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

FYI: depcomp mode for icc


From: Alexandre Duret-Lutz
Subject: FYI: depcomp mode for icc
Date: Tue, 11 Feb 2003 19:20:28 +0100
User-agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i386-pc-linux-gnu)

I'm installing this on HEAD and branch-1-7.  This adds a
dependency mode for icc.


ICC ignores any flags it doesn't understand (it just prints
warnings).  I guess that is meant to ease its use in existing
projects (call this optimistic compatibility if you prefer).

Because ICC doesn't choke on unknown options, Automake 1.7.2
thinks ICC understands GCC's options and use its `gcc3' mode for
dependency tracking.  The user then get many `ignored option'
warnings during compilation, and - worse - the output dependencies 
are wrong.

With only the depend.m4 change, the selected dependency tracking
mode becomes `tru64'.  This is wrong too, because ICC's -MD flag
doesn't respect subdirectories (when computing dependency
filenames) as Tru64 cc does.

So we really need just another mode, and a mode which must be
checked before `tru64'.  To be sure that the `tru64' mode isn't
hidden by `icc', I have verified (on the command line, not in a
real project), that OSF1 cc will not work with `-MD -MF
conftest.Tpo'.  In fact OSF1 cc accepts these options silently,
but doesn't create conftest.Tpo, so this looks safe.

2003-02-11  Alexandre Duret-Lutz  <address@hidden>

        * m4/depend.m4: Grep depcomp's stderr for icc warnings about
        ignored options.
        * lib/depcomp (icc): New mode.
        * tests/depcomp5.test: New file.
        * tests/defs.in: Handle required=icc.
        * tests/Makefile.am (TESTS): Add it.

Index: NEWS
===================================================================
RCS file: /cvs/automake/automake/NEWS,v
retrieving revision 1.198.2.22
diff -u -r1.198.2.22 NEWS
--- NEWS        11 Feb 2003 13:30:45 -0000      1.198.2.22
+++ NEWS        11 Feb 2003 18:18:05 -0000
@@ -14,10 +14,11 @@
 * Fix some incompatibilities with upcoming perl-5.10.
 * Properly quote AC_PACKAGE_TARNAME and AC_PACKAGE_VERSION when defining
   PACKAGE and VERSION.
-* depcomp fixes (PR/385):
+* depcomp fixes:
   - dashmstdout and dashXmstdout modes: don't use `-o /dev/null', this
-    is troublesome with gcc and Solaris compilers.
-  - makedepend mode: work with Libtool.
+    is troublesome with gcc and Solaris compilers. (PR/385)
+  - makedepend mode: work with Libtool. (PR/385 too)
+  - support for ICC.
 * Flag missing po/ and intl/ directories as warnings, not errors. (PR/381)
 * Noteworthy manual updates:
   - New FAQ chapter.
Index: lib/depcomp
===================================================================
RCS file: /cvs/automake/automake/lib/depcomp,v
retrieving revision 1.35.2.2
diff -u -r1.35.2.2 depcomp
--- lib/depcomp 10 Feb 2003 22:16:50 -0000      1.35.2.2
+++ lib/depcomp 11 Feb 2003 18:18:06 -0000
@@ -206,6 +206,35 @@
   rm -f "$tmpdepfile"
   ;;
 
+icc) # Must come before tru64.
+
+  # Intel's C compiler understands `-MD -MF file'.  However
+  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+  # will fill foo.d with something like
+  #    foo.o: sub/foo.c
+  #    foo.o: sub/foo.h
+  # which is wrong.  We want:
+  #    sub/foo.o: sub/foo.c
+  #    sub/foo.o: sub/foo.h
+  #    sub/foo.c:
+  #    sub/foo.h:
+
+  "$@" -MD -MF "$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  # Each line is of the form `foo.o: dependent.h'.
+  # Do two passes, one to just change these to
+  # `$object: dependent.h' and one to simply `dependent.h:'.
+  sed -e "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+  sed -e "s,^[^:]*: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
 tru64)
    # The Tru64 compiler uses -MD to generate dependencies as a side
    # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
Index: m4/depend.m4
===================================================================
RCS file: /cvs/automake/automake/m4/depend.m4,v
retrieving revision 1.26.2.2
diff -u -r1.26.2.2 depend.m4
--- m4/depend.m4        13 Jan 2003 14:06:04 -0000      1.26.2.2
+++ m4/depend.m4        11 Feb 2003 18:18:06 -0000
@@ -92,11 +92,17 @@
     if depmode=$depmode \
        source=conftest.c object=conftest.o \
        depfile=conftest.Po tmpdepfile=conftest.TPo \
-       $SHELL ./depcomp $depcc -c -o conftest.o conftest.c >/dev/null 2>&1 &&
+       $SHELL ./depcomp $depcc -c -o conftest.o conftest.c \
+         >/dev/null 2>conftest.err &&
        grep conftest.h conftest.Po > /dev/null 2>&1 &&
        ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
-      am_cv_$1_dependencies_compiler_type=$depmode
-      break
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored.
+      if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else
+        am_cv_$1_dependencies_compiler_type=$depmode
+        break
+      fi
     fi
   done
 
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.443.2.18
diff -u -r1.443.2.18 Makefile.am
--- tests/Makefile.am   10 Feb 2003 22:16:50 -0000      1.443.2.18
+++ tests/Makefile.am   11 Feb 2003 18:18:06 -0000
@@ -137,6 +137,7 @@
 depcomp2.test \
 depcomp3.test \
 depcomp4.test \
+depcomp5.test \
 depdist.test \
 depend.test \
 depend2.test \
Index: tests/defs.in
===================================================================
RCS file: /cvs/automake/automake/tests/defs.in,v
retrieving revision 1.4.2.5
diff -u -r1.4.2.5 defs.in
--- tests/defs.in       10 Jan 2003 19:30:50 -0000      1.4.2.5
+++ tests/defs.in       11 Feb 2003 18:18:07 -0000
@@ -92,6 +92,16 @@
        echo "$me: running $CXX --version"
        ( $CXX --version ) || exit 77
        ;;
+      icc)
+        CC=icc
+       export CC
+       # There is no way to ask *only* the compiler's version.
+       # This tool always want to do something (by default
+       # it will try link *nothing* and complain it cannot find
+       # main(); funny).  -dryrun is a workaround.
+       echo "$me: running $CC -V -dryrun"
+       ( $CC -V -dryrun ) || exit 77
+       ;;
       non-root)
        # Skip this test case if the user is root.
        # We try to append to a read-only file to detect this.
Index: tests/depcomp5.test
===================================================================
RCS file: tests/depcomp5.test
diff -N tests/depcomp5.test
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ tests/depcomp5.test 11 Feb 2003 18:18:07 -0000
@@ -0,0 +1,64 @@
+#! /bin/sh
+# Copyright (C) 2003  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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, or (at your option)
+# any later version.
+#
+# GNU Automake 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 Automake; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Check icc's dependency mode.
+
+required='icc'
+. ./defs || exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+check_PROGRAMS = prg
+prg_SOURCES = src/sub.c src/foo.h
+
+grepdeps:
+       grep 'src/sub.$(OBJEXT).*:' src/$(DEPDIR)/sub.Po
+
+END
+
+mkdir src
+
+touch src/foo.h
+
+cat >src/sub.c <<EOF
+#include "foo.h"
+int
+main ()
+{
+   return 0;
+}
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+grep 'depmode=icc' Makefile
+$MAKE check
+$MAKE grepdeps

-- 
Alexandre Duret-Lutz





reply via email to

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