postgrespro / pg_probackup

Backup and recovery manager for PostgreSQL
https://postgrespro.github.io/pg_probackup/
Other
703 stars 86 forks source link

Problem with build #627

Open dmitry-lipetsk opened 1 month ago

dmitry-lipetsk commented 1 month ago

Hello,

Could anyone help me build probackup?

I am trying to build it (Ubuntu 24.04) using your instruction.

PostrgreSQL was compiled with the following steps:

Installed PG instance works as expected.

Build method 1 (PGXS)

Instruction:

To compile pg_probackup, you must have a PostgreSQL installation and raw source tree....

What is mean "raw source tree"? I pointed the folder with source that I used to build PG. Is it OK?

My command is:

make USE_PGXS=1 PG_CONFIG='/usr/local/pgsql/bin/pg_config' top_srcdir='/home/dima/.MY/GitHUB/Postgres/DEV20240722-work2/'

Errors:

/home/dima/.MY/GitHUB/PostgresPro/pgprobackup/work/src/utils/file.c:1581:(.text+0x3f74): undefined reference to `deflateInit2' /usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pgprobackup/work/src/utils/file.c:1601:(.text+0x4004): undefined reference to `inflateInit2' /usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:1630:(.text+0x40f3): undefined reference to gzdopen' /usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:1633:(.text+0x410c): undefined reference togzopen' /usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:1636:(.text+0x4133): undefined reference to `gzsetparams' ….

As I understand, a problem with zlib library. How can I fix it?

/sbin/ldconfig -p| grep libz.so says:

    libz.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libz.so.1
    libz.so.1 (libc6) => /lib/i386-linux-gnu/libz.so.1
    libz.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libz.so

Build method 2 (build probackup in contrib folder of PG source tree)

Instruction:

The alternative way, without using the PGXS infrastructure, is to place pg_probackup source directory into contrib directory and build it there.

Ok.

I copyed the folder with source code of probackup in '/home/dima/.MY/GitHUB/Postgres/DEV20240722-work2/contrib/pg_probackup':

image

I opened a terminal in this folder and executed "make"

Error:

Makefile:48: ../../src/Makefile.global: No such file or directory make: *** No rule to make target '../../src/Makefile.global'. Stop.

As I understand, the problem is here: https://github.com/postgrespro/pg_probackup/blob/a2510f5fa1845305db5aab0e5476f403fc7a5499/Makefile#L45-L50

Makefile.global was generated in "PG_SRC_TREE/build/src" not in "PG_SRC_TREE/src"

I corrected top_builddir with top_builddir=../../build but it did not help.

Error:

make -C ../../build/src/backend generated-headers make[1]: Entering directory '/home/dima/.MY/GitHUB/Postgres/DEV20240722-work2/build/src/backend' make[1]: No rule to make target 'generated-headers'. Stop. make[1]: Leaving directory '/home/dima/.MY/GitHUB/Postgres/DEV20240722-work2/build/src/backend' make: [../../build/src/Makefile.global:384: submake-generated-headers] Error 2

What did I do wrong?

Thanks.

dmitry-lipetsk commented 1 month ago

Hello,

I was able to find a temporary solution for this issue - I added PG_LDFLAGS = -lz in Makefile before including PGXS makefile.

ifdef USE_PGXS
PG_CONFIG = pg_config
# it is required for fixing a problem with zlib linking
PG_LDFLAGS = -lz
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
else

I am not sure that it is right way, because -lz it is a specific option of GCC but this is working.

Could you proposal the true solution to this?

Thanks.

fukanchik commented 1 month ago

Is -dev package of zlib installed? I think it is zlib1g-dev or libz-dev.

fukanchik commented 1 month ago

"raw source tree" indeed is a postgres source tree. E.g. just postgres-dev package won't work. Below I am doing apt source postgresql-16 but your method of git cloning and building using meson should work also.

Here's dockerfile which builds ok on ubuntu 24.04.

FROM ubuntu:24.04
WORKDIR  /
RUN sed -i 's/^Types: deb$/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources && apt update
RUN apt install -y dpkg-dev git make gcc gettext libkrb5-dev postgresql-server-dev-all vim
RUN apt install -y libssl-dev libz-dev libselinux-dev libxslt-dev libxml2-dev libreadline-dev libpam-dev
RUN apt install -y liblz4-dev libzstd-dev
RUN apt source postgresql-16
RUN GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone https://github.com/postgrespro/pg_probackup.git
WORKDIR /pg_probackup
RUN make USE_PGXS=1 PG_CONFIG=/usr/bin/pg_config top_srcdir=/postgresql-16-16.3 VERBOSE=1 clean install

Does this help?

dmitry-lipetsk commented 1 month ago

Is -dev package of zlib installed? I think it is zlib1g-dev or libz-dev.

Yes, I did it and got the following messages:

dima@ubuntu-work:~/.MY/GitHUB/PostgresPro/pg_probackup/work$ sudo apt-get install zlib1g-dev [sudo] password for dima: Reading package lists... Done Building dependency tree... Done Reading state information... Done zlib1g-dev is already the newest version (1:1.3.dfsg-3.1ubuntu2). 0 upgraded, 0 newly installed, 0 to remove and 18 not upgraded.

It does not help.

dima@ubuntu-work:~/.MY/GitHUB/PostgresPro/pg_probackup/work$ sudo apt-get install libz-dev Reading package lists... Done Building dependency tree... Done Reading state information... Done Note, selecting 'zlib1g-dev' instead of 'libz-dev' zlib1g-dev is already the newest version (1:1.3.dfsg-3.1ubuntu2). 0 upgraded, 0 newly installed, 0 to remove and 18 not upgraded.

It does not help, too.

All the error messages:

dima@ubuntu-work:~/.MY/GitHUB/PostgresPro/pg_probackup/work$ make USE_PGXS=1 PG_CONFIG='/usr/local/pgsql/bin/pg_config' top_srcdir='/home/dima/.MY/GitHUB/Postgres/DEV20240722-work2/'
rm -f src/receivelog.h && ln -s /home/dima/.MY/GitHUB/Postgres/DEV20240722-work2/src/bin/pg_basebackup/receivelog.h src/receivelog.h
cc -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wall -g -O0 -Wmissing-prototypes -Wpointer-arith -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -Wdeclaration-after-statement -Wno-format-truncation -Wno-stringop-truncation src/utils/configuration.o src/utils/json.o src/utils/logger.o src/utils/parray.o src/utils/pgut.o src/utils/thread.o src/utils/remote.o src/utils/file.o src/archive.o src/backup.o src/catalog.o src/checkdb.o src/configure.o src/data.o src/delete.o src/dir.o src/fetch.o src/help.o src/init.o src/merge.o src/parsexlog.o src/ptrack.o src/pg_probackup.o src/restore.o src/show.o src/stream.o src/util.o src/validate.o src/datapagemap.o src/catchup.o src/pg_crc.o src/receivelog.o src/streamutil.o src/xlogreader.o src/walmethods.o -L/usr/local/pgsql/lib/x86_64-linux-gnu -lpq  -L/usr/local/pgsql/lib/x86_64-linux-gnu -Wl,--as-needed -Wl,-rpath,'/usr/local/pgsql/lib/x86_64-linux-gnu',--enable-new-dtags   -lpgcommon -lpgport  -o pg_probackup
/usr/bin/ld: src/utils/file.o: in function `fio_gzopen':
/home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:1581:(.text+0x3f74): undefined reference to `deflateInit2_'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:1601:(.text+0x4004): undefined reference to `inflateInit2_'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:1630:(.text+0x40f3): undefined reference to `gzdopen'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:1633:(.text+0x410c): undefined reference to `gzopen'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:1636:(.text+0x4133): undefined reference to `gzsetparams'
/usr/bin/ld: src/utils/file.o: in function `fio_gzread':
/home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:1664:(.text+0x41ea): undefined reference to `inflate'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:1705:(.text+0x42fe): undefined reference to `gzread'
/usr/bin/ld: src/utils/file.o: in function `fio_gzwrite':
/home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:1728:(.text+0x4386): undefined reference to `deflate'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:1753:(.text+0x446a): undefined reference to `gzwrite'
/usr/bin/ld: src/utils/file.o: in function `fio_gzclose':
/home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:1767:(.text+0x44c9): undefined reference to `deflate'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:1769:(.text+0x4514): undefined reference to `deflateEnd'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:1778:(.text+0x4568): undefined reference to `inflateEnd'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:1786:(.text+0x4596): undefined reference to `gzclose'
/usr/bin/ld: src/utils/file.o: in function `fio_gzeof':
/home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:1800:(.text+0x45d9): undefined reference to `gzeof'
/usr/bin/ld: src/utils/file.o: in function `fio_gzerror':
/home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:1816:(.text+0x4638): undefined reference to `gzerror'
/usr/bin/ld: src/utils/file.o: in function `fio_gzseek':
/home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:1824:(.text+0x469b): undefined reference to `gzseek'
/usr/bin/ld: src/utils/file.o: in function `fio_send_file_gz':
/home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:2568:(.text+0x6953): undefined reference to `inflateInit2_'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:2600:(.text+0x69fc): undefined reference to `inflate'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:2651:(.text+0x6b70): undefined reference to `inflateEnd'
/usr/bin/ld: src/utils/file.o: in function `pgFileGetCRCgz':
/home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:3300:(.text+0x807f): undefined reference to `gzopen'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:3324:(.text+0x8130): undefined reference to `gzread'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:3329:(.text+0x8145): undefined reference to `gzeof'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:3335:(.text+0x8168): undefined reference to `gzerror'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/utils/file.c:3345:(.text+0x8234): undefined reference to `gzclose'
/usr/bin/ld: src/archive.o: in function `get_wal_file_internal':
/home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/archive.c:1645:(.text+0x3ec4): undefined reference to `gzopen'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/archive.c:1670:(.text+0x3f50): undefined reference to `gzread'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/archive.c:1674:(.text+0x3f69): undefined reference to `gzeof'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/archive.c:1717:(.text+0x40c8): undefined reference to `gzclose'
/usr/bin/ld: src/data.o: in function `zlib_compress':
/home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/data.c:44:(.text+0x38d): undefined reference to `compress2'
/usr/bin/ld: src/data.o: in function `zlib_decompress':
/home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/data.c:55:(.text+0x400): undefined reference to `uncompress'
/usr/bin/ld: src/data.o: in function `do_compress':
/home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/data.c:80:(.text+0x4a5): undefined reference to `zError'
/usr/bin/ld: src/data.o: in function `do_decompress':
/home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/data.c:112:(.text+0x567): undefined reference to `zError'
/usr/bin/ld: src/walmethods.o: in function `dir_open_for_write':
/home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/walmethods.c:157:(.text+0x203): undefined reference to `gzdopen'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/walmethods.c:165:(.text+0x25c): undefined reference to `gzsetparams'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/walmethods.c:169:(.text+0x280): undefined reference to `gzclose'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/walmethods.c:260:(.text+0x3ac): undefined reference to `gzclose'
/usr/bin/ld: src/walmethods.o: in function `dir_write':
/home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/walmethods.c:316:(.text+0x53f): undefined reference to `gzwrite'
/usr/bin/ld: src/walmethods.o: in function `dir_close':
/home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/walmethods.c:400:(.text+0x6bc): undefined reference to `gzclose'
/usr/bin/ld: src/walmethods.o: in function `dir_sync':
/home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/walmethods.c:527:(.text+0xa99): undefined reference to `gzflush'
/usr/bin/ld: src/walmethods.o: in function `tar_write_compressed_data':
/home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/walmethods.c:723:(.text+0xe25): undefined reference to `deflate'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/walmethods.c:753:(.text+0xf2f): undefined reference to `deflateReset'
/usr/bin/ld: src/walmethods.o: in function `tar_open_for_write':
/home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/walmethods.c:874:(.text+0x1386): undefined reference to `deflateInit2_'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/walmethods.c:921:(.text+0x150a): undefined reference to `deflateParams'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/walmethods.c:962:(.text+0x1688): undefined reference to `deflateParams'
/usr/bin/ld: src/walmethods.o: in function `tar_close':
/home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/walmethods.c:1169:(.text+0x1cf1): undefined reference to `deflateParams'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/walmethods.c:1181:(.text+0x1d74): undefined reference to `deflateParams'
/usr/bin/ld: src/walmethods.o: in function `tar_finish':
/home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/walmethods.c:1265:(.text+0x2067): undefined reference to `deflate'
/usr/bin/ld: /home/dima/.MY/GitHUB/PostgresPro/pg_probackup/work/src/walmethods.c:1291:(.text+0x2158): undefined reference to `deflateEnd'
collect2: error: ld returned 1 exit status
make: *** [/usr/local/pgsql/lib/x86_64-linux-gnu/pgxs/src/makefiles/pgxs.mk:478: pg_probackup] Error 1
dmitry-lipetsk commented 1 month ago

"raw source tree" indeed is a postgres source tree. E.g. just postgres-dev package won't work.

Ok, I did it.

My '/home/dima/.MY/GitHUB/Postgres/DEV20240722-work2' contains PG source tree (it was cloned from GitHub) and this tree was used to compile my installed PG instance.

image

Below I am doing apt source postgresql-16 but your method of git cloning and building using meson should work >also.

Here's dockerfile which builds ok on ubuntu 24.04.

...

Does this help?

I'll try to check it a bit later.

Thank you for your help.

dmitry-lipetsk commented 1 month ago

I tested PGXS method with PostgreSQL v16.3 (cloned from GitHub) and got the same problem with undefined references.

v16 was compiled with meson.

make USE_PGXS=1 PG_CONFIG='/usr/local/pgsql16/bin/pg_config' top_srcdir='/home/dima/.MY/GitHUB/Postgres/v16/work'

Errors:

cc -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wmissing-prototypes -Wpointer-arith -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -Wdeclaration-after-statement -Wno-format-truncation -Wno-stringop-truncation src/utils/configuration.o src/utils/json.o src/utils/logger.o src/utils/parray.o src/utils/pgut.o src/utils/thread.o src/utils/remote.o src/utils/file.o src/archive.o src/backup.o src/catalog.o src/checkdb.o src/configure.o src/data.o src/delete.o src/dir.o src/fetch.o src/help.o src/init.o src/merge.o src/parsexlog.o src/ptrack.o src/pg_probackup.o src/restore.o src/show.o src/stream.o src/util.o src/validate.o src/datapagemap.o src/catchup.o src/pg_crc.o src/receivelog.o src/streamutil.o src/xlogreader.o src/walmethods.o -L/usr/local/pgsql16/lib/x86_64-linux-gnu -lpgcommon -lpgport -L/usr/local/pgsql16/lib/x86_64-linux-gnu -lpq  -L/usr/local/pgsql16/lib/x86_64-linux-gnu -Wl,--as-needed -Wl,-rpath,'/usr/local/pgsql16/lib/x86_64-linux-gnu',--enable-new-dtags   -lpgcommon -lpgport  -o pg_probackup
/usr/bin/ld: src/utils/file.o: in function `fio_gzopen':
file.c:(.text+0x3f74): undefined reference to `deflateInit2_'
/usr/bin/ld: file.c:(.text+0x4004): undefined reference to `inflateInit2_'
/usr/bin/ld: file.c:(.text+0x40f3): undefined reference to `gzdopen'
/usr/bin/ld: file.c:(.text+0x410c): undefined reference to `gzopen'
/usr/bin/ld: file.c:(.text+0x4133): undefined reference to `gzsetparams'
/usr/bin/ld: src/utils/file.o: in function `fio_gzread':
file.c:(.text+0x41ea): undefined reference to `inflate'
/usr/bin/ld: file.c:(.text+0x42fe): undefined reference to `gzread'
/usr/bin/ld: src/utils/file.o: in function `fio_gzwrite':
file.c:(.text+0x4386): undefined reference to `deflate'
/usr/bin/ld: file.c:(.text+0x446a): undefined reference to `gzwrite'
/usr/bin/ld: src/utils/file.o: in function `fio_gzclose':
file.c:(.text+0x44c9): undefined reference to `deflate'
/usr/bin/ld: file.c:(.text+0x4514): undefined reference to `deflateEnd'
/usr/bin/ld: file.c:(.text+0x4568): undefined reference to `inflateEnd'
/usr/bin/ld: file.c:(.text+0x4596): undefined reference to `gzclose'
/usr/bin/ld: src/utils/file.o: in function `fio_gzeof':
file.c:(.text+0x45d9): undefined reference to `gzeof'
/usr/bin/ld: src/utils/file.o: in function `fio_gzerror':
file.c:(.text+0x4638): undefined reference to `gzerror'
/usr/bin/ld: src/utils/file.o: in function `fio_gzseek':
file.c:(.text+0x469b): undefined reference to `gzseek'
/usr/bin/ld: src/utils/file.o: in function `fio_send_file_gz':
file.c:(.text+0x6953): undefined reference to `inflateInit2_'
/usr/bin/ld: file.c:(.text+0x69fc): undefined reference to `inflate'
/usr/bin/ld: file.c:(.text+0x6b70): undefined reference to `inflateEnd'
/usr/bin/ld: src/utils/file.o: in function `pgFileGetCRCgz':
file.c:(.text+0x807f): undefined reference to `gzopen'
/usr/bin/ld: file.c:(.text+0x8130): undefined reference to `gzread'
/usr/bin/ld: file.c:(.text+0x8145): undefined reference to `gzeof'
/usr/bin/ld: file.c:(.text+0x8168): undefined reference to `gzerror'
/usr/bin/ld: file.c:(.text+0x8234): undefined reference to `gzclose'
/usr/bin/ld: src/archive.o: in function `get_wal_file_internal':
archive.c:(.text+0x3ec4): undefined reference to `gzopen'
/usr/bin/ld: archive.c:(.text+0x3f50): undefined reference to `gzread'
/usr/bin/ld: archive.c:(.text+0x3f69): undefined reference to `gzeof'
/usr/bin/ld: archive.c:(.text+0x40c8): undefined reference to `gzclose'
/usr/bin/ld: src/data.o: in function `zlib_compress':
data.c:(.text+0x38d): undefined reference to `compress2'
/usr/bin/ld: src/data.o: in function `zlib_decompress':
data.c:(.text+0x400): undefined reference to `uncompress'
/usr/bin/ld: src/data.o: in function `do_compress':
data.c:(.text+0x4a5): undefined reference to `zError'
/usr/bin/ld: src/data.o: in function `do_decompress':
data.c:(.text+0x567): undefined reference to `zError'
/usr/bin/ld: src/walmethods.o: in function `dir_open_for_write':
walmethods.c:(.text+0x203): undefined reference to `gzdopen'
/usr/bin/ld: walmethods.c:(.text+0x25c): undefined reference to `gzsetparams'
/usr/bin/ld: walmethods.c:(.text+0x280): undefined reference to `gzclose'
/usr/bin/ld: walmethods.c:(.text+0x3ac): undefined reference to `gzclose'
/usr/bin/ld: src/walmethods.o: in function `dir_write':
walmethods.c:(.text+0x53f): undefined reference to `gzwrite'
/usr/bin/ld: src/walmethods.o: in function `dir_close':
walmethods.c:(.text+0x6bc): undefined reference to `gzclose'
/usr/bin/ld: src/walmethods.o: in function `dir_sync':
walmethods.c:(.text+0xa99): undefined reference to `gzflush'
/usr/bin/ld: src/walmethods.o: in function `tar_write_compressed_data':
walmethods.c:(.text+0xe25): undefined reference to `deflate'
/usr/bin/ld: walmethods.c:(.text+0xf2f): undefined reference to `deflateReset'
/usr/bin/ld: src/walmethods.o: in function `tar_open_for_write':
walmethods.c:(.text+0x1386): undefined reference to `deflateInit2_'
/usr/bin/ld: walmethods.c:(.text+0x150a): undefined reference to `deflateParams'
/usr/bin/ld: walmethods.c:(.text+0x1688): undefined reference to `deflateParams'
/usr/bin/ld: src/walmethods.o: in function `tar_close':
walmethods.c:(.text+0x1cf1): undefined reference to `deflateParams'
/usr/bin/ld: walmethods.c:(.text+0x1d74): undefined reference to `deflateParams'
/usr/bin/ld: src/walmethods.o: in function `tar_finish':
walmethods.c:(.text+0x2067): undefined reference to `deflate'
/usr/bin/ld: walmethods.c:(.text+0x2158): undefined reference to `deflateEnd'
collect2: error: ld returned 1 exit status
make: *** [/usr/local/pgsql16/lib/x86_64-linux-gnu/pgxs/src/makefiles/pgxs.mk:478: pg_probackup] Error 1

When I add PG_LDFLAGS = -lz - propbackup is built without any problems:

dima@ubuntu-work:~/.MY/GitHUB/PostgresPro/pg_probackup/work$ make USE_PGXS=1 PG_CONFIG='/usr/local/pgsql16/bin/pg_config' top_srcdir='/home/dima/.MY/GitHUB/Postgres/v16/work'
rm -f src/receivelog.h && ln -s /home/dima/.MY/GitHUB/Postgres/v16/work/src/bin/pg_basebackup/receivelog.h src/receivelog.h
cc -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wmissing-prototypes -Wpointer-arith -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -Wdeclaration-after-statement -Wno-format-truncation -Wno-stringop-truncation src/utils/configuration.o src/utils/json.o src/utils/logger.o src/utils/parray.o src/utils/pgut.o src/utils/thread.o src/utils/remote.o src/utils/file.o src/archive.o src/backup.o src/catalog.o src/checkdb.o src/configure.o src/data.o src/delete.o src/dir.o src/fetch.o src/help.o src/init.o src/merge.o src/parsexlog.o src/ptrack.o src/pg_probackup.o src/restore.o src/show.o src/stream.o src/util.o src/validate.o src/datapagemap.o src/catchup.o src/pg_crc.o src/receivelog.o src/streamutil.o src/xlogreader.o src/walmethods.o -L/usr/local/pgsql16/lib/x86_64-linux-gnu -lpgcommon -lpgport -L/usr/local/pgsql16/lib/x86_64-linux-gnu -lpq  -lz -L/usr/local/pgsql16/lib/x86_64-linux-gnu -Wl,--as-needed -Wl,-rpath,'/usr/local/pgsql16/lib/x86_64-linux-gnu',--enable-new-dtags   -lpgcommon -lpgport  -o pg_probackup
dima@ubuntu-work:~/.MY/GitHUB/PostgresPro/pg_probackup/work$
dmitry-lipetsk commented 1 month ago

Here's dockerfile which builds ok on ubuntu 24.04.

Unfortunately, docker does not work on my ubuntu 24.04 (that works in VM / Hyper-V) - it crashes.

So, I can't check this scenario.

Ok, I have already been able to build probackup and it is enough to continue.

I hope this problem with build will be fixed in the future :)

fukanchik commented 1 month ago

I was able to reproduce your problem using the following dockerfile. Please note that even adding -Dzlib=enabled to the meson setup didn't help.

FROM ubuntu:24.04
WORKDIR  /
RUN apt update
RUN apt install -y dpkg-dev git make gcc gettext libkrb5-dev vim
RUN apt install -y libssl-dev libz-dev libselinux-dev libxslt-dev libxml2-dev libreadline-dev libpam-dev
RUN apt install -y liblz4-dev libzstd-dev meson
RUN GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone https://github.com/postgres/postgres.git
RUN GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone https://github.com/postgrespro/pg_probackup.git
WORKDIR /postgres
RUN apt install -y flex bison
RUN apt install -y zlib1g-dev
RUN meson setup build --prefix=/usr/local/pgsql --buildtype=debug -Dssl=openssl -Dcassert=true -Dzlib=enabled
WORKDIR /postgres/build
RUN ninja
RUN ninja install
WORKDIR /pg_probackup
RUN make USE_PGXS=1 PG_CONFIG=/usr/local/pgsql/bin/pg_config top_srcdir=/postgres VERBOSE=1 clean install
fukanchik commented 1 month ago

Yeah, thanks for reporting. This have to be fixed.

dmitry-lipetsk commented 1 month ago

An equal problem exists when Postgres was compiled with a support of LZ4 (?) library

/home/dima/MY/GitHub2/pg_probackup/work-D2024728_01--HomeWork/src/xlogreader.c:2096:(.text+0x39ae): undefined reference to `LZ4_decompress_safe'
/usr/bin/ld: src/walmethods.o: in function `dir_open_for_write':
/home/dima/MY/GitHub2/pg_probackup/work-D2024728_01--HomeWork/src/walmethods.c:181:(.text+0x2d2): undefined reference to `LZ4F_createCompressionContext'
/usr/bin/ld: /home/dima/MY/GitHub2/pg_probackup/work-D2024728_01--HomeWork/src/walmethods.c:182:(.text+0x2e8): undefined reference to `LZ4F_isError'
/usr/bin/ld: /home/dima/MY/GitHub2/pg_probackup/work-D2024728_01--HomeWork/src/walmethods.c:184:(.text+0x2fb): undefined reference to `LZ4F_getErrorName'
/usr/bin/ld: /home/dima/MY/GitHub2/pg_probackup/work-D2024728_01--HomeWork/src/walmethods.c:189:(.text+0x32c): undefined reference to `LZ4F_compressBound'
/usr/bin/ld: /home/dima/MY/GitHub2/pg_probackup/work-D2024728_01--HomeWork/src/walmethods.c:197:(.text+0x396): undefined reference to `LZ4F_compressBegin'
/usr/bin/ld: /home/dima/MY/GitHub2/pg_probackup/work-D2024728_01--HomeWork/src/walmethods.c:198:(.text+0x3ac): undefined reference to `LZ4F_isError'
/usr/bin/ld: /home/dima/MY/GitHub2/pg_probackup/work-D2024728_01--HomeWork/src/walmethods.c:200:(.text+0x3bf): undefined reference to `LZ4F_getErrorName'
/usr/bin/ld: /home/dima/MY/GitHub2/pg_probackup/work-D2024728_01--HomeWork/src/walmethods.c:201:(.text+0x3d9): undefined reference to `LZ4F_freeCompressionContext'
/usr/bin/ld: /home/dima/MY/GitHub2/pg_probackup/work-D2024728_01--HomeWork/src/walmethods.c:212:(.text+0x469): undefined reference to `LZ4F_freeCompressionContext'
/usr/bin/ld: /home/dima/MY/GitHub2/pg_probackup/work-D2024728_01--HomeWork/src/walmethods.c:266:(.text+0x5ec): undefined reference to `LZ4F_compressEnd'
/usr/bin/ld: /home/dima/MY/GitHub2/pg_probackup/work-D2024728_01--HomeWork/src/walmethods.c:267:(.text+0x5fb): undefined reference to `LZ4F_freeCompressionContext'
/usr/bin/ld: src/walmethods.o: in function `dir_write':
/home/dima/MY/GitHub2/pg_probackup/work-D2024728_01--HomeWork/src/walmethods.c:343:(.text+0x8a9): undefined reference to `LZ4F_compressUpdate'
/usr/bin/ld: /home/dima/MY/GitHub2/pg_probackup/work-D2024728_01--HomeWork/src/walmethods.c:348:(.text+0x8b9): undefined reference to `LZ4F_isError'
/usr/bin/ld: /home/dima/MY/GitHub2/pg_probackup/work-D2024728_01--HomeWork/src/walmethods.c:350:(.text+0x8d0): undefined reference to `LZ4F_getErrorName'
/usr/bin/ld: src/walmethods.o: in function `dir_close':
/home/dima/MY/GitHub2/pg_probackup/work-D2024728_01--HomeWork/src/walmethods.c:409:(.text+0xafc): undefined reference to `LZ4F_compressEnd'
/usr/bin/ld: /home/dima/MY/GitHub2/pg_probackup/work-D2024728_01--HomeWork/src/walmethods.c:413:(.text+0xb12): undefined reference to `LZ4F_isError'
/usr/bin/ld: /home/dima/MY/GitHub2/pg_probackup/work-D2024728_01--HomeWork/src/walmethods.c:415:(.text+0xb2f): undefined reference to `LZ4F_getErrorName'
/usr/bin/ld: /home/dima/MY/GitHub2/pg_probackup/work-D2024728_01--HomeWork/src/walmethods.c:502:(.text+0xec4): undefined reference to `LZ4F_freeCompressionContext'
/usr/bin/ld: src/walmethods.o: in function `dir_sync':
/home/dima/MY/GitHub2/pg_probackup/work-D2024728_01--HomeWork/src/walmethods.c:541:(.text+0x1028): undefined reference to `LZ4F_flush'
/usr/bin/ld: /home/dima/MY/GitHub2/pg_probackup/work-D2024728_01--HomeWork/src/walmethods.c:542:(.text+0x1038): undefined reference to `LZ4F_isError'
/usr/bin/ld: /home/dima/MY/GitHub2/pg_probackup/work-D2024728_01--HomeWork/src/walmethods.c:544:(.text+0x104f): undefined reference to `LZ4F_getErrorName'
collect2: error: ld returned 1 exit status
make: *** [/usr/local/pgsql/lib/x86_64-linux-gnu/pgxs/src/makefiles/pgxs.mk:478: pg_probackup] Error 1

I have not known how to fix it yet :(

UPD. PG_LDFLAGS = -lz -llz4