Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiler error on Illumos #317

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

japinli
Copy link
Contributor

@japinli japinli commented Mar 25, 2024

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
Copy link
Contributor Author

japinli commented Mar 25, 2024

@microsoft-github-policy-service agree

endif

PG_CPPFLAGS += -D__EXTENSIONS__
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When compiling pg_cron with -std=c99, I need to add -D__EXTENSIONS__. Maybe I can do this during the compilation of the Postgres.

else
PG_CPPFLAGS = -std=c99 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-implicit-fallthrough -Iinclude -I$(libpq_srcdir)
PG_CPPFLAGS = -std=c99 -Wall -Wextra -Wno-unused-parameter -Wno-implicit-fallthrough -Iinclude -I$(libpq_srcdir)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a good change, can the includes be fixed somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Illumos, UINT8_MAX is defined as '255U', however, Linux glibc uses '255' for UINT8_MAX, which is signed.

When using the -Werror flag, any warning generated during compilation will be treated as an error and the compilation process will fail.

/home/japin/postgres/build/pg/include/server/access/rmgr.h:50:42: error: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Werror=sign-compare]
   50 |  return rmid >= RM_MIN_CUSTOM_ID && rmid <= RM_MAX_CUSTOM_ID;
      |                                          ^~
cc1: all warnings being treated as errors

Although this is a Postgres issue, forcing -Werror will cause pg_cron to fail to compile successfully on Illumos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants