From 9499db075b72b147e2ff9bb78e9d5edbaac14e69 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 23 Sep 2019 16:53:12 +0200 Subject: [PATCH] waf:replace: Do not link against libpthread if not necessary MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit On Linux we should avoid linking everything against libpthread. Symbols used my most application are provided by glibc and code which deals with threads has to explicitly link against libpthread. This avoids setting LDFLAGS=-pthread globally. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14140 Signed-off-by: Andreas Schneider Signed-off-by: Isaac Boukris Pair-Programmed-With: Isaac Boukris Reviewed-by: Matthias Dieter Wallnöfer Reviewed-by: Alexander Bokovoy --- lib/replace/wscript | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/replace/wscript b/lib/replace/wscript index 5b5a9ab39c0..93379a7aefe 100644 --- a/lib/replace/wscript +++ b/lib/replace/wscript @@ -553,6 +553,11 @@ def configure(conf): PTHREAD_CFLAGS='error' PTHREAD_LDFLAGS='error' + if PTHREAD_LDFLAGS == 'error': + # Check if pthread_attr_init() is provided by libc first! + if conf.CHECK_FUNCS('pthread_attr_init'): + PTHREAD_CFLAGS='-D_REENTRANT' + PTHREAD_LDFLAGS='' if PTHREAD_LDFLAGS == 'error': if conf.CHECK_FUNCS_IN('pthread_attr_init', 'pthread'): PTHREAD_CFLAGS='-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS' @@ -565,10 +570,7 @@ def configure(conf): if conf.CHECK_FUNCS_IN('pthread_attr_init', 'c_r'): PTHREAD_CFLAGS='-D_THREAD_SAFE -pthread' PTHREAD_LDFLAGS='-pthread' - if PTHREAD_LDFLAGS == 'error': - if conf.CHECK_FUNCS('pthread_attr_init'): - PTHREAD_CFLAGS='-D_REENTRANT' - PTHREAD_LDFLAGS='-lpthread' + # especially for HP-UX, where the CHECK_FUNC macro fails to test for # pthread_attr_init. On pthread_mutex_lock it works there... if PTHREAD_LDFLAGS == 'error': -- 2.34.1