On Fri, Aug 15, 2014 at 8:00 PM, Noah Misch <n...@leadboat.com> wrote: > > On Fri, Aug 15, 2014 at 12:49:36AM -0700, Michael Paquier wrote: > > Btw, how do you determine if MSVC is using HAVE_GETADDRINFO? Is it > > decided by the inclusion of getaddrinfo.c in @pgportfiles of > > Mkvdbuild.pm? > > src/include/pg_config.h.win32 dictates it, and we must keep @pgportfiles > synchronized with the former's verdict. Thanks.
Looking more into that, I am seeing that MinGW-32 is failing to find socket at configure, contrary to MinGW-64. Here is what happens for MinGW-64 at configure: configure:7638: checking for library containing socket [...] configure:7669: x86_64-w64-mingw32-gcc -o conftest.exe -Wall -Wmissing-prototypes -Wpointer-arith \ -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-stri\ ct-aliasing -fwrapv -fexcess-precision=standard -g -I./src/include/port/win32 -DEXEC_BACKEND -Wl\ ,--allow-multiple-definition -Wl,--disable-auto-import conftest.c -lws2_32 -lm >&5 configure:7669: $? = 0 configure:7686: result: -lws2_32 And for MinGW-32: configure:7638: checking for library containing socket [...] configure:7669: gcc -o conftest.exe -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after\ -statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv\ -fexcess-precision=standard -g -I./src/include/port/win32 -DEXEC_BACKEND -Wl,--allow-multiple-d\ efinition -Wl,--disable-auto-import conftest.c -lws2_32 -lm >&5 C:\Users\ioltas\AppData\Local\Temp\cciNV1Y8.o: In function `main': c:\Users\ioltas\git\postgres/conftest.c:33: undefined reference to `socket' collect2.exe: error: ld returned 1 exit status configure:7669: $? = 1 [...] configure:7686: result: no Now, what happens is that if configure finds socket within ws2_32 it adds it to LIBS, making this variable look like that: - MinGW-32: LIBS="-lm " - MinGW-64: LIBS="-lm -lws2_32" And as LIBS is used afterwards to check the presence of several functions, including getaddrinfo, those different values of LIBS make HAVE_GETADDRINFO set to different values in MinGW-32 and 64, respectively undefined and defined. I am not sure which way is better, do we want HAVE_GETADDRINFO or !HAVE_GETADDRINFO in all Windows builds? If we choose the former, we'll need to understand why -lws2_32 is not added to LIBS for MinGW-32. If we choose the latter, we would need to remove -lws2_32 from LIBS with MinGW-64 for consistency with MinGW-32 I think. Either way, currently MSVC uses !HAVE_GETADDRINFO. So in bonus to this anamysis, the patch attached makes possible the use of HAVE_GETADDRINFO. This could be needed for the final solution we seek. Note that the undef gai_strerror in src/include/port/win32/sys/socket.h has been added in 2005 by this commit: commit: a310a1d80c6535774115838010f9c337d08d45cc author: Tom Lane <t...@sss.pgh.pa.us> date: Fri, 26 Aug 2005 03:15:12 +0000 Some more mop-up for Windows IPv6 support. Andrew Dunstan I don't know the opinions of the others, but removing a tweak like this one may not be a bad thing to simplify code. Regards, -- Michael
diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32 index bce67a2..903246d 100644 --- a/src/include/pg_config.h.win32 +++ b/src/include/pg_config.h.win32 @@ -143,7 +143,7 @@ #define HAVE_FUNCNAME__FUNCTION 1 /* Define to 1 if you have getaddrinfo(). */ -/* #undef HAVE_GETADDRINFO */ +#define HAVE_GETADDRINFO 1 /* Define to 1 if you have the `gethostbyname_r' function. */ /* #undef HAVE_GETHOSTBYNAME_R */ diff --git a/src/include/port/win32/sys/socket.h b/src/include/port/win32/sys/socket.h index edaee6a..4bd08f0 100644 --- a/src/include/port/win32/sys/socket.h +++ b/src/include/port/win32/sys/socket.h @@ -23,11 +23,4 @@ #define ERROR PGERROR #endif -/* - * we can't use the windows gai_strerror{AW} functions because - * they are defined inline in the MS header files. So we'll use our - * own - */ -#undef gai_strerror - #endif /* WIN32_SYS_SOCKET_H */ diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 004942c..177879e 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -66,7 +66,7 @@ sub mkvcbuild our @pgportfiles = qw( chklocale.c crypt.c fls.c fseeko.c getrusage.c inet_aton.c random.c - srandom.c getaddrinfo.c gettimeofday.c inet_net_ntop.c kill.c open.c + srandom.c gettimeofday.c inet_net_ntop.c kill.c open.c erand48.c snprintf.c strlcat.c strlcpy.c dirmod.c noblock.c path.c pgcheckdir.c pg_crc.c pgmkdirp.c pgsleep.c pgstrcasecmp.c pqsignal.c mkdtemp.c qsort.c qsort_arg.c quotes.c system.c
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers