e15953
From 5095b43b5ea079aab47963fa443a0d697f4a7af9 Mon Sep 17 00:00:00 2001
e15953
From: Andreas Schneider <asn@samba.org>
e15953
Date: Mon, 23 Sep 2019 15:18:55 +0200
e15953
Subject: [PATCH 1/9] s3:waf: Do not check for nanosleep() as we don't use it
e15953
 anywhere
e15953
MIME-Version: 1.0
e15953
Content-Type: text/plain; charset=UTF-8
e15953
Content-Transfer-Encoding: 8bit
e15953
e15953
We use usleep() in the meantime.
e15953
e15953
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14140
e15953
e15953
Signed-off-by: Andreas Schneider <asn@samba.org>
e15953
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
e15953
Pair-Programmed-With: Isaac Boukris <iboukris@gmail.com>
e15953
Reviewed-by: Matthias Dieter Wallnöfer <mdw@samba.org>
e15953
Reviewed-by: Alexander Bokovoy <ab@samba.org>
e15953
(cherry picked from commit 952e1812fa9bdc1bac2a7ae5ebb5532f1ea31447)
e15953
---
e15953
 source3/wscript | 1 -
e15953
 1 file changed, 1 deletion(-)
e15953
e15953
diff --git a/source3/wscript b/source3/wscript
e15953
index 84a2ad9e601..5c2ba18f872 100644
e15953
--- a/source3/wscript
e15953
+++ b/source3/wscript
e15953
@@ -116,7 +116,6 @@ def configure(conf):
e15953
     conf.CHECK_FUNCS('fstatat')
e15953
     conf.CHECK_FUNCS('getpwent_r setenv clearenv strcasecmp fcvt fcvtl')
e15953
     conf.CHECK_FUNCS('syslog vsyslog timegm setlocale')
e15953
-    conf.CHECK_FUNCS_IN('nanosleep', 'rt')
e15953
     conf.CHECK_FUNCS('lutimes futimes utimensat futimens')
e15953
     conf.CHECK_FUNCS('mlock munlock mlockall munlockall')
e15953
     conf.CHECK_FUNCS('memalign posix_memalign hstrerror')
e15953
-- 
e15953
2.23.0
e15953
e15953
e15953
From 74d4e574e0f971bd7c0bf60af696d285c3a01aae Mon Sep 17 00:00:00 2001
e15953
From: Andreas Schneider <asn@samba.org>
e15953
Date: Mon, 23 Sep 2019 15:14:24 +0200
e15953
Subject: [PATCH 2/9] replace: Only link against librt if really needed
e15953
MIME-Version: 1.0
e15953
Content-Type: text/plain; charset=UTF-8
e15953
Content-Transfer-Encoding: 8bit
e15953
e15953
fdatasync() and clock_gettime() are provided by glibc on Linux, so there
e15953
is no need to link against librt. Checks have been added so if there are
e15953
platforms which require it are still functional.
e15953
e15953
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14140
e15953
e15953
Signed-off-by: Andreas Schneider <asn@samba.org>
e15953
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
e15953
Pair-Programmed-With: Isaac Boukris <iboukris@gmail.com>
e15953
Reviewed-by: Matthias Dieter Wallnöfer <mdw@samba.org>
e15953
Reviewed-by: Alexander Bokovoy <ab@samba.org>
e15953
(cherry picked from commit 480152dd6729d4c58faca6f3e4fa91ff4614c272)
e15953
---
e15953
 lib/replace/wscript | 24 +++++++++++++++++++++---
e15953
 1 file changed, 21 insertions(+), 3 deletions(-)
e15953
e15953
diff --git a/lib/replace/wscript b/lib/replace/wscript
e15953
index a7fd25d15bc..d8423b1d281 100644
e15953
--- a/lib/replace/wscript
e15953
+++ b/lib/replace/wscript
e15953
@@ -457,11 +457,28 @@ def configure(conf):
e15953
     conf.CHECK_C_PROTOTYPE('dlopen', 'void *dlopen(const char* filename, unsigned int flags)',
e15953
                            define='DLOPEN_TAKES_UNSIGNED_FLAGS', headers='dlfcn.h dl.h')
e15953
 
e15953
-    if conf.CHECK_FUNCS_IN('fdatasync', 'rt', checklibc=True):
e15953
+    #
e15953
+    # Check for clock_gettime and fdatasync
e15953
+    #
e15953
+    # First check libc to avoid linking libreplace against librt.
e15953
+    #
e15953
+    if conf.CHECK_FUNCS('fdatasync'):
e15953
         # some systems are missing the declaration
e15953
         conf.CHECK_DECLS('fdatasync')
e15953
+    else:
e15953
+        if conf.CHECK_FUNCS_IN('fdatasync', 'rt'):
e15953
+            # some systems are missing the declaration
e15953
+            conf.CHECK_DECLS('fdatasync')
e15953
+
e15953
+    has_clock_gettime = False
e15953
+    if conf.CHECK_FUNCS('clock_gettime'):
e15953
+        has_clock_gettime = True
e15953
+
e15953
+    if not has_clock_gettime:
e15953
+        if conf.CHECK_FUNCS_IN('clock_gettime', 'rt', checklibc=True):
e15953
+            has_clock_gettime = True
e15953
 
e15953
-    if conf.CHECK_FUNCS_IN('clock_gettime', 'rt', checklibc=True):
e15953
+    if has_clock_gettime:
e15953
         for c in ['CLOCK_MONOTONIC', 'CLOCK_PROCESS_CPUTIME_ID', 'CLOCK_REALTIME']:
e15953
             conf.CHECK_CODE('''
e15953
                 #if TIME_WITH_SYS_TIME
e15953
@@ -815,6 +832,7 @@ def build(bld):
e15953
 
e15953
     extra_libs = ''
e15953
     if bld.CONFIG_SET('HAVE_LIBBSD'): extra_libs += ' bsd'
e15953
+    if bld.CONFIG_SET('HAVE_LIBRT'): extra_libs += ' rt'
e15953
 
e15953
     bld.SAMBA_SUBSYSTEM('LIBREPLACE_HOSTCC',
e15953
         REPLACE_HOSTCC_SOURCE,
e15953
@@ -855,7 +873,7 @@ def build(bld):
e15953
                       # at the moment:
e15953
                       # hide_symbols=bld.BUILTIN_LIBRARY('replace'),
e15953
                       private_library=True,
e15953
-                      deps='crypt dl nsl socket rt attr' + extra_libs)
e15953
+                      deps='crypt dl nsl socket attr' + extra_libs)
e15953
 
e15953
     replace_test_cflags = ''
e15953
     if bld.CONFIG_SET('HAVE_WNO_FORMAT_TRUNCATION'):
e15953
-- 
e15953
2.23.0
e15953
e15953
e15953
From 58859a3088a74753b301e48b964edb6d242d245a Mon Sep 17 00:00:00 2001
e15953
From: Andreas Schneider <asn@samba.org>
e15953
Date: Mon, 23 Sep 2019 16:10:35 +0200
e15953
Subject: [PATCH 3/9] pthreadpool: Only link pthreadpool against librt if we
e15953
 have to
e15953
MIME-Version: 1.0
e15953
Content-Type: text/plain; charset=UTF-8
e15953
Content-Transfer-Encoding: 8bit
e15953
e15953
This calls clock_gettime() which is available in glibc on Linux. If the
e15953
wscript in libreplace detected that librt is needed for clock_gettime()
e15953
we have to link against it.
e15953
e15953
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14140
e15953
e15953
Signed-off-by: Andreas Schneider <asn@samba.org>
e15953
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
e15953
Pair-Programmed-With: Isaac Boukris <iboukris@gmail.com>
e15953
Reviewed-by: Matthias Dieter Wallnöfer <mdw@samba.org>
e15953
Reviewed-by: Alexander Bokovoy <ab@samba.org>
e15953
(cherry picked from commit 4b28239d13b17e42eb5aa4b405342f46347f3de4)
e15953
---
e15953
 lib/pthreadpool/wscript_build | 7 ++++++-
e15953
 1 file changed, 6 insertions(+), 1 deletion(-)
e15953
e15953
diff --git a/lib/pthreadpool/wscript_build b/lib/pthreadpool/wscript_build
e15953
index 57df25548b1..70aa7cbf041 100644
e15953
--- a/lib/pthreadpool/wscript_build
e15953
+++ b/lib/pthreadpool/wscript_build
e15953
@@ -1,12 +1,17 @@
e15953
 #!/usr/bin/env python
e15953
 
e15953
 if bld.env.WITH_PTHREADPOOL:
e15953
+    extra_libs=''
e15953
+
e15953
+    # Link to librt if needed for clock_gettime()
e15953
+    if bld.CONFIG_SET('HAVE_LIBRT'): extra_libs += ' rt'
e15953
+
e15953
     bld.SAMBA_SUBSYSTEM('PTHREADPOOL',
e15953
                          source='''pthreadpool.c
e15953
                                    pthreadpool_pipe.c
e15953
                                    pthreadpool_tevent.c
e15953
                                 ''',
e15953
-                         deps='pthread rt replace tevent-util')
e15953
+                         deps='pthread replace tevent-util' + extra_libs)
e15953
 else:
e15953
     bld.SAMBA_SUBSYSTEM('PTHREADPOOL',
e15953
                          source='''pthreadpool_sync.c
e15953
-- 
e15953
2.23.0
e15953
e15953
e15953
From 8a268f3af434d409dcd84db5fef10d6943266b75 Mon Sep 17 00:00:00 2001
e15953
From: Andreas Schneider <asn@samba.org>
e15953
Date: Mon, 23 Sep 2019 17:04:57 +0200
e15953
Subject: [PATCH 4/9] third_party: Only link cmocka against librt if really
e15953
 needed
e15953
MIME-Version: 1.0
e15953
Content-Type: text/plain; charset=UTF-8
e15953
Content-Transfer-Encoding: 8bit
e15953
e15953
cmocka also uses clock_gettime().
e15953
e15953
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14140
e15953
e15953
Signed-off-by: Andreas Schneider <asn@samba.org>
e15953
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
e15953
Pair-Programmed-With: Isaac Boukris <iboukris@gmail.com>
e15953
Reviewed-by: Matthias Dieter Wallnöfer <mdw@samba.org>
e15953
Reviewed-by: Alexander Bokovoy <ab@samba.org>
e15953
(cherry picked from commit 36e8d715bc8dc1e8466f5a5c9798df76310b7572)
e15953
---
e15953
 third_party/cmocka/wscript | 7 ++++++-
e15953
 1 file changed, 6 insertions(+), 1 deletion(-)
e15953
e15953
diff --git a/third_party/cmocka/wscript b/third_party/cmocka/wscript
e15953
index 9ebdd7cfbe9..3c2ad50801a 100644
e15953
--- a/third_party/cmocka/wscript
e15953
+++ b/third_party/cmocka/wscript
e15953
@@ -12,8 +12,13 @@ def build(bld):
e15953
     if bld.CONFIG_SET('USING_SYSTEM_CMOCKA'):
e15953
         return
e15953
 
e15953
+    extra_libs=''
e15953
+
e15953
+    # Link to librt if needed for clock_gettime()
e15953
+    if bld.CONFIG_SET('HAVE_LIBRT'): extra_libs += ' rt'
e15953
+
e15953
     bld.SAMBA_LIBRARY('cmocka',
e15953
                       source='cmocka.c',
e15953
-                      deps='rt',
e15953
+                      deps=extra_libs,
e15953
                       allow_warnings=True,
e15953
                       private_library=True)
e15953
-- 
e15953
2.23.0
e15953
e15953
e15953
From 3b3d2606fefb98a9a27626f1ddfdabdf22992a9e Mon Sep 17 00:00:00 2001
e15953
From: Andreas Schneider <asn@samba.org>
e15953
Date: Mon, 23 Sep 2019 17:39:29 +0200
e15953
Subject: [PATCH 5/9] third_party: Link nss_wrapper against pthread
e15953
MIME-Version: 1.0
e15953
Content-Type: text/plain; charset=UTF-8
e15953
Content-Transfer-Encoding: 8bit
e15953
e15953
nss_wrapper uses pthread_atfork() which is only provided by libpthread.
e15953
So we need an explicit dependency.
e15953
e15953
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14140
e15953
e15953
Signed-off-by: Andreas Schneider <asn@samba.org>
e15953
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
e15953
Pair-Programmed-With: Isaac Boukris <iboukris@gmail.com>
e15953
Reviewed-by: Matthias Dieter Wallnöfer <mdw@samba.org>
e15953
Reviewed-by: Alexander Bokovoy <ab@samba.org>
e15953
(cherry picked from commit 68d8a02ef57cce29e4ff3ef1b792adfc10d0b916)
e15953
---
e15953
 third_party/nss_wrapper/wscript | 2 +-
e15953
 1 file changed, 1 insertion(+), 1 deletion(-)
e15953
e15953
diff --git a/third_party/nss_wrapper/wscript b/third_party/nss_wrapper/wscript
e15953
index 2e9d1db13b1..40848603b36 100644
e15953
--- a/third_party/nss_wrapper/wscript
e15953
+++ b/third_party/nss_wrapper/wscript
e15953
@@ -89,6 +89,6 @@ def build(bld):
e15953
         # breaks preloading!
e15953
         bld.SAMBA_LIBRARY('nss_wrapper',
e15953
                           source='nss_wrapper.c',
e15953
-                          deps='dl',
e15953
+                          deps='dl pthread',
e15953
                           install=False,
e15953
                           realname='libnss-wrapper.so')
e15953
-- 
e15953
2.23.0
e15953
e15953
e15953
From 2f27ac30a8d75b09f3ac9ac32d3a0e23d3d48581 Mon Sep 17 00:00:00 2001
e15953
From: Andreas Schneider <asn@samba.org>
e15953
Date: Mon, 23 Sep 2019 17:40:13 +0200
e15953
Subject: [PATCH 6/9] third_party: Link uid_wrapper against pthread
e15953
MIME-Version: 1.0
e15953
Content-Type: text/plain; charset=UTF-8
e15953
Content-Transfer-Encoding: 8bit
e15953
e15953
uid_wrapper uses pthread_atfork() which is only provided by libpthread.                                                                                   │····················
e15953
So we need an explicit dependency.
e15953
e15953
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14140
e15953
e15953
Signed-off-by: Andreas Schneider <asn@samba.org>
e15953
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
e15953
Pair-Programmed-With: Isaac Boukris <iboukris@gmail.com>
e15953
Reviewed-by: Matthias Dieter Wallnöfer <mdw@samba.org>
e15953
Reviewed-by: Alexander Bokovoy <ab@samba.org>
e15953
(cherry picked from commit bd0cd8e13234d684da77a65f6fdaea2572625369)
e15953
---
e15953
 third_party/uid_wrapper/wscript | 2 +-
e15953
 1 file changed, 1 insertion(+), 1 deletion(-)
e15953
e15953
diff --git a/third_party/uid_wrapper/wscript b/third_party/uid_wrapper/wscript
e15953
index 61d8a189625..738343f49e4 100644
e15953
--- a/third_party/uid_wrapper/wscript
e15953
+++ b/third_party/uid_wrapper/wscript
e15953
@@ -119,6 +119,6 @@ def build(bld):
e15953
         # breaks preloading!
e15953
         bld.SAMBA_LIBRARY('uid_wrapper',
e15953
                           source='uid_wrapper.c',
e15953
-                          deps='dl',
e15953
+                          deps='dl pthread',
e15953
                           install=False,
e15953
                           realname='libuid-wrapper.so')
e15953
-- 
e15953
2.23.0
e15953
e15953
e15953
From bf1b1e4b85c516a480c5a29a98a8761870a59735 Mon Sep 17 00:00:00 2001
e15953
From: Andreas Schneider <asn@samba.org>
e15953
Date: Mon, 23 Sep 2019 16:53:12 +0200
e15953
Subject: [PATCH 7/9] waf:replace: Do not link against libpthread if not
e15953
 necessary
e15953
MIME-Version: 1.0
e15953
Content-Type: text/plain; charset=UTF-8
e15953
Content-Transfer-Encoding: 8bit
e15953
e15953
On Linux we should avoid linking everything against libpthread. Symbols
e15953
used my most application are provided by glibc and code which deals with
e15953
threads has to explicitly link against libpthread.  This avoids setting
e15953
LDFLAGS=-pthread globally.
e15953
e15953
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14140
e15953
e15953
Signed-off-by: Andreas Schneider <asn@samba.org>
e15953
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
e15953
Pair-Programmed-With: Isaac Boukris <iboukris@gmail.com>
e15953
Reviewed-by: Matthias Dieter Wallnöfer <mdw@samba.org>
e15953
Reviewed-by: Alexander Bokovoy <ab@samba.org>
e15953
(cherry picked from commit 9499db075b72b147e2ff9bb78e9d5edbaac14e69)
e15953
---
e15953
 lib/replace/wscript | 10 ++++++----
e15953
 1 file changed, 6 insertions(+), 4 deletions(-)
e15953
e15953
diff --git a/lib/replace/wscript b/lib/replace/wscript
e15953
index d8423b1d281..b5919835c0b 100644
e15953
--- a/lib/replace/wscript
e15953
+++ b/lib/replace/wscript
e15953
@@ -551,6 +551,11 @@ def configure(conf):
e15953
     PTHREAD_CFLAGS='error'
e15953
     PTHREAD_LDFLAGS='error'
e15953
 
e15953
+    if PTHREAD_LDFLAGS == 'error':
e15953
+        # Check if pthread_attr_init() is provided by libc first!
e15953
+        if conf.CHECK_FUNCS('pthread_attr_init'):
e15953
+            PTHREAD_CFLAGS='-D_REENTRANT'
e15953
+            PTHREAD_LDFLAGS=''
e15953
     if PTHREAD_LDFLAGS == 'error':
e15953
         if conf.CHECK_FUNCS_IN('pthread_attr_init', 'pthread'):
e15953
             PTHREAD_CFLAGS='-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS'
e15953
@@ -563,10 +568,7 @@ def configure(conf):
e15953
         if conf.CHECK_FUNCS_IN('pthread_attr_init', 'c_r'):
e15953
             PTHREAD_CFLAGS='-D_THREAD_SAFE -pthread'
e15953
             PTHREAD_LDFLAGS='-pthread'
e15953
-    if PTHREAD_LDFLAGS == 'error':
e15953
-        if conf.CHECK_FUNCS('pthread_attr_init'):
e15953
-            PTHREAD_CFLAGS='-D_REENTRANT'
e15953
-            PTHREAD_LDFLAGS='-lpthread'
e15953
+
e15953
     # especially for HP-UX, where the CHECK_FUNC macro fails to test for
e15953
     # pthread_attr_init. On pthread_mutex_lock it works there...
e15953
     if PTHREAD_LDFLAGS == 'error':
e15953
-- 
e15953
2.23.0
e15953
e15953
e15953
From cce4834d7aacf69975bc5acf24c66e3a2913f231 Mon Sep 17 00:00:00 2001
e15953
From: Isaac Boukris <iboukris@gmail.com>
e15953
Date: Tue, 15 Oct 2019 13:52:42 +0300
e15953
Subject: [PATCH 8/9] nsswitch: Link stress-nss-libwbclient against pthread
e15953
e15953
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14140
e15953
e15953
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
e15953
Reviewed-by: Andreas Schneider <asn@samba.org>
e15953
Reviewed-by: Alexander Bokovoy <ab@samba.org>
e15953
(cherry picked from commit d473f1e38c2822746030516269b4d70032cf9b2e)
e15953
---
e15953
 nsswitch/wscript_build | 2 +-
e15953
 1 file changed, 1 insertion(+), 1 deletion(-)
e15953
e15953
diff --git a/nsswitch/wscript_build b/nsswitch/wscript_build
e15953
index 6acc4a19b9b..861ed2f23bf 100644
e15953
--- a/nsswitch/wscript_build
e15953
+++ b/nsswitch/wscript_build
e15953
@@ -20,7 +20,7 @@ bld.SAMBA_BINARY('nsstest',
e15953
 if bld.CONFIG_SET('HAVE_PTHREAD'):
e15953
     bld.SAMBA_BINARY('stress-nss-libwbclient',
e15953
 		     source='stress-nss-libwbclient.c',
e15953
-		     deps='wbclient',
e15953
+		     deps='wbclient pthread',
e15953
 		     install=False
e15953
 		     )
e15953
 
e15953
-- 
e15953
2.23.0
e15953
e15953
e15953
From d3609fef9b4e7ac76d4dfe2f387e89e3a79749c6 Mon Sep 17 00:00:00 2001
e15953
From: Isaac Boukris <iboukris@gmail.com>
e15953
Date: Tue, 15 Oct 2019 17:01:48 +0300
e15953
Subject: [PATCH 9/9] s3:libsmb: Link libsmb against pthread
e15953
e15953
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14140
e15953
e15953
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
e15953
Reviewed-by: Andreas Schneider <asn@samba.org>
e15953
Reviewed-by: Alexander Bokovoy <ab@samba.org>
e15953
(cherry picked from commit 7259197bf716f8b81dea74beefe6ee3b1239f172)
e15953
---
e15953
 source3/libsmb/wscript | 1 +
e15953
 1 file changed, 1 insertion(+)
e15953
e15953
diff --git a/source3/libsmb/wscript b/source3/libsmb/wscript
e15953
index d9e933e9e9f..febff9df7fc 100644
e15953
--- a/source3/libsmb/wscript
e15953
+++ b/source3/libsmb/wscript
e15953
@@ -16,6 +16,7 @@ def build(bld):
e15953
                               libsmb_xattr.c
e15953
                               libsmb_setget.c''',
e15953
                        public_deps='''
e15953
+                                   pthread
e15953
                                    talloc
e15953
                                    smbconf
e15953
                                    libsmb
e15953
-- 
e15953
2.23.0
e15953