Skip to content

Commit de91c3b

Browse files
committed
Fix new pthread code to respect --disable-thread-safety.
Don't try to compile src/port/pthread_barrier_wait.c if we opted out of threads at configure time. Revealed by build farm member gaur, which can't compile this code because of problems with its pthread implementation. It shouldn't be trying to, because it's using --disable-thread-safety. Defect in commit 44bf3d5. Reported-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/2568537.1615603606%40sss.pgh.pa.us
1 parent c5be48f commit de91c3b

File tree

2 files changed

+84
-71
lines changed

2 files changed

+84
-71
lines changed

configure

Lines changed: 76 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -11635,62 +11635,6 @@ if test "$ac_res" != no; then :
1163511635

1163611636
fi
1163711637

11638-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_barrier_wait" >&5
11639-
$as_echo_n "checking for library containing pthread_barrier_wait... " >&6; }
11640-
if ${ac_cv_search_pthread_barrier_wait+:} false; then :
11641-
$as_echo_n "(cached) " >&6
11642-
else
11643-
ac_func_search_save_LIBS=$LIBS
11644-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11645-
/* end confdefs.h. */
11646-
11647-
/* Override any GCC internal prototype to avoid an error.
11648-
Use char because int might match the return type of a GCC
11649-
builtin and then its argument prototype would still apply. */
11650-
#ifdef __cplusplus
11651-
extern "C"
11652-
#endif
11653-
char pthread_barrier_wait ();
11654-
int
11655-
main ()
11656-
{
11657-
return pthread_barrier_wait ();
11658-
;
11659-
return 0;
11660-
}
11661-
_ACEOF
11662-
for ac_lib in '' pthread; do
11663-
if test -z "$ac_lib"; then
11664-
ac_res="none required"
11665-
else
11666-
ac_res=-l$ac_lib
11667-
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
11668-
fi
11669-
if ac_fn_c_try_link "$LINENO"; then :
11670-
ac_cv_search_pthread_barrier_wait=$ac_res
11671-
fi
11672-
rm -f core conftest.err conftest.$ac_objext \
11673-
conftest$ac_exeext
11674-
if ${ac_cv_search_pthread_barrier_wait+:} false; then :
11675-
break
11676-
fi
11677-
done
11678-
if ${ac_cv_search_pthread_barrier_wait+:} false; then :
11679-
11680-
else
11681-
ac_cv_search_pthread_barrier_wait=no
11682-
fi
11683-
rm conftest.$ac_ext
11684-
LIBS=$ac_func_search_save_LIBS
11685-
fi
11686-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pthread_barrier_wait" >&5
11687-
$as_echo "$ac_cv_search_pthread_barrier_wait" >&6; }
11688-
ac_res=$ac_cv_search_pthread_barrier_wait
11689-
if test "$ac_res" != no; then :
11690-
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
11691-
11692-
fi
11693-
1169411638
# Solaris:
1169511639
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing fdatasync" >&5
1169611640
$as_echo_n "checking for library containing fdatasync... " >&6; }
@@ -11978,6 +11922,65 @@ if test "$ac_res" != no; then :
1197811922
fi
1197911923

1198011924

11925+
if test "$enable_thread_safety" = yes; then
11926+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_barrier_wait" >&5
11927+
$as_echo_n "checking for library containing pthread_barrier_wait... " >&6; }
11928+
if ${ac_cv_search_pthread_barrier_wait+:} false; then :
11929+
$as_echo_n "(cached) " >&6
11930+
else
11931+
ac_func_search_save_LIBS=$LIBS
11932+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11933+
/* end confdefs.h. */
11934+
11935+
/* Override any GCC internal prototype to avoid an error.
11936+
Use char because int might match the return type of a GCC
11937+
builtin and then its argument prototype would still apply. */
11938+
#ifdef __cplusplus
11939+
extern "C"
11940+
#endif
11941+
char pthread_barrier_wait ();
11942+
int
11943+
main ()
11944+
{
11945+
return pthread_barrier_wait ();
11946+
;
11947+
return 0;
11948+
}
11949+
_ACEOF
11950+
for ac_lib in '' pthread; do
11951+
if test -z "$ac_lib"; then
11952+
ac_res="none required"
11953+
else
11954+
ac_res=-l$ac_lib
11955+
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
11956+
fi
11957+
if ac_fn_c_try_link "$LINENO"; then :
11958+
ac_cv_search_pthread_barrier_wait=$ac_res
11959+
fi
11960+
rm -f core conftest.err conftest.$ac_objext \
11961+
conftest$ac_exeext
11962+
if ${ac_cv_search_pthread_barrier_wait+:} false; then :
11963+
break
11964+
fi
11965+
done
11966+
if ${ac_cv_search_pthread_barrier_wait+:} false; then :
11967+
11968+
else
11969+
ac_cv_search_pthread_barrier_wait=no
11970+
fi
11971+
rm conftest.$ac_ext
11972+
LIBS=$ac_func_search_save_LIBS
11973+
fi
11974+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pthread_barrier_wait" >&5
11975+
$as_echo "$ac_cv_search_pthread_barrier_wait" >&6; }
11976+
ac_res=$ac_cv_search_pthread_barrier_wait
11977+
if test "$ac_res" != no; then :
11978+
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
11979+
11980+
fi
11981+
11982+
fi
11983+
1198111984
if test "$with_readline" = yes; then
1198211985

1198311986

@@ -15939,19 +15942,6 @@ esac
1593915942

1594015943
fi
1594115944

15942-
ac_fn_c_check_func "$LINENO" "pthread_barrier_wait" "ac_cv_func_pthread_barrier_wait"
15943-
if test "x$ac_cv_func_pthread_barrier_wait" = xyes; then :
15944-
$as_echo "#define HAVE_PTHREAD_BARRIER_WAIT 1" >>confdefs.h
15945-
15946-
else
15947-
case " $LIBOBJS " in
15948-
*" pthread_barrier_wait.$ac_objext "* ) ;;
15949-
*) LIBOBJS="$LIBOBJS pthread_barrier_wait.$ac_objext"
15950-
;;
15951-
esac
15952-
15953-
fi
15954-
1595515945
ac_fn_c_check_func "$LINENO" "pwrite" "ac_cv_func_pwrite"
1595615946
if test "x$ac_cv_func_pwrite" = xyes; then :
1595715947
$as_echo "#define HAVE_PWRITE 1" >>confdefs.h
@@ -16058,6 +16048,23 @@ fi
1605816048

1605916049

1606016050

16051+
if test "$enable_thread_safety" = yes; then
16052+
ac_fn_c_check_func "$LINENO" "pthread_barrier_wait" "ac_cv_func_pthread_barrier_wait"
16053+
if test "x$ac_cv_func_pthread_barrier_wait" = xyes; then :
16054+
$as_echo "#define HAVE_PTHREAD_BARRIER_WAIT 1" >>confdefs.h
16055+
16056+
else
16057+
case " $LIBOBJS " in
16058+
*" pthread_barrier_wait.$ac_objext "* ) ;;
16059+
*) LIBOBJS="$LIBOBJS pthread_barrier_wait.$ac_objext"
16060+
;;
16061+
esac
16062+
16063+
fi
16064+
16065+
16066+
fi
16067+
1606116068
if test "$PORTNAME" = "win32" -o "$PORTNAME" = "cygwin"; then
1606216069
# Cygwin and (apparently, based on test results) Mingw both
1606316070
# have a broken strtof(), so substitute the same replacement

configure.ac

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,6 @@ AC_SEARCH_LIBS(getopt_long, [getopt gnugetopt])
11431143
AC_SEARCH_LIBS(shm_open, rt)
11441144
AC_SEARCH_LIBS(shm_unlink, rt)
11451145
AC_SEARCH_LIBS(clock_gettime, [rt posix4])
1146-
AC_SEARCH_LIBS(pthread_barrier_wait, pthread)
11471146
# Solaris:
11481147
AC_SEARCH_LIBS(fdatasync, [rt posix4])
11491148
# Required for thread_test.c on Solaris
@@ -1156,6 +1155,10 @@ AC_SEARCH_LIBS(shmget, cygipc)
11561155
# *BSD:
11571156
AC_SEARCH_LIBS(backtrace_symbols, execinfo)
11581157

1158+
if test "$enable_thread_safety" = yes; then
1159+
AC_SEARCH_LIBS(pthread_barrier_wait, pthread)
1160+
fi
1161+
11591162
if test "$with_readline" = yes; then
11601163
PGAC_CHECK_READLINE
11611164
if test x"$pgac_cv_check_readline" = x"no"; then
@@ -1744,7 +1747,6 @@ AC_REPLACE_FUNCS(m4_normalize([
17441747
mkdtemp
17451748
pread
17461749
preadv
1747-
pthread_barrier_wait
17481750
pwrite
17491751
pwritev
17501752
random
@@ -1755,6 +1757,10 @@ AC_REPLACE_FUNCS(m4_normalize([
17551757
strtof
17561758
]))
17571759

1760+
if test "$enable_thread_safety" = yes; then
1761+
AC_REPLACE_FUNCS(pthread_barrier_wait)
1762+
fi
1763+
17581764
if test "$PORTNAME" = "win32" -o "$PORTNAME" = "cygwin"; then
17591765
# Cygwin and (apparently, based on test results) Mingw both
17601766
# have a broken strtof(), so substitute the same replacement

0 commit comments

Comments
 (0)