summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2019-09-23 15:14:24 +0200
committerStefan Metzmacher <metze@samba.org>2019-10-16 12:15:52 +0000
commita1309d360b9aef76c4dede9be6a0343874577a4e (patch)
treea2ab6718e690a2ade34ba37ab374aa5644b7e298
parentb0362fd07f87080f29ffee15874e381bc4481fe2 (diff)
downloadsamba-a1309d360b9aef76c4dede9be6a0343874577a4e.tar.gz
replace: Only link against librt if really needed
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)
-rw-r--r--lib/replace/wscript24
1 files 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'):