Blob Blame History Raw
From 5095b43b5ea079aab47963fa443a0d697f4a7af9 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn@samba.org>
Date: Mon, 23 Sep 2019 15:18:55 +0200
Subject: [PATCH 1/9] s3:waf: Do not check for nanosleep() as we don't use it
 anywhere
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

We use usleep() in the meantime.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14140

Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
Pair-Programmed-With: Isaac Boukris <iboukris@gmail.com>
Reviewed-by: Matthias Dieter Wallnöfer <mdw@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
(cherry picked from commit 952e1812fa9bdc1bac2a7ae5ebb5532f1ea31447)
---
 source3/wscript | 1 -
 1 file changed, 1 deletion(-)

diff --git a/source3/wscript b/source3/wscript
index 84a2ad9e601..5c2ba18f872 100644
--- a/source3/wscript
+++ b/source3/wscript
@@ -116,7 +116,6 @@ def configure(conf):
     conf.CHECK_FUNCS('fstatat')
     conf.CHECK_FUNCS('getpwent_r setenv clearenv strcasecmp fcvt fcvtl')
     conf.CHECK_FUNCS('syslog vsyslog timegm setlocale')
-    conf.CHECK_FUNCS_IN('nanosleep', 'rt')
     conf.CHECK_FUNCS('lutimes futimes utimensat futimens')
     conf.CHECK_FUNCS('mlock munlock mlockall munlockall')
     conf.CHECK_FUNCS('memalign posix_memalign hstrerror')
-- 
2.23.0


From 74d4e574e0f971bd7c0bf60af696d285c3a01aae Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn@samba.org>
Date: Mon, 23 Sep 2019 15:14:24 +0200
Subject: [PATCH 2/9] replace: Only link against librt if really needed
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

fdatasync() and clock_gettime() are provided by glibc on Linux, so there
is no need to link against librt. Checks have been added so if there are
platforms which require it are still functional.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14140

Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
Pair-Programmed-With: Isaac Boukris <iboukris@gmail.com>
Reviewed-by: Matthias Dieter Wallnöfer <mdw@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
(cherry picked from commit 480152dd6729d4c58faca6f3e4fa91ff4614c272)
---
 lib/replace/wscript | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/lib/replace/wscript b/lib/replace/wscript
index a7fd25d15bc..d8423b1d281 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -457,11 +457,28 @@ def configure(conf):
     conf.CHECK_C_PROTOTYPE('dlopen', 'void *dlopen(const char* filename, unsigned int flags)',
                            define='DLOPEN_TAKES_UNSIGNED_FLAGS', headers='dlfcn.h dl.h')
 
-    if conf.CHECK_FUNCS_IN('fdatasync', 'rt', checklibc=True):
+    #
+    # Check for clock_gettime and fdatasync
+    #
+    # First check libc to avoid linking libreplace against librt.
+    #
+    if conf.CHECK_FUNCS('fdatasync'):
         # some systems are missing the declaration
         conf.CHECK_DECLS('fdatasync')
+    else:
+        if conf.CHECK_FUNCS_IN('fdatasync', 'rt'):
+            # some systems are missing the declaration
+            conf.CHECK_DECLS('fdatasync')
+
+    has_clock_gettime = False
+    if conf.CHECK_FUNCS('clock_gettime'):
+        has_clock_gettime = True
+
+    if not has_clock_gettime:
+        if conf.CHECK_FUNCS_IN('clock_gettime', 'rt', checklibc=True):
+            has_clock_gettime = True
 
-    if conf.CHECK_FUNCS_IN('clock_gettime', 'rt', checklibc=True):
+    if has_clock_gettime:
         for c in ['CLOCK_MONOTONIC', 'CLOCK_PROCESS_CPUTIME_ID', 'CLOCK_REALTIME']:
             conf.CHECK_CODE('''
                 #if TIME_WITH_SYS_TIME
@@ -815,6 +832,7 @@ def build(bld):
 
     extra_libs = ''
     if bld.CONFIG_SET('HAVE_LIBBSD'): extra_libs += ' bsd'
+    if bld.CONFIG_SET('HAVE_LIBRT'): extra_libs += ' rt'
 
     bld.SAMBA_SUBSYSTEM('LIBREPLACE_HOSTCC',
         REPLACE_HOSTCC_SOURCE,
@@ -855,7 +873,7 @@ def build(bld):
                       # at the moment:
                       # hide_symbols=bld.BUILTIN_LIBRARY('replace'),
                       private_library=True,
-                      deps='crypt dl nsl socket rt attr' + extra_libs)
+                      deps='crypt dl nsl socket attr' + extra_libs)
 
     replace_test_cflags = ''
     if bld.CONFIG_SET('HAVE_WNO_FORMAT_TRUNCATION'):
-- 
2.23.0


From 58859a3088a74753b301e48b964edb6d242d245a Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn@samba.org>
Date: Mon, 23 Sep 2019 16:10:35 +0200
Subject: [PATCH 3/9] pthreadpool: Only link pthreadpool against librt if we
 have to
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This calls clock_gettime() which is available in glibc on Linux. If the
wscript in libreplace detected that librt is needed for clock_gettime()
we have to link against it.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14140

Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
Pair-Programmed-With: Isaac Boukris <iboukris@gmail.com>
Reviewed-by: Matthias Dieter Wallnöfer <mdw@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
(cherry picked from commit 4b28239d13b17e42eb5aa4b405342f46347f3de4)
---
 lib/pthreadpool/wscript_build | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/pthreadpool/wscript_build b/lib/pthreadpool/wscript_build
index 57df25548b1..70aa7cbf041 100644
--- a/lib/pthreadpool/wscript_build
+++ b/lib/pthreadpool/wscript_build
@@ -1,12 +1,17 @@
 #!/usr/bin/env python
 
 if bld.env.WITH_PTHREADPOOL:
+    extra_libs=''
+
+    # Link to librt if needed for clock_gettime()
+    if bld.CONFIG_SET('HAVE_LIBRT'): extra_libs += ' rt'
+
     bld.SAMBA_SUBSYSTEM('PTHREADPOOL',
                          source='''pthreadpool.c
                                    pthreadpool_pipe.c
                                    pthreadpool_tevent.c
                                 ''',
-                         deps='pthread rt replace tevent-util')
+                         deps='pthread replace tevent-util' + extra_libs)
 else:
     bld.SAMBA_SUBSYSTEM('PTHREADPOOL',
                          source='''pthreadpool_sync.c
-- 
2.23.0


From 8a268f3af434d409dcd84db5fef10d6943266b75 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn@samba.org>
Date: Mon, 23 Sep 2019 17:04:57 +0200
Subject: [PATCH 4/9] third_party: Only link cmocka against librt if really
 needed
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

cmocka also uses clock_gettime().

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14140

Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
Pair-Programmed-With: Isaac Boukris <iboukris@gmail.com>
Reviewed-by: Matthias Dieter Wallnöfer <mdw@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
(cherry picked from commit 36e8d715bc8dc1e8466f5a5c9798df76310b7572)
---
 third_party/cmocka/wscript | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/third_party/cmocka/wscript b/third_party/cmocka/wscript
index 9ebdd7cfbe9..3c2ad50801a 100644
--- a/third_party/cmocka/wscript
+++ b/third_party/cmocka/wscript
@@ -12,8 +12,13 @@ def build(bld):
     if bld.CONFIG_SET('USING_SYSTEM_CMOCKA'):
         return
 
+    extra_libs=''
+
+    # Link to librt if needed for clock_gettime()
+    if bld.CONFIG_SET('HAVE_LIBRT'): extra_libs += ' rt'
+
     bld.SAMBA_LIBRARY('cmocka',
                       source='cmocka.c',
-                      deps='rt',
+                      deps=extra_libs,
                       allow_warnings=True,
                       private_library=True)
-- 
2.23.0


From 3b3d2606fefb98a9a27626f1ddfdabdf22992a9e Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn@samba.org>
Date: Mon, 23 Sep 2019 17:39:29 +0200
Subject: [PATCH 5/9] third_party: Link nss_wrapper against pthread
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

nss_wrapper uses pthread_atfork() which is only provided by libpthread.
So we need an explicit dependency.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14140

Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
Pair-Programmed-With: Isaac Boukris <iboukris@gmail.com>
Reviewed-by: Matthias Dieter Wallnöfer <mdw@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
(cherry picked from commit 68d8a02ef57cce29e4ff3ef1b792adfc10d0b916)
---
 third_party/nss_wrapper/wscript | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/third_party/nss_wrapper/wscript b/third_party/nss_wrapper/wscript
index 2e9d1db13b1..40848603b36 100644
--- a/third_party/nss_wrapper/wscript
+++ b/third_party/nss_wrapper/wscript
@@ -89,6 +89,6 @@ def build(bld):
         # breaks preloading!
         bld.SAMBA_LIBRARY('nss_wrapper',
                           source='nss_wrapper.c',
-                          deps='dl',
+                          deps='dl pthread',
                           install=False,
                           realname='libnss-wrapper.so')
-- 
2.23.0


From 2f27ac30a8d75b09f3ac9ac32d3a0e23d3d48581 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn@samba.org>
Date: Mon, 23 Sep 2019 17:40:13 +0200
Subject: [PATCH 6/9] third_party: Link uid_wrapper against pthread
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

uid_wrapper uses pthread_atfork() which is only provided by libpthread.                                                                                   │····················
So we need an explicit dependency.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14140

Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
Pair-Programmed-With: Isaac Boukris <iboukris@gmail.com>
Reviewed-by: Matthias Dieter Wallnöfer <mdw@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
(cherry picked from commit bd0cd8e13234d684da77a65f6fdaea2572625369)
---
 third_party/uid_wrapper/wscript | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/third_party/uid_wrapper/wscript b/third_party/uid_wrapper/wscript
index 61d8a189625..738343f49e4 100644
--- a/third_party/uid_wrapper/wscript
+++ b/third_party/uid_wrapper/wscript
@@ -119,6 +119,6 @@ def build(bld):
         # breaks preloading!
         bld.SAMBA_LIBRARY('uid_wrapper',
                           source='uid_wrapper.c',
-                          deps='dl',
+                          deps='dl pthread',
                           install=False,
                           realname='libuid-wrapper.so')
-- 
2.23.0


From bf1b1e4b85c516a480c5a29a98a8761870a59735 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn@samba.org>
Date: Mon, 23 Sep 2019 16:53:12 +0200
Subject: [PATCH 7/9] waf:replace: Do not link against libpthread if not
 necessary
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
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 <asn@samba.org>
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
Pair-Programmed-With: Isaac Boukris <iboukris@gmail.com>
Reviewed-by: Matthias Dieter Wallnöfer <mdw@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
(cherry picked from commit 9499db075b72b147e2ff9bb78e9d5edbaac14e69)
---
 lib/replace/wscript | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/replace/wscript b/lib/replace/wscript
index d8423b1d281..b5919835c0b 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -551,6 +551,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'
@@ -563,10 +568,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.23.0


From cce4834d7aacf69975bc5acf24c66e3a2913f231 Mon Sep 17 00:00:00 2001
From: Isaac Boukris <iboukris@gmail.com>
Date: Tue, 15 Oct 2019 13:52:42 +0300
Subject: [PATCH 8/9] nsswitch: Link stress-nss-libwbclient against pthread

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14140

Signed-off-by: Isaac Boukris <iboukris@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
(cherry picked from commit d473f1e38c2822746030516269b4d70032cf9b2e)
---
 nsswitch/wscript_build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nsswitch/wscript_build b/nsswitch/wscript_build
index 6acc4a19b9b..861ed2f23bf 100644
--- a/nsswitch/wscript_build
+++ b/nsswitch/wscript_build
@@ -20,7 +20,7 @@ bld.SAMBA_BINARY('nsstest',
 if bld.CONFIG_SET('HAVE_PTHREAD'):
     bld.SAMBA_BINARY('stress-nss-libwbclient',
 		     source='stress-nss-libwbclient.c',
-		     deps='wbclient',
+		     deps='wbclient pthread',
 		     install=False
 		     )
 
-- 
2.23.0


From d3609fef9b4e7ac76d4dfe2f387e89e3a79749c6 Mon Sep 17 00:00:00 2001
From: Isaac Boukris <iboukris@gmail.com>
Date: Tue, 15 Oct 2019 17:01:48 +0300
Subject: [PATCH 9/9] s3:libsmb: Link libsmb against pthread

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14140

Signed-off-by: Isaac Boukris <iboukris@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
(cherry picked from commit 7259197bf716f8b81dea74beefe6ee3b1239f172)
---
 source3/libsmb/wscript | 1 +
 1 file changed, 1 insertion(+)

diff --git a/source3/libsmb/wscript b/source3/libsmb/wscript
index d9e933e9e9f..febff9df7fc 100644
--- a/source3/libsmb/wscript
+++ b/source3/libsmb/wscript
@@ -16,6 +16,7 @@ def build(bld):
                               libsmb_xattr.c
                               libsmb_setget.c''',
                        public_deps='''
+                                   pthread
                                    talloc
                                    smbconf
                                    libsmb
-- 
2.23.0