citusdata / pg_cron

Run periodic jobs in PostgreSQL
PostgreSQL License
2.9k stars 195 forks source link

Fix compiler error on Illumos #317

Closed japinli closed 5 months ago

japinli commented 8 months ago

Hi,

When I try to use pg_cron on Illumos, there are some errors, such as following:

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 -Wsign-compare -ggdb -O0 -ftree-vectorize -pipe -fexceptions -Wl,-rpath,/home/japin/postgres/build/pg/lib -fPIC -fvisibility=hidden -std=c99 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-implicit-fallthrough -Iinclude -I/home/japin/postgres/build/pg/include -I. -I./ -I/home/japin/postgres/build/pg/include/server -I/home/japin/postgres/build/pg/include/internal -I/opt/local/include  -D_POSIX_PTHREAD_SEMANTICS -I/opt/local/include/libxml2 -I/opt/local/include -I/opt/local/include -I/opt/local/include   -c -o src/entry.o src/entry.c -MMD -MP -MF .deps/entry.Po
In file included from /home/japin/postgres/build/pg/include/server/postgres.h:46,
                 from src/entry.c:26:
/home/japin/postgres/build/pg/include/server/utils/elog.h:429:20: error: unknown type name 'sigjmp_buf'
  429 | extern PGDLLIMPORT sigjmp_buf *PG_exception_stack;
      |                    ^~~~~~~~~~
src/entry.c: In function 'get_number':
src/entry.c:468:9: error: implicit declaration of function 'strcasecmp'; did you mean 'pg_strcasecmp'? [-Werror=implicit-function-declaration]
  468 |    if (!strcasecmp(names[i], temp)) {
      |         ^~~~~~~~~~
      |         pg_strcasecmp
cc1: all warnings being treated as errors
make: *** [/home/japin/postgres/build/pg/lib/pgxs/src/makefiles/../../src/Makefile.global:962: src/entry.o] Error 1
japinli commented 8 months ago

@microsoft-github-policy-service agree

japinli commented 5 months ago

Hi, @marcoslot,

For the __EXTENSIONS__ macro, on illumos, the sigjmp_buf is defined under !defined(_STRICT_STDC) || defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__), so I enabled this macro on SunOS.

See: https://github.com/illumos/illumos-gate/blob/master/usr/src/head/setjmp.h#L50-L58

Now, I only disable sign compare on illumos (which is derived from SunOS) that can fix comparison of integer expressions of different signedness: 'int' and 'unsigned int'.

See: https://github.com/illumos/illumos-gate/blob/master/usr/src/uts/common/sys/int_limits.h#L92

Please, take a look. Thank you so much for your attention and participation.

japinli commented 5 months ago

@marcoslot Thank you.