From: Andreas Schneider Date: Mon, 23 Sep 2019 13:14:24 +0000 (+0200) Subject: replace: Only link against librt if really needed X-Git-Tag: talloc-2.3.1~676 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=480152dd6729d4c58faca6f3e4fa91ff4614c272;p=thirdparty%2Fsamba.git 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 Signed-off-by: Isaac Boukris Pair-Programmed-With: Isaac Boukris Reviewed-by: Matthias Dieter Wallnöfer Reviewed-by: Alexander Bokovoy --- diff --git a/lib/replace/wscript b/lib/replace/wscript index c22262191c2..5b5a9ab39c0 100644 --- a/lib/replace/wscript +++ b/lib/replace/wscript @@ -459,11 +459,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 @@ -817,6 +834,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, @@ -856,7 +874,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'):