hapostgres / pg_auto_failover

Postgres extension and service for automated failover and high-availability
Other
1.07k stars 113 forks source link

Compile fails on lock_utils.c: 127:14: error: variable has incomplete type 'union semun' #897

Closed MikeJakubik closed 2 years ago

MikeJakubik commented 2 years ago

Hi,

I get the following error when trying to compile on FreeBSD 13 against PostgreSQL 14.

[root@pgsql1 ~]# pkg info|grep postgres
postgresql14-client-14.2       PostgreSQL database (client)
postgresql14-contrib-14.2      The contrib utilities from the PostgreSQL distribution
postgresql14-server-14.2       PostgreSQL is the most advanced open-source database available anywhere

[root@pgsql1 /tmp/pg_auto_failover]# uname -a
FreeBSD pgsql1 13.1-PRERELEASE FreeBSD 13.1-PRERELEASE #0 stable/13-n249838-e8bb416da13: Thu Mar  3 02:31:18 UTC 2022     root@releng3.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64

[root@pgsql1 /tmp/pg_auto_failover]# cc -v
FreeBSD clang version 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a303)
Target: x86_64-unknown-freebsd13.1
Thread model: posix
InstalledDir: /usr/bin

gmake[2]: Entering directory '/tmp/pg_auto_failover/src/bin/pg_autoctl'
cc -std=c99 -D_GNU_SOURCE -g -I /usr/local/include -I /usr/local/include/postgresql/server -I /usr/local/include/postgresql/internal -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Werror=unguarded-availability-new -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing  -Wformat -Wall -Werror=implicit-int -Werror=implicit-function-declaration -Werror=return-type -Wno-declaration-after-statement -Wno-missing-braces -I/tmp/pg_auto_failover/src/bin/pg_autoctl/../lib/pg -I/tmp/pg_auto_failover/src/bin/pg_autoctl/../lib/log/src/ -I/tmp/pg_auto_failover/src/bin/pg_autoctl/../lib/subcommands.c/ -I/tmp/pg_auto_failover/src/bin/pg_autoctl/../lib/libs/ -I/tmp/pg_auto_failover/src/bin/pg_autoctl/../lib/parson/  -c -MMD -MP -MF/tmp/pg_auto_failover/src/bin/pg_autoctl//.deps/lock_utils.Po -o lock_utils.o lock_utils.c
lock_utils.c:127:14: error: variable has incomplete type 'union semun'
        union semun semun;
                    ^
lock_utils.c:127:8: note: forward declaration of 'union semun'
        union semun semun;
              ^
lock_utils.c:199:14: error: variable has incomplete type 'union semun'
        union semun semun;
                    ^
lock_utils.c:199:8: note: forward declaration of 'union semun'
        union semun semun;
              ^
2 errors generated.
gmake[2]: *** [Makefile:69: lock_utils.o] Error 1
gmake[2]: Leaving directory '/tmp/pg_auto_failover/src/bin/pg_autoctl'
gmake[1]: *** [Makefile:7: pg_autoctl] Error 2
gmake[1]: Leaving directory '/tmp/pg_auto_failover/src/bin'
gmake: *** [Makefile:127: bin] Error 2
DimCitus commented 2 years ago

Hi, can you try with a similar fix to this one on another project with lots of commonalities source-code wise: https://github.com/dimitri/pgcopydb/commit/734eb121b4726f5deb2ad6c8ea6a173a4de4b6b2. Cheers.

MikeJakubik commented 2 years ago

Hi, can you try with a similar fix to this one on another project with lots of commonalities source-code wise: dimitri/pgcopydb@734eb12. Cheers.

Yes, it compiles fine.

[root@pgsql1 /tmp/pgcopydb]# gmake
GIT_VERSION = 0.6.4.g8f0f25b
gmake -C src/bin/ all
gmake[1]: Entering directory '/tmp/pgcopydb/src/bin'
gmake -C pgcopydb pgcopydb
gmake[2]: Entering directory '/tmp/pgcopydb/src/bin/pgcopydb'

...

cc -std=c99 -D_GNU_SOURCE -g -I /usr/local/include -I /usr/local/include/postgresql/server -I /usr/local/include/postgresql/internal -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Werror=unguarded-availability-new -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing  -Wformat -Wall -Werror=implicit-int -Werror=implicit-function-declaration -Werror=return-type -Wno-declaration-after-statement -D_WANT_SEMUN -Wno-missing-braces -I/tmp/pgcopydb/src/bin/pgcopydb/../lib/pg -I/tmp/pgcopydb/src/bin/pgcopydb/../lib/log/src/ -I/tmp/pgcopydb/src/bin/pgcopydb/../lib/subcommands.c/ -I/tmp/pgcopydb/src/bin/pgcopydb/../lib/libs/ -I/tmp/pgcopydb/src/bin/pgcopydb/../lib/parson/ -I/tmp/pgcopydb/src/bin/pgcopydb/../lib/uthash  cli_common.o cli_copy.o cli_dump.o cli_list.o cli_restore.o cli_root.o copydb.o dump_restore.o env_utils.o file_utils.o filtering.o indexes.o ini_implementation.o lock_utils.o main.o parsing.o pgcmd.o pgsql.o pidfile.o schema.o sequences.o signals.o string_utils.o summary.o table-data.o lib-log.o lib-commandline.o lib-parson.o lib-snprintf.o lib-strerror.o  -L /usr/local/lib/postgresql -L /usr/local/lib -L/usr/local/lib -lpthread -L/usr/local/lib -fstack-protector-strong -L/usr/local/lib -Wl,--as-needed -Wl,-R'/usr/local/lib' -lpgcommon -lpgport -lintl -lssl -lcrypto -lz -lreadline -lexecinfo -lm  -lpq -lncurses -o pgcopydb
gmake[2]: Leaving directory '/tmp/pgcopydb/src/bin/pgcopydb'
gmake[1]: Leaving directory '/tmp/pgcopydb/src/bin'

[root@pgsql1 /tmp/pgcopydb]# file src/bin/pgcopydb/pgcopydb
src/bin/pgcopydb/pgcopydb: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 13.0 (1300526), FreeBSD-style, with debug_info, not stripped