diff options
| author | Heikki Linnakangas | 2015-07-09 08:38:34 +0000 |
|---|---|---|
| committer | Heikki Linnakangas | 2015-07-09 08:38:34 +0000 |
| commit | 01051a9879fcd353eaf0d3788a911e774b52798c (patch) | |
| tree | e4eb60e1c1d5b75d493141a79aa961f183c0b641 /configure.in | |
| parent | bfb4cf12abc14a99b29c9c3f768b0c7f568c262d (diff) | |
Use AS_IF rather than plain shell "if" in pthread-check.
Autoconf generates additional code for the first AC_CHECK_HEADERS call in
the script. If the first call is within an if-block, the additional code is
put inside the if-block too, even though it is needed by subsequent
AC_CHECK_HEADERS checks and should always be executed. When I moved the
pthread-related checks earlier in the script, the pthread.h test inside
the block became the very first AC_CHECK_HEADERS call in the script,
triggering that problem.
To fix, use AS_IF instead of plain shell if. AS_IF knows about that issue,
and makes sure the additional code is always executed. To be completely
safe from this issue (and others), we should always be using AS_IF instead
of plain if, but that seems like excessive caution given that this is the
first time we have trouble like this. Plain if-then is more readable than
AS_IF.
This should fix compilation with --disable-thread-safety, and hopefully the
buildfarm failure on forgmouth, related to mingw standard headers, too.
I backpatched the previous fixes to 9.5, but it's starting to look like
these changes are too fiddly to backpatch, so commit this to master only,
and revert all the pthread-related configure changes in 9.5.
Diffstat (limited to 'configure.in')
| -rw-r--r-- | configure.in | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/configure.in b/configure.in index a7eec7f6e8..5724a4df07 100644 --- a/configure.in +++ b/configure.in @@ -961,7 +961,13 @@ fi # other libraries can pull in the pthread functions as a side-effect. We # want to use the -pthread or similar flags directly, and not rely on # the side-effects of linking with some other library. -if test "$enable_thread_safety" = yes -a "$PORTNAME" != "win32"; then +# +# note: We have to use AS_IF here rather than plain if. The AC_CHECK_HEADER +# invocation below is the first one in the script, and autoconf generates +# additional code for that, which must not be inside the if-block. AS_IF +# knows how to do that. +AS_IF([test "$enable_thread_safety" = yes -a "$PORTNAME" != "win32"], +[ # then AX_PTHREAD # set thread flags # Some platforms use these, so just define them. They can't hurt if they @@ -975,10 +981,8 @@ _LIBS="$LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" LIBS="$LIBS $PTHREAD_LIBS" -if test "$PORTNAME" != "win32"; then AC_CHECK_HEADER(pthread.h, [], [AC_MSG_ERROR([ pthread.h not found; use --disable-thread-safety to disable thread safety])]) -fi AC_CHECK_FUNCS([strerror_r getpwuid_r gethostbyname_r]) @@ -988,11 +992,11 @@ PGAC_FUNC_STRERROR_R_INT CFLAGS="$_CFLAGS" LIBS="$_LIBS" -else +], [ # else # do not use values from template file PTHREAD_CFLAGS= PTHREAD_LIBS= -fi +]) # fi AC_SUBST(PTHREAD_CFLAGS) AC_SUBST(PTHREAD_LIBS) |
