Skip to content

Commit 1d084fb

Browse files
committed
Add ./configure check for "lz4" command
Some environments may compile with --with-lz4 while the command "lz4" goes missing, causing two failures in the TAP tests of pg_verifybackup (008_untar.pl and 010_client_untar.pl) as the code assumed that the command always existed with a hardcoded value in src/Makefile.global. Rather than this method, this adds a ./configure check based on PGAC_PATH_PROGS() to find automatically the command and get an absolute path to it. Both tests need to be adjusted for the case where the command does not exist, actually, as Makefile.global would set now LZ4 to an empty value in this case. The TAP tests of pg_receivewal already do that. Per report from buildfarm member copperhead, as an effect of dab2984. The origin of the failure is actually babbbb5 that did not centralize the check for the existence of a "lz4" command at ./configure to shave a few cycles. Note that one just needs to tweak an environment to move "lz4" out of the way to reproduce the problem, which is what I did to test this change. Per discussion with Robert Haas, Tom Lane, Andres Freund and myself. Discussion: https://postgr.es/m/[email protected]
1 parent 3f74daa commit 1d084fb

File tree

5 files changed

+63
-5
lines changed

5 files changed

+63
-5
lines changed

configure

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,7 @@ CFLAGS_ARMV8_CRC32C
650650
CFLAGS_SSE42
651651
have_win32_dbghelp
652652
LIBOBJS
653+
LZ4
653654
UUID_LIBS
654655
LDAP_LIBS_BE
655656
LDAP_LIBS_FE
@@ -13832,6 +13833,60 @@ fi
1383213833

1383313834
fi
1383413835

13836+
if test -z "$LZ4"; then
13837+
for ac_prog in lz4
13838+
do
13839+
# Extract the first word of "$ac_prog", so it can be a program name with args.
13840+
set dummy $ac_prog; ac_word=$2
13841+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
13842+
$as_echo_n "checking for $ac_word... " >&6; }
13843+
if ${ac_cv_path_LZ4+:} false; then :
13844+
$as_echo_n "(cached) " >&6
13845+
else
13846+
case $LZ4 in
13847+
[\\/]* | ?:[\\/]*)
13848+
ac_cv_path_LZ4="$LZ4" # Let the user override the test with a path.
13849+
;;
13850+
*)
13851+
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
13852+
for as_dir in $PATH
13853+
do
13854+
IFS=$as_save_IFS
13855+
test -z "$as_dir" && as_dir=.
13856+
for ac_exec_ext in '' $ac_executable_extensions; do
13857+
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
13858+
ac_cv_path_LZ4="$as_dir/$ac_word$ac_exec_ext"
13859+
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
13860+
break 2
13861+
fi
13862+
done
13863+
done
13864+
IFS=$as_save_IFS
13865+
13866+
;;
13867+
esac
13868+
fi
13869+
LZ4=$ac_cv_path_LZ4
13870+
if test -n "$LZ4"; then
13871+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LZ4" >&5
13872+
$as_echo "$LZ4" >&6; }
13873+
else
13874+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
13875+
$as_echo "no" >&6; }
13876+
fi
13877+
13878+
13879+
test -n "$LZ4" && break
13880+
done
13881+
13882+
else
13883+
# Report the value of LZ4 in configure's output in all cases.
13884+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LZ4" >&5
13885+
$as_echo_n "checking for LZ4... " >&6; }
13886+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LZ4" >&5
13887+
$as_echo "$LZ4" >&6; }
13888+
fi
13889+
1383513890
if test "$with_lz4" = yes; then
1383613891
for ac_header in lz4.h
1383713892
do :

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,6 +1485,7 @@ failure. It is possible the compiler isn't looking in the proper directory.
14851485
Use --without-zlib to disable zlib support.])])
14861486
fi
14871487

1488+
PGAC_PATH_PROGS(LZ4, lz4)
14881489
if test "$with_lz4" = yes; then
14891490
AC_CHECK_HEADERS(lz4.h, [], [AC_MSG_ERROR([lz4.h header file is required for LZ4])])
14901491
fi

src/Makefile.global.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ XGETTEXT = @XGETTEXT@
350350

351351
GZIP = gzip
352352
BZIP2 = bzip2
353-
LZ4 = lz4
353+
LZ4 = @LZ4@
354354

355355
DOWNLOAD = wget -O $@ --no-use-server-timestamps
356356
#DOWNLOAD = curl -o $@

src/bin/pg_verifybackup/t/008_untar.pl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@
5454
skip "$method compression not supported by this build", 3
5555
if ! $tc->{'enabled'};
5656
skip "no decompressor available for $method", 3
57-
if exists $tc->{'decompress_program'} &&
58-
!defined $tc->{'decompress_program'};
57+
if exists $tc->{'decompress_program'}
58+
&& (!defined $tc->{'decompress_program'}
59+
|| $tc->{'decompress_program'} eq '');
5960

6061
# Take a server-side backup.
6162
my @backup = (

src/bin/pg_verifybackup/t/010_client_untar.pl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@
5353
skip "$method compression not supported by this build", 3
5454
if ! $tc->{'enabled'};
5555
skip "no decompressor available for $method", 3
56-
if exists $tc->{'decompress_program'} &&
57-
!defined $tc->{'decompress_program'};
56+
if exists $tc->{'decompress_program'}
57+
&& (!defined $tc->{'decompress_program'}
58+
|| $tc->{'decompress_program'} eq '');
5859

5960
# Take a client-side backup.
6061
my @backup = (

0 commit comments

Comments
 (0)