pr 61889 - support gcov-tool without ftw.h
diff mbox

Message ID 1422621813-11997-1-git-send-email-tbsaunde+gcc@tbsaunde.org
State New
Headers show

Commit Message

tbsaunde+gcc@tbsaunde.org Jan. 30, 2015, 12:43 p.m. UTC
From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

Hi,

given the glibc man page claims this is in POSIX.1-2001 and SUv1, and none of
the people testing on normally odd systems other than mingw have complained it
doesn't seem terribly likely there's many other hosts where this is an issue,
so I just did the minimal thing of not supporting clearing gcda files if the
host doesn't provide ftw.h.  Besides people can remove the gcda files
themselves easily enough.

bootstrapped on x86_64-unknown-linux-gnu, and checked compile / .ii files for
both HAVE_FTW_H defined to 0 and 1, ok?

Trev


	gcc/

	PR gcov-profile/61889
	* config.in: regenerate.
	* auto-host.h: Likewise.
	* configure.ac: Check for ftw.h.
	* gcov-tool.c: Check for ftw.h before using nftw.

Patch
diff mbox

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f35e3c7..bb1ef0b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@ 
+2015-01-29  Trevor Saunders  <tsaunders@mozilla.com>
+
+	PR gcov-profile/61889
+	* config.in: regenerate.
+	* auto-host.h: Likewise.
+	* configure.ac: Check for ftw.h.
+	* gcov-tool.c: Check for ftw.h before using nftw.
+
 2015-01-25  Allan Sandfeld Jensen  <sandfeld@kde.org>
 	    Uros Bizjak  <ubizjak@gmail.com>
 
diff --git a/gcc/config.in b/gcc/config.in
index f34adb5..7bde5b1 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -1098,6 +1098,12 @@ 
 #endif
 
 
+/* Define to 1 if you have the <ftw.h> header file. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_FTW_H
+#endif
+
+
 /* Define to 1 if you have the `fwrite_unlocked' function. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_FWRITE_UNLOCKED
diff --git a/gcc/configure b/gcc/configure
index 1bf4358..1a35d5a 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -8448,7 +8448,7 @@  $as_echo "#define GWINSZ_IN_SYS_IOCTL 1" >>confdefs.h
 fi
 
 for ac_header in limits.h stddef.h string.h strings.h stdlib.h time.h iconv.h \
-		 fcntl.h unistd.h sys/file.h sys/time.h sys/mman.h \
+		 fcntl.h ftw.h unistd.h sys/file.h sys/time.h sys/mman.h \
 		 sys/resource.h sys/param.h sys/times.h sys/stat.h \
 		 direct.h malloc.h langinfo.h ldfcn.h locale.h wchar.h
 do :
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 102dab9..a553a65 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1028,7 +1028,7 @@  ACX_HEADER_STRING
 AC_HEADER_SYS_WAIT
 AC_HEADER_TIOCGWINSZ
 AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h iconv.h \
-		 fcntl.h unistd.h sys/file.h sys/time.h sys/mman.h \
+		 fcntl.h ftw.h unistd.h sys/file.h sys/time.h sys/mman.h \
 		 sys/resource.h sys/param.h sys/times.h sys/stat.h \
 		 direct.h malloc.h langinfo.h ldfcn.h locale.h wchar.h)
 
diff --git a/gcc/gcov-tool.c b/gcc/gcov-tool.c
index 7de175f..36234d8 100644
--- a/gcc/gcov-tool.c
+++ b/gcc/gcov-tool.c
@@ -35,7 +35,9 @@  see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #include <stdio.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#if HAVE_FTW_H
 #include <ftw.h>
+#endif
 #include <getopt.h>
 
 extern int gcov_profile_merge (struct gcov_info*, struct gcov_info*, int, int);
@@ -49,6 +51,8 @@  extern void gcov_set_verbose (void);
 /* Set to verbose output mode.  */
 static bool verbose;
 
+#if HAVE_FTW_H
+
 /* Remove file NAME if it has a gcda suffix. */
 
 static int
@@ -69,13 +73,18 @@  unlink_gcda_file (const char *name,
 
   return ret;
 }
+#endif
 
 /* Remove the gcda files in PATH recursively.  */
 
 static int
-unlink_profile_dir (const char *path)
+unlink_profile_dir (const char *path ATTRIBUTE_UNUSED)
 {
+#if HAVE_FTW_H
     return nftw(path, unlink_gcda_file, 64, FTW_DEPTH | FTW_PHYS);
+#else
+    return -1;
+#endif
 }
 
 /* Output GCOV_INFO lists PROFILE to directory OUT. Note that