postgrespro / pgsphere

PgSphere provides spherical data types, functions, operators, and indexing for PostgreSQL.
https://pgsphere.org
BSD 3-Clause "New" or "Revised" License
17 stars 14 forks source link

Compiling under windows mingw64 #122

Closed robe2 closed 6 months ago

robe2 commented 7 months ago

I tried compiling master under mingw64 with PG16 and ran into some issues.

In file included from src/sparse.c:136:
src/sparse.h:69:5: error: 'INT' redeclared as different kind of symbol
   69 |     INT = 270,                     /* INT  */
      |     ^~~
In file included from C:/ming64/mingw64/include/minwindef.h:163,
                 from C:/ming64/mingw64/include/windef.h:9,
                 from C:/ming64/mingw64/include/windows.h:69,
                 from C:/ming64/mingw64/include/winsock2.h:23,
                 from C:/ming64/projects/POSTGR~1/rel/pg16w64/include/server/port/win32_port.h:60,
                 from C:/ming64/projects/POSTGR~1/rel/pg16w64/include/server/port.h:24,
                 from C:/ming64/projects/POSTGR~1/rel/pg16w64/include/server/c.h:1375,
                 from C:/ming64/projects/POSTGR~1/rel/pg16w64/include/server/postgres.h:45,
                 from src/sparse.y:4:
C:/ming64/mingw64/include/winnt.h:299:15: note: previous declaration of 'INT' with type 'INT' {aka 'int'}
  299 |   typedef int INT;
      |               ^~~
src/sparse.h:70:5: error: 'FLOAT' redeclared as different kind of symbol
   70 |     FLOAT = 271,                   /* FLOAT  */
      |     ^~~~~
C:/ming64/mingw64/include/minwindef.h:142:17: note: previous declaration of 'FLOAT' with type 'FLOAT' {aka 'float'}
  142 |   typedef float FLOAT;
      |                 ^~~~~
make: *** [<builtin>: src/sparse.o] Error 1
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -O2 -DPGSPHERE_VERSION=1.4.0 -fvisibility=hidden -DPGSPHERE_VERSION=1.4.0 -I. -I./ -IC:/ming64/projects/POSTGR~1/rel/pg16w64/include/server -IC:/ming64/projects/POSTGR~1/rel/pg16w64/include/internal  -I/projects/zlib/rel-zlib-1.2.13w64/include  -I/projects/libxml/rel-libxml2-2.9.14w64/include -I./src/include/port/win32 -IC:/ming64/mingw64/bin/../include/libxml2 -IC:/ming64/projects/lz4/rel-lz4-1.9.3w64/include  -IC:/ming64/projects/POSTGR~1/rel/pg16w64/include/server/port/win32 -DWIN32_STACK_RLIMIT=4194304  -c -o src/sparse.o src/sparse.c
In file included from src/sparse.c:136:
src/sparse.h:69:5: error: 'INT' redeclared as different kind of symbol
   69 |     INT = 270,                     /* INT  */
      |     ^~~
In file included from C:/ming64/mingw64/include/minwindef.h:163,
                 from C:/ming64/mingw64/include/windef.h:9,
                 from C:/ming64/mingw64/include/windows.h:69,
                 from C:/ming64/mingw64/include/winsock2.h:23,
                 from C:/ming64/projects/POSTGR~1/rel/pg16w64/include/server/port/win32_port.h:60,
                 from C:/ming64/projects/POSTGR~1/rel/pg16w64/include/server/port.h:24,
                 from C:/ming64/projects/POSTGR~1/rel/pg16w64/include/server/c.h:1375,
                 from C:/ming64/projects/POSTGR~1/rel/pg16w64/include/server/postgres.h:45,
                 from src/sparse.y:4:
C:/ming64/mingw64/include/winnt.h:299:15: note: previous declaration of 'INT' with type 'INT' {aka 'int'}
  299 |   typedef int INT;
      |               ^~~
src/sparse.h:70:5: error: 'FLOAT' redeclared as different kind of symbol
   70 |     FLOAT = 271,                   /* FLOAT  */
      |     ^~~~~
C:/ming64/mingw64/include/minwindef.h:142:17: note: previous declaration of 'FLOAT' with type 'FLOAT' {aka 'float'}
  142 |   typedef float FLOAT;

If I remark out the lines 69 and 70 of sparse.h then it compiles and extension installs and tests pass.

make USE_HEALPIX=0
make installcheck USE_HEALPIX=0
ok 1         - init                                      198 ms
ok 2         - tables                                    870 ms
ok 3         - points                                     45 ms
ok 4         - euler                                      35 ms
ok 5         - circle                                     44 ms
ok 6         - line                                       34 ms
ok 7         - ellipse                                    58 ms
ok 8         - poly                                       99 ms
ok 9         - path                                       49 ms
ok 10        - box                                        71 ms
ok 11        - index                                     148 ms
ok 12        - contains_ops                               61 ms
ok 13        - contains_ops_compat                        58 ms
ok 14        - bounding_box_gist                          58 ms
ok 15        - gnomo                                      50 ms
ok 16        - epochprop                                  33 ms
ok 17        - contains                                   38 ms
ok 18        - overlaps                                   54 ms
ok 19        - spoint_brin                                43 ms
ok 20        - sbox_brin                                  51 ms
ok 21        - selectivity                               685 ms
ok 22        - gist_support                              556 ms
1..22
# All 22 tests passed.

Note the Token Kinds section I didn't need to touch. Not sure what I am missing here.

I haven't tried yet compiling with HEALPIX

esabol commented 7 months ago

Well, I guess we could change INT and FLOAT in src/sparse.{c,h} to INTTOKEN and FLOATTOKEN (or something like that), respectively?

vitcpp commented 7 months ago

@esabol What do you think if to postpone 1.5.1 and fix this bug? @robe2 Is it ok for you if we plan the fix for the next release?

esabol commented 7 months ago

What do you think if to postpone 1.5.1 and fix this bug?

I have no objection, @vitcpp, if you think it can fixed quickly.

vitcpp commented 7 months ago

I have no objection, @vitcpp, if you think it can fixed quickly.

@esabol I think we should edit sparse.y - rename token names. I should find where to check the compilation because I personally use Linux :)

robe2 commented 7 months ago

@esabol What do you think if to postpone 1.5.1 and fix this bug? @robe2 Is it ok for you if we plan the fix for the next release?

Yes fine with me.

robe2 commented 7 months ago

I have no objection, @vitcpp, if you think it can fixed quickly.

@esabol I think we should edit sparse.y - rename token names. I should find where to check the compilation because I personally use Linux :)

I confirm @vitcpp patch works for me.
For testing at least mingw64 (not sure about VS cause I don't use Visual Studio), you could setup a github workflow similar to the mobilitydb one, yours I think will be much simpler.

https://github.com/MobilityDB/MobilityDB/blob/master/.github/workflows/windows_msys2.yml

I can take a stab at setting one up and see how it works.

vitcpp commented 7 months ago

@robe2 Thank you! It is a good idea to setup msys2 workflow. I'm not good in understanding how workflows are configured on github. Any help is welcome! Anyway, I will take closer look how to setup mswin/msys2 environment.