Opened 3 years ago

Closed 3 years ago

#4877 closed defect (fixed)

PostgreSQL 14 / windows mingw64 can't compile PostGIS

Reported by: robe Owned by: robe
Priority: blocker Milestone: PostGIS 3.1.2
Component: postgis Version: master
Keywords: windows, mingw64 Cc:

Description

In trying to troubleshoot #4876 I seem to have run into another issue which seems windows/mingw specific which prevents me from being able to even compile, though my PostgreSQL 14 installed fine.

NG64~1/projects/POSTGR~1/rel/PG14W6~1/include/server/port/win32 -DWIN32_STACK_RLIMIT=4194304                                                                                              -c -o lwgeom_in_gml.o lwgeom_in_gml.c
In file included from C:/MING64~1/projects/POSTGR~1/rel/PG14W6~1/include/server/port.h:26,
                 from C:/MING64~1/projects/POSTGR~1/rel/PG14W6~1/include/server/c.h:1355,
                 from C:/MING64~1/projects/POSTGR~1/rel/PG14W6~1/include/server/postgres.h:4                                                                                            6,
                 from lwgeom_in_gml.c:55:
C:/MING64~1/projects/POSTGR~1/rel/PG14W6~1/include/server/port/win32_port.h:57:14: warning:                                                                                             'struct microsoft_native_stat' declared inside parameter list will not be visible outside of                                                                                             this definition or declaration
 #define stat microsoft_native_stat
              ^~~~~~~~~~~~~~~~~~~~~
C:/MING64~1/projects/POSTGR~1/rel/PG14W6~1/include/server/port/win32_port.h:57:14: warning:                                                                                             'struct microsoft_native_stat' declared inside parameter list will not be visible outside of                                                                                             this definition or declaration
 #define stat microsoft_native_stat
              ^~~~~~~~~~~~~~~~~~~~~
C:/MING64~1/projects/POSTGR~1/rel/PG14W6~1/include/server/port/win32_port.h:57:14: warning:                                                                                             'struct microsoft_native_stat' declared inside parameter list will not be visible outside of                                                                                             this definition or declaration
 #define stat microsoft_native_stat
              ^~~~~~~~~~~~~~~~~~~~~
C:/MING64~1/projects/POSTGR~1/rel/PG14W6~1/include/server/port/win32_port.h:57:14: warning:                                                                                             'struct microsoft_native_stat' declared inside parameter list will not be visible outside of                                                                                             this definition or declaration
 #define stat microsoft_native_stat
              ^~~~~~~~~~~~~~~~~~~~~
C:/MING64~1/projects/POSTGR~1/rel/PG14W6~1/include/server/port/win32_port.h:56:15: error: co                                                                                            nflicting types for 'microsoft_native_fstat'
 #define fstat microsoft_native_fstat
               ^~~~~~~~~~~~~~~~~~~~~~
C:/MING64~1/projects/POSTGR~1/rel/PG14W6~1/include/server/port/win32_port.h:56:15: note: pre                                                                                            vious declaration of 'microsoft_native_fstat' was here
 #define fstat microsoft_native_fstat
               ^~~~~~~~~~~~~~~~~~~~~~
In file included from C:/MING64~1/projects/POSTGR~1/rel/PG14W6~1/include/server/port/win32_p                                                                                            ort.h:58,
                 from C:/MING64~1/projects/POSTGR~1/rel/PG14W6~1/include/server/port.h:26,
                 from C:/MING64~1/projects/POSTGR~1/rel/PG14W6~1/include/server/c.h:1355,
                 from C:/MING64~1/projects/POSTGR~1/rel/PG14W6~1/include/server/postgres.h:4                                                                                            6,
                 from lwgeom_in_gml.c:55:
C:/ming64gcc81/mingw64/x86_64-w64-mingw32/include/sys/stat.h: In function 'microsoft_native_                                                                                            fstat':
C:/ming64gcc81/mingw64/x86_64-w64-mingw32/include/sys/stat.h:226:27: error: invalid applicat                                                                                            ion of 'sizeof' to incomplete type 'struct microsoft_native_stat'
     memset(_Stat,0,sizeof(struct stat));
                           ^~~~~~
C:/ming64gcc81/mingw64/x86_64-w64-mingw32/include/sys/stat.h:231:8: error: dereferencing poi                                                                                            nter to incomplete type 'struct microsoft_native_stat'
   _Stat->st_dev=st.st_dev;
        ^~
In file included from C:/MING64~1/projects/POSTGR~1/rel/PG14W6~1/include/server/port.h:26,
                 from C:/MING64~1/projects/POSTGR~1/rel/PG14W6~1/include/server/c.h:1355,
                 from C:/MING64~1/projects/POSTGR~1/rel/PG14W6~1/include/server/postgres.h:4                                                                                            6,
                 from lwgeom_in_gml.c:55:
C:/MING64~1/projects/POSTGR~1/rel/PG14W6~1/include/server/port/win32_port.h: At top level:
C:/MING64~1/projects/POSTGR~1/rel/PG14W6~1/include/server/port/win32_port.h:256:8: error: re                                                                                            definition of 'struct stat'
 struct stat      /* This should match struct __stat64 */
        ^~~~
In file included from C:/ming64gcc81/mingw64/x86_64-w64-mingw32/include/wchar.h:424,
                 from C:/ming64gcc81/projects/rel-libiconv-1.15w64gcc81/include/iconv.h:110,
                 from C:/ming64gcc81/projects/libxml/rel-libxml2-2.9.9w64gcc81/include/libxm                                                                                            l2/libxml/encoding.h:28,
                 from C:/ming64gcc81/projects/libxml/rel-libxml2-2.9.9w64gcc81/include/libxm                                                                                            l2/libxml/parser.h:810,
                 from C:/ming64gcc81/projects/libxml/rel-libxml2-2.9.9w64gcc81/include/libxm                                                                                            l2/libxml/globals.h:18,
                 from C:/ming64gcc81/projects/libxml/rel-libxml2-2.9.9w64gcc81/include/libxm                                                                                            l2/libxml/threads.h:35,
                 from C:/ming64gcc81/projects/libxml/rel-libxml2-2.9.9w64gcc81/include/libxm                                                                                            l2/libxml/xmlmemory.h:218,
                 from C:/ming64gcc81/projects/libxml/rel-libxml2-2.9.9w64gcc81/include/libxm                                                                                            l2/libxml/tree.h:1307,
                 from lwgeom_in_gml.c:50:
C:/ming64gcc81/mingw64/x86_64-w64-mingw32/include/_mingw_stat64.h:43:10: note: originally de                                                                                            fined here
   struct stat {
          ^~~~
make[1]: *** [<builtin>: lwgeom_in_gml.o] Error 1
make[1]: Leaving directory '/projects/postgis/postgis-git/postgis'
make: *** [GNUmakefile:22: all] Error 1

Change History (7)

comment:1 by robe, 3 years ago

Seems they introduced this line in include/server/port/win32_port.h which is conflicting with mingw64 definition. Might be my mingw is old and shouldn't have it defined or they should have a mingw64 guard around this like they have other sections of the win32_port.h

#define stat microsoft_native_stat

also

C:/MING64~1/projects/POSTGR~1/rel/PG14W6~1/include/server/port/win32_port.h:258:8: error: redefinition of 'struct stat'
 struct stat      /* This should match struct __stat64 */
        ^~~~
/*
 * Supplement to <sys/stat.h>.
 *
 * We must pull in sys/stat.h before this part, else our overrides lose.
 *
 * stat() is not guaranteed to set the st_size field on win32, so we
 * redefine it to our own implementation.  See src/port/win32stat.c.
 *
 * The struct stat is 32 bit in MSVC, so we redefine it as a copy of
 * struct __stat64.  This also fixes the struct size for MINGW builds.
 */
struct stat						/* This should match struct __stat64 */
{
	_dev_t		st_dev;
	_ino_t		st_ino;
	unsigned short st_mode;
	short		st_nlink;
	short		st_uid;
	short		st_gid;
	_dev_t		st_rdev;
	__int64		st_size;
	__time64_t	st_atime;
	__time64_t	st_mtime;
	__time64_t	st_ctime;
};

I put a

#if !defined(__MINGW64_VERSION_MAJOR) || defined(_MSC_VER)

#endif

guard around these sections that allowed me to compile. I'll report as possible bug upstream.

comment:2 by robe, 3 years ago

Summary: PostgreSQL 14 / windows can't compile PostGISPostgreSQL 14 / windows mingw64 can't compile PostGIS

comment:3 by robe, 3 years ago

Milestone: PostGIS 3.2.0PostGIS PostgreSQL

comment:5 by robe, 3 years ago

Milestone: PostGIS PostgreSQLPostGIS 3.1.2

comment:6 by Regina Obe <lr@…>, 3 years ago

In f719c3c/git:

Move postgres.h include to top to fix mingw64 issues
as suggested by Tom Lane.
References #4877 for PostGIS 3.2

comment:7 by Regina Obe <lr@…>, 3 years ago

Resolution: fixed
Status: assignedclosed

In d2b6e27/git:

Move postgres.h include to top to fix mingw64 issues
as suggested by Tom Lane.
Closes #4877 for PostGIS 3.1

Note: See TracTickets for help on using tickets.