The Samba-Bugzilla – Attachment 15493 Details for
Bug 14140
Overlinking libreplace against librt and pthread against every binary or library causes issues
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch for 4.10
v4-10-test.patch (text/plain), 12.71 KB, created by
Andreas Schneider
on 2019-09-26 10:16:33 UTC
(
hide
)
Description:
patch for 4.10
Filename:
MIME Type:
Creator:
Andreas Schneider
Created:
2019-09-26 10:16:33 UTC
Size:
12.71 KB
patch
obsolete
>From b8cef968927d8080b033a682620559359d41ec2d 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/7] 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 629146f2deaf318da26d8601b861a6d84de6caa0 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/7] 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 843dd95a7ac8251da1c7d0130f6e06d2e75e94df 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/7] 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 f85758466298c24f42f37fbe25ac51c7e028cdce 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/7] 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 b223877b56c8390d61c234f0ed6c725b07ffb00d 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/7] 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 5ff385147920654c47f5e2ecd7e53431696ac7a4 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/7] 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 8d253442a7a7d760b534a282128c9bee6dec8f55 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/7] 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 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
ab
:
review+
Actions:
View
Attachments on
bug 14140
:
15492
|
15493
|
15542
|
15551
|
15552
|
15561