Find file History
Latest commit e6bbc00 Oct 11, 2016 @ffontaine ffontaine Fix pthreads detection when cross-compiling
pthreads are not working when cross-compiling, indeed configure
sets pthreads_working to no if cross_compiling is detected.
This behavior is implemented in PTHREADS_CHECK. This function call
AC_CACHE_CHECK twice to retrieve ac_cv_pthreads_cflags and
In these calls, the function PTHREADS_CHECK_COMPILE will call AC_TRY_RUN
function which will update the global pthreads_working variable.
This is not compliant with autoconf AC_CACHE_CHECK rules which specify
that "The commands-to-set-it must have no side effects except for
setting the variable cache-id".

So, this patch replaces pthread_working assignments with assignments on
a new local pthread_checked variable. Value of ptreads_working is
computed outside AC_CACHE_CHECK function depending on value of
ac_cv_pthreads_cflags and ac_cv_pthreads_lib.

Moreover, AC_TRY_RUN call is replaced by AC_TRY_LINK which will work
when cross-compiling.

Without this modification, thread safety option (--enable-maintainer-zts)
can not be enabled on embedded buildsystems such as buildroot.

Signed-off-by: Fabrice Fontaine <>