diff mbox series

[2/2,d] PR d/87799 Fix build on windows hosts

Message ID 20190324110603.2508-1-johannespfau@gmail.com
State New
Headers show
Series [1/2,d] Merge latest upstream DMD | expand

Commit Message

Johannes Pfau March 24, 2019, 11:06 a.m. UTC
Merge with upstream DMD 74ac873be1862090b7ec0e4a876fd1b758520359.
This fixes various MinGW host build errors in filename.c.

Additionally provide _mkdir in d-system.h as we do not
include the windows 'direct.h' header.


gcc/d/ChangeLog:

2019-03-23  Johannes Pfau  <johannespfau@gmail.com>
	PR d/87799
	* d-system.h (_mkdir): Define to mkdir for MinGW hosts.
	* dmd/root/filename.c: Merge related dmd-cxx fixes.

---
 gcc/d/d-system.h          | 6 ++++++
 gcc/d/dmd/MERGE           | 2 +-
 gcc/d/dmd/root/filename.c | 7 ++++---
 3 files changed, 11 insertions(+), 4 deletions(-)

Comments

Iain Buclaw March 24, 2019, 4:49 p.m. UTC | #1
On Sun, 24 Mar 2019 at 12:06, Johannes Pfau <johannespfau@gmail.com> wrote:
>
> Merge with upstream DMD 74ac873be1862090b7ec0e4a876fd1b758520359.
> This fixes various MinGW host build errors in filename.c.
>
> Additionally provide _mkdir in d-system.h as we do not
> include the windows 'direct.h' header.
>

I've done the front-end merge, leaving just the following.

> diff --git a/gcc/d/d-system.h b/gcc/d/d-system.h
> index efece15f3bc..6c18b69d4df 100644
> --- a/gcc/d/d-system.h
> +++ b/gcc/d/d-system.h
> @@ -55,4 +55,10 @@
>  #undef tolower
>  #define tolower(c) TOLOWER(c)
>
> +/* We do not include direct.h as it conflicts with system.h.  */
> +#ifdef _WIN32
> +#undef _mkdir
> +#define _mkdir(p) mkdir(p, 0)
> +#endif
> +

Does this mean that we can remove MinGW from the special casing in the
toplevel configure?  See r265658.

Iain.
Johannes Pfau March 25, 2019, 7:04 p.m. UTC | #2
Am 24.03.19 um 17:49 schrieb Iain Buclaw:
> 
> I've done the front-end merge, leaving just the following.
> 
>> diff --git a/gcc/d/d-system.h b/gcc/d/d-system.h
>> index efece15f3bc..6c18b69d4df 100644
>> --- a/gcc/d/d-system.h
>> +++ b/gcc/d/d-system.h
>> @@ -55,4 +55,10 @@
>>   #undef tolower
>>   #define tolower(c) TOLOWER(c)
>>
>> +/* We do not include direct.h as it conflicts with system.h.  */
>> +#ifdef _WIN32
>> +#undef _mkdir
>> +#define _mkdir(p) mkdir(p, 0)
>> +#endif
>> +
> 
> Does this mean that we can remove MinGW from the special casing in the
> toplevel configure?  See r265658.
> 
> Iain.
> 

Thanks. I think we can indeed remove the special case in configure, new 
patch attached. I'm not sure about cygwin though and I don't have a 
build setup for cygwin either.

I will however bootstrap this on MinGW again, just to be sure.
Please note that these fixes are for MinGW hosts though, whereas the 
check in configure checked for MinGW targets. I'm not aware of any build 
issues affecting MinGW targets though and the MinGW bootstrap will check 
both cases anyway.

Regards,
Johannes
From 6b54d601ee5810260ba3e5e5134783a2f107ff36 Mon Sep 17 00:00:00 2001
From: Johannes Pfau <johannespfau@gmail.com>
Date: Sun, 24 Mar 2019 11:57:51 +0100
Subject: [PATCH] PR d/87799 Fix build on windows hosts

Provide _mkdir in d-system.h as we do not include the windows 'direct.h'
header. Fixes build for windows hosts.

gcc/d/ChangeLog:

2019-03-23  Johannes Pfau  <johannespfau@gmail.com>
	PR d/87799
	* d-system.h (_mkdir): Define to mkdir for MinGW hosts.

2019-03-25  Johannes Pfau  <johannespfau@gmail.com>

	* configure: Rebuild.
	* configure.ac: Mark D on MinGW as supported.
---
 configure        | 2 +-
 configure.ac     | 2 +-
 gcc/d/d-system.h | 6 ++++++
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index adf4fda0f69..325ea76ccee 100755
--- a/configure
+++ b/configure
@@ -3395,7 +3395,7 @@ case ,${enable_languages}, in
     ;;
   *)
     case "${target}" in
-      *-*-darwin* | *-*-cygwin* | *-*-mingw*)
+      *-*-darwin* | *-*-cygwin*)
 	unsupported_languages="$unsupported_languages d"
 	;;
     esac
diff --git a/configure.ac b/configure.ac
index 87f2aee0500..6e29ded6106 100644
--- a/configure.ac
+++ b/configure.ac
@@ -680,7 +680,7 @@ case ,${enable_languages}, in
     ;;
   *)
     case "${target}" in
-      *-*-darwin* | *-*-cygwin* | *-*-mingw*)
+      *-*-darwin* | *-*-cygwin*)
 	unsupported_languages="$unsupported_languages d"
 	;;
     esac
diff --git a/gcc/d/d-system.h b/gcc/d/d-system.h
index efece15f3bc..6c18b69d4df 100644
--- a/gcc/d/d-system.h
+++ b/gcc/d/d-system.h
@@ -55,4 +55,10 @@
 #undef tolower
 #define tolower(c) TOLOWER(c)
 
+/* We do not include direct.h as it conflicts with system.h.  */
+#ifdef _WIN32
+#undef _mkdir
+#define _mkdir(p) mkdir(p, 0)
+#endif
+
 #endif  /* GCC_D_SYSTEM_H  */
Johannes Pfau March 25, 2019, 10:11 p.m. UTC | #3
Am 25.03.19 um 20:04 schrieb Johannes Pfau:
> Am 24.03.19 um 17:49 schrieb Iain Buclaw:
>>
>> Does this mean that we can remove MinGW from the special casing in the
>> toplevel configure?  See r265658.
>>
> I will however bootstrap this on MinGW again, just to be sure.

Bootstrapped properly on x86_64 mingw-w64 host/target (seh build). So I 
think we can really remove that check.

Regards,
Johannes
Iain Buclaw April 13, 2019, 4:48 p.m. UTC | #4
On Mon, 25 Mar 2019 at 20:04, Johannes Pfau <johannespfau@gmail.com> wrote:
>
> diff --git a/gcc/d/d-system.h b/gcc/d/d-system.h
> index efece15f3bc..6c18b69d4df 100644
> --- a/gcc/d/d-system.h
> +++ b/gcc/d/d-system.h
> @@ -55,4 +55,10 @@
>  #undef tolower
>  #define tolower(c) TOLOWER(c)
>
> +/* We do not include direct.h as it conflicts with system.h.  */

Maybe a small nit on the comment.

/* Forward _mkdir on MinGW to mkdir in system.h.  */

Otherwise, OK.
Johannes Pfau April 14, 2019, 9:56 a.m. UTC | #5
Am 13.04.19 um 18:48 schrieb Iain Buclaw:
> On Mon, 25 Mar 2019 at 20:04, Johannes Pfau <johannespfau@gmail.com> wrote:
>>
>> diff --git a/gcc/d/d-system.h b/gcc/d/d-system.h
>> index efece15f3bc..6c18b69d4df 100644
>> --- a/gcc/d/d-system.h
>> +++ b/gcc/d/d-system.h
>> @@ -55,4 +55,10 @@
>>   #undef tolower
>>   #define tolower(c) TOLOWER(c)
>>
>> +/* We do not include direct.h as it conflicts with system.h.  */
> 
> Maybe a small nit on the comment.
> 
> /* Forward _mkdir on MinGW to mkdir in system.h.  */
> 
> Otherwise, OK.
> 

Changed the comment and committed as r270349
diff mbox series

Patch

diff --git a/gcc/d/d-system.h b/gcc/d/d-system.h
index efece15f3bc..6c18b69d4df 100644
--- a/gcc/d/d-system.h
+++ b/gcc/d/d-system.h
@@ -55,4 +55,10 @@ 
 #undef tolower
 #define tolower(c) TOLOWER(c)
 
+/* We do not include direct.h as it conflicts with system.h.  */
+#ifdef _WIN32
+#undef _mkdir
+#define _mkdir(p) mkdir(p, 0)
+#endif
+
 #endif  /* GCC_D_SYSTEM_H  */
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index a8757427849..3017f0d34af 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@ 
-fe8b2c2c2a4ede475f15a082f26460275cdef42e
+74ac873be1862090b7ec0e4a876fd1b758520359
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
diff --git a/gcc/d/dmd/root/filename.c b/gcc/d/dmd/root/filename.c
index 0e7b79db806..6144d810fb5 100644
--- a/gcc/d/dmd/root/filename.c
+++ b/gcc/d/dmd/root/filename.c
@@ -262,6 +262,7 @@  const char *FileName::name(const char *str)
                 if (e == str + 1 || e == str + len - 1)
                     return e + 1;
 #endif
+                /* falls through */
             default:
                 if (e == str)
                     break;
@@ -542,7 +543,7 @@  int FileName::exists(const char *name)
     int result;
 
     dw = GetFileAttributesA(name);
-    if (dw == -1L)
+    if (dw == INVALID_FILE_ATTRIBUTES)
         result = 0;
     else if (dw & FILE_ATTRIBUTE_DIRECTORY)
         result = 2;
@@ -568,7 +569,7 @@  bool FileName::ensurePathExists(const char *path)
                 size_t len = strlen(path);
                 if ((len > 2 && p[-1] == ':' && strcmp(path + 2, p) == 0) ||
                     len == strlen(p))
-                {   mem.xfree(const_cast<void *>(p));
+                {   mem.xfree(const_cast<char *>(p));
                     return 0;
                 }
 #endif
@@ -621,7 +622,7 @@  const char *FileName::canonicalName(const char *name)
     DWORD result = GetFullPathNameA(name, 0, NULL, NULL);
     if (result)
     {
-        char *buf = (char *)malloc(result);
+        char *buf = (char *)mem.xmalloc(result);
         result = GetFullPathNameA(name, result, buf, NULL);
         if (result == 0)
         {