diff options
author | Ian Jackson <ian.jackson@eu.citrix.com> | 2012-04-11 14:14:11 +0100 |
---|---|---|
committer | Ian Jackson <ian.jackson@eu.citrix.com> | 2012-04-11 14:14:11 +0100 |
commit | 90b969c2ede4bd5ba3722d0f2a71a77d8380bf80 (patch) | |
tree | d80784684a262b3dd427ba9895780af6cc8f19b5 /tools/m4 | |
parent | 862bf6424b9cd460b337cb5e47f16d3581970ff2 (diff) | |
download | xen-90b969c2ede4bd5ba3722d0f2a71a77d8380bf80.tar.gz xen-90b969c2ede4bd5ba3722d0f2a71a77d8380bf80.tar.bz2 xen-90b969c2ede4bd5ba3722d0f2a71a77d8380bf80.zip |
tools: Correct PTHREAD options in config/StdGNU.mk
It is not correct to say -lpthread. The correct option is -pthread,
which may have sundry other effects on code generation etc. It needs
to be passed both to compilation and linking.
Fix the configure test to test -pthread, and plumb the resulting flag
through to PTHREAD_{CFLAGS,LDFLAGS} in Tools.mk; also substitute
PTHREAD_LIBS (although this will currently always be empty).
Remove PTHREAD_LIBS setting from StdGNU.mk.
Fix the one user (libxc) to use PTHREAD_{CFLAGS,LDFLAGS} too.
There are still some other users in tree which pass -pthread or
-lpthread by adding it as a literal to their own compiler options.
These will be fixed in a later patch.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Roger Pau Monne <roger.pau@entel.upc.edu>
Acked-by: Roger Pau Monne <roger.pau@entel.upc.edu>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Diffstat (limited to 'tools/m4')
-rw-r--r-- | tools/m4/pthread.m4 | 41 | ||||
-rw-r--r-- | tools/m4/savevar.m4 | 6 |
2 files changed, 47 insertions, 0 deletions
diff --git a/tools/m4/pthread.m4 b/tools/m4/pthread.m4 new file mode 100644 index 0000000000..57ea85c1f9 --- /dev/null +++ b/tools/m4/pthread.m4 @@ -0,0 +1,41 @@ +# We define, separately, PTHREAD_CFLAGS, _LDFLAGS and _LIBS +# even though currently we don't set them very separately. +# This means that the makefiles will not need to change in +# the future if we make the test more sophisticated. + +AC_DEFUN([AX_PTHREAD_CV2VARS],[ + PTHREAD_CFLAGS="$ax_cv_pthread_flags" + PTHREAD_LDFLAGS="$ax_cv_pthread_flags" + PTHREAD_LIBS="" +]) + +# We invoke AX_PTHREAD_VARS with the name of another macro +# which is then expanded once for each variable. +AC_DEFUN([AX_PTHREAD_VARS],[$1(CFLAGS) $1(LDFLAGS) $1(LIBS)]) + +AC_DEFUN([AX_PTHREAD_VAR_APPLY],[ + $1="$$1 $PTHREAD_$1" +]) +AC_DEFUN([AX_PTHREAD_VAR_SUBST],[AC_SUBST(PTHREAD_$1)]) + +AC_DEFUN([AX_CHECK_PTHREAD],[ + AC_CACHE_CHECK([for pthread flag], [ax_cv_pthread_flags], [ + ax_cv_pthread_flags=-pthread + AX_PTHREAD_CV2VARS + AX_PTHREAD_VARS([AX_SAVEVAR_SAVE]) + AX_PTHREAD_VARS([AX_PTHREAD_VAR_APPLY]) + AC_LINK_IFELSE([ +#include <pthread.h> +int main(void) { + pthread_atfork(0,0,0); + pthread_create(0,0,0,0); +} +],[],[ax_cv_pthread_flags=failed]) + AX_PTHREAD_VARS([AX_SAVEVAR_RESTORE]) + ]) + if test "x$ax_cv_pthread_flags" = xfailed; then + AC_MSG_ERROR([-pthread does not work]) + fi + AX_PTHREAD_CV2VARS + AX_PTHREAD_VARS([AX_PTHREAD_VAR_SUBST]) +]) diff --git a/tools/m4/savevar.m4 b/tools/m4/savevar.m4 new file mode 100644 index 0000000000..2156beed17 --- /dev/null +++ b/tools/m4/savevar.m4 @@ -0,0 +1,6 @@ +AC_DEFUN([AX_SAVEVAR_SAVE],[ + saved_$1="$$1" +]) +AC_DEFUN([AX_SAVEVAR_RESTORE],[ + $1="$saved_$1" +]) |