Hi.

The patch is fix for Cygwin where we should not define 
HAVE_DOS_BASED_FILE_SYSTEM
and use back slashes as a path component separator.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
I'm going to install the patch if there are no objections.

Thanks,
Martin

ChangeLog:

2020-04-16  Martin Liska  <mli...@suse.cz>
            Jonathan Yong <10wa...@gmail.com>

        PR gcov-profile/94570
        * ltmain.sh: Do not define HAVE_DOS_BASED_FILE_SYSTEM
        for CYGWIN.

gcc/ChangeLog:

2020-04-16  Martin Liska  <mli...@suse.cz>
            Jonathan Yong <10wa...@gmail.com>

        PR gcov-profile/94570
        * coverage.c (coverage_init): Use separator properly.

include/ChangeLog:

2020-04-16  Martin Liska  <mli...@suse.cz>
            Jonathan Yong <10wa...@gmail.com>

        PR gcov-profile/94570
        * filenames.h (defined): Do not define HAVE_DOS_BASED_FILE_SYSTEM
        for CYGWIN.
---
 gcc/coverage.c      | 12 ++++++------
 include/filenames.h |  2 +-
 ltmain.sh           |  2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)


diff --git a/gcc/coverage.c b/gcc/coverage.c
index 30ae84df90f..30ac3540110 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -1199,6 +1199,11 @@ coverage_obj_finish (vec<constructor_elt, va_gc> *ctor)
 void
 coverage_init (const char *filename)
 {
+#if HAVE_DOS_BASED_FILE_SYSTEM
+  const char *separator = "\\";
+#else
+  const char *separator = "/";
+#endif
   int len = strlen (filename);
   int prefix_len = 0;
 
@@ -1215,11 +1220,6 @@ coverage_init (const char *filename)
 	 of filename in order to prevent file path clashing.  */
       if (profile_data_prefix)
 	{
-#if HAVE_DOS_BASED_FILE_SYSTEM
-	  const char *separator = "\\";
-#else
-	  const char *separator = "/";
-#endif
 	  filename = concat (getpwd (), separator, filename, NULL);
 	  filename = mangle_path (filename);
 	  len = strlen (filename);
@@ -1238,7 +1238,7 @@ coverage_init (const char *filename)
   if (profile_data_prefix)
     {
       memcpy (da_file_name, profile_data_prefix, prefix_len);
-      da_file_name[prefix_len++] = '/';
+      da_file_name[prefix_len++] = *separator;
     }
   memcpy (da_file_name + prefix_len, filename, len);
   strcpy (da_file_name + prefix_len + len, GCOV_DATA_SUFFIX);
diff --git a/include/filenames.h b/include/filenames.h
index 1ed441221ac..710d9c72687 100644
--- a/include/filenames.h
+++ b/include/filenames.h
@@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
 extern "C" {
 #endif
 
-#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__)
+#if defined(__MSDOS__) || (defined(_WIN32) && ! defined(__CYGWIN__)) || defined(__OS2__)
 #  ifndef HAVE_DOS_BASED_FILE_SYSTEM
 #    define HAVE_DOS_BASED_FILE_SYSTEM 1
 #  endif
diff --git a/ltmain.sh b/ltmain.sh
index 79f9ba89af5..8ad183010f0 100644
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -3425,7 +3425,7 @@ int setenv (const char *, const char *, int);
 # define PATH_SEPARATOR ':'
 #endif
 
-#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
+#if (defined (_WIN32) && ! defined(__CYGWIN__)) || defined (__MSDOS__) || defined (__DJGPP__) || \
   defined (__OS2__)
 # define HAVE_DOS_BASED_FILE_SYSTEM
 # define FOPEN_WB "wb"

Reply via email to