joyent / libuv

Go to
https://github.com/libuv/libuv
3.27k stars 654 forks source link

MinGW-w64 Build Problems #221

Closed davidhoyt closed 12 years ago

davidhoyt commented 12 years ago

src/win/fs.c has several build problems when using mingw-w64 and make. My gcc's winnt.h doesn't include definitions for REPARSE_DATA_BUFFER, ENABLE_INSERT_MODE, ENABLE_QUICK_EDIT_MODE, and ENABLE_EXTENDED_FLAGS. Consequently there are build problems with src/win/fs.c.

An MSVC build also doesn't seem to work since it looks for stdint.h in uv.h and because it doesn't exist, it fails.

I'm using the git version. Are there stable source releases I missed somewhere?

Any chance you'd consider switching over to using autotools?

Also, after inspecting the makefile, I don't see anywhere where a shared object is created. Is this meant to always only be statically linked?

Thanks!

luislavena commented 12 years ago

@davidhoyt, you're correct, mingw-w64 is missing those defitions, but mingw.org does have them.

Perhaps will be better report this to mingw-w64 so they add the missing information.

Any chance you'd consider switching over to using autotools?

Don't think that is going to happen, Gyp is used but I don't think MinGW is supported.

Also, after inspecting the makefile, I don't see anywhere where a shared object is created. Is this meant to always only be statically linked?

Correct, there is no shared object being created, only uv.a

luislavena commented 12 years ago

A followup on this: mingw-w64 is not missing the declaration, it is inside ddk which is not included in the default GCC include path.

I don't remember a way to trigger DDK be available :-(

okuoku commented 12 years ago

Hmm, my MinGW32/64 install (TDM-GCC 4.6.1) has everything you've mentioned ( wincon.h or ddk/ntifs.h ).

MSVC10 has stdint.h. and I'm using MSVC10 build (with my CMake branch) flawlessly.

luislavena commented 12 years ago

@okuoku mingw-w64 indeed defines the elements, but these belong to DDK headers and those are not in the default lookup path for GCC.

TDM build of mingw-w64 (only the 64bits) might have relocated them so it could work, can't comment on that.

But, if you look at src/win/winapi.h will see that the missing definitions for MinGW are added there, for some reason win/fs.c is not picking that up?

okuoku commented 12 years ago

What we have to do is:

diff --git a/src/win/winapi.h b/src/win/winapi.h
index 78ffe16..ac89bf6 100644
--- a/src/win/winapi.h
+++ b/src/win/winapi.h
@@ -4080,7 +4080,7 @@

 /* from ntifs.h */
 /* MinGW already has it */
-#ifndef __MINGW32__
+#if !defined(__MINGW32__)||defined(__MINGW64__)
   typedef struct _REPARSE_DATA_BUFFER {
     ULONG  ReparseTag;
     USHORT ReparseDataLength;

at least.

83 Success 3 Fail with TDM MinGW64

okuoku commented 12 years ago

Ah, Ubuntu Mingw32-w64 lacks rest.

Finally, following works at Ubuntu mingw64, TDM MinGW32/64. (I don't know anything about MSYS. But should work.)

diff --git a/src/win/util.c b/src/win/util.c
index cc6f93c..4f236e3 100644
--- a/src/win/util.c
+++ b/src/win/util.c
@@ -25,7 +25,7 @@

 #include "uv.h"
 #include "internal.h"
-#include "Tlhelp32.h"
+#include "tlhelp32.h"

 int uv_utf16_to_utf8(const wchar_t* utf16Buffer, size_t utf16Size,
diff --git a/src/win/winapi.h b/src/win/winapi.h
index 78ffe16..55b633c 100644
--- a/src/win/winapi.h
+++ b/src/win/winapi.h
@@ -4080,7 +4080,7 @@

 /* from ntifs.h */
 /* MinGW already has it */
-#ifndef __MINGW32__
+#if !defined(__MINGW32__)||defined(__MINGW64__)
   typedef struct _REPARSE_DATA_BUFFER {
     ULONG  ReparseTag;
     USHORT ReparseDataLength;
@@ -4270,6 +4270,10 @@ typedef enum _FILE_INFORMATION_CLASS {
                                              FILE_SPECIAL_ACCESS)
 #endif

+#ifndef IO_REPARSE_TAG_SYMLINK
+# define IO_REPARSE_TAG_SYMLINK 0xA000000CL
+#endif
+
 typedef ULONG (NTAPI *sRtlNtStatusToDosError)
               (NTSTATUS Status);

@@ -4334,4 +4338,17 @@ extern sGetQueuedCompletionStatusEx pGetQueuedCompletionStatusEx;
 extern sSetFileCompletionNotificationModes pSetFileCompletionNotificationModes;
 extern sCreateSymbolicLinkW pCreateSymbolicLinkW;

+/* from wincon.h */
+#ifndef ENABLE_INSERT_MODE
+# define ENABLE_INSERT_MODE 0x20
+#endif
+
+#ifndef ENABLE_QUICK_EDIT_MODE
+# define ENABLE_QUICK_EDIT_MODE 0x40
+#endif
+
+#ifndef ENABLE_EXTENDED_FLAGS
+# define ENABLE_EXTENDED_FLAGS 0x80
+#endif
+
 #endif /* UV_WIN_WINAPI_H_ */
luislavena commented 12 years ago

Hey @piscisaureus and @bnoordhuis, by chance can you look at this and #222?

I've asked about this on mingw-w64 and they follow MS header placed inside ddk folder, see the thread in mingw-w64 here:

http://bit.ly/t6O57P

Thank you

bnoordhuis commented 12 years ago

I think this got fixed in ee49c7a. If not, holler and I'll reopen the issue.

okuoku commented 12 years ago

I have: https://github.com/okuoku/libuv/commit/0dca9f7b2d57f56078da767f99d8697482aba535 to fix mingw64 build for my own CMake fork. It must be a MinGW64 bug but not confirmed yet.

Anyway, MinGW32/64 are not "tier-1" here so i'm ok with closing this, at least. I will submit my patch later if i'd get more confident with my patch...