--- /dev/null
+#ifndef _REPLACE_BUILTIN_LINKING_H_
+#define _REPLACE_BUILTIN_LINKING_H_
+
+/*
+ * In the builtin case we don't want to depend on
+ * libbsd as that would inject a lot of symbols
+ * with very common names including crypto related
+ * stuff, we want to avoid that for builtin linking
+ * of plugins.
+ */
+
+#ifdef HAVE_STRLCPY_IN_LIBBSD
+#undef HAVE_STRLCPY
+#undef HAVE_STRLCAT
+#endif /* HAVE_STRLCPY_IN_LIBBSD */
+
+#ifdef HAVE_CLOSEFROM_IN_LIBBSD
+#undef HAVE_CLOSEFROM
+#endif /* HAVE_CLOSEFROM_IN_LIBBSD */
+
+#ifdef HAVE_GETPEEREID_IN_LIBBSD
+#undef HAVE_GETPEEREID
+#endif /* HAVE_GETPEEREID_IN_LIBBSD */
+
+#ifdef HAVE_SETPROCTITLE_IN_LIBBSD
+#undef HAVE_SETPROCTITLE
+#endif /* HAVE_SETPROCTITLE_IN_LIBBSD */
+#ifdef HAVE_SETPROCTITLE_INIT_IN_LIBBSD
+#undef HAVE_SETPROCTITLE_INIT
+#endif /* HAVE_SETPROCTITLE_INIT_IN_LIBBSD */
+
+#endif /* _REPLACE_BUILTIN_LINKING_H_ */
if not conf.CHECK_FUNCS('strlcpy strlcat'):
if conf.CHECK_FUNCS_IN('strlcpy strlcat', 'bsd', headers='bsd/string.h',
checklibc=True):
+ conf.DEFINE('HAVE_STRLCPY_IN_LIBBSD', 1)
strlcpy_in_bsd = True
+ libbsd_useful = True
elif conf.env.enable_fuzzing:
# Just to complicate it more, some versions of Honggfuzz have
# got strlcpy and strlcat in libc, but not in <string.h>
conf.CHECK_HEADERS('bsd/string.h')
if not conf.CHECK_FUNCS('getpeereid'):
- conf.CHECK_FUNCS_IN('getpeereid', 'bsd', headers='sys/types.h bsd/unistd.h')
+ if conf.CHECK_FUNCS_IN('getpeereid', 'bsd', headers='sys/types.h bsd/unistd.h'):
+ conf.DEFINE('HAVE_GETPEEREID_IN_LIBBSD', 1)
+ libbsd_useful = True
if not conf.CHECK_FUNCS_IN('setproctitle', 'setproctitle', headers='setproctitle.h'):
- conf.CHECK_FUNCS_IN('setproctitle', 'bsd', headers='sys/types.h bsd/unistd.h')
+ if conf.CHECK_FUNCS_IN('setproctitle', 'bsd', headers='sys/types.h bsd/unistd.h'):
+ conf.DEFINE('HAVE_SETPROCTITLE_IN_LIBBSD', 1)
+ libbsd_useful = True
if not conf.CHECK_FUNCS('setproctitle_init'):
- conf.CHECK_FUNCS_IN('setproctitle_init', 'bsd', headers='sys/types.h bsd/unistd.h')
+ if conf.CHECK_FUNCS_IN('setproctitle_init', 'bsd', headers='sys/types.h bsd/unistd.h'):
+ conf.DEFINE('HAVE_SETPROCTITLE_INIT_IN_LIBBSD', 1)
+ libbsd_useful = True
if not conf.CHECK_FUNCS('closefrom'):
- conf.CHECK_FUNCS_IN('closefrom', 'bsd', headers='bsd/unistd.h')
+ if conf.CHECK_FUNCS_IN('closefrom', 'bsd', headers='bsd/unistd.h'):
+ conf.DEFINE('HAVE_CLOSEFROM_IN_LIBBSD', 1)
+ libbsd_useful = True
+
+ if libbsd_useful:
+ conf.DEFINE('REPLACE_USE_LIBBSD', 1)
conf.CHECK_CODE('''
struct ucred cred;
break
extra_libs = ''
- if bld.CONFIG_SET('HAVE_LIBBSD'): extra_libs += ' bsd'
if bld.CONFIG_SET('HAVE_LIBRT'): extra_libs += ' rt'
if bld.CONFIG_SET('REPLACE_REQUIRES_LIBSOCKET_LIBNSL'): extra_libs += ' socket nsl'
+ # In the builtin case we don't want to depend on
+ # libbsd as that would inject a lot of symbols
+ # with very common names including crypto related
+ # stuff, we want to avoid that for builtin linking
+ # of plugins.
+ REPLACE_BUILTIN_SOURCE = REPLACE_HOSTCC_SOURCE
+ REPLACE_BUILTIN_SOURCE += ' closefrom.c'
+ REPLACE_BUILTIN_DEPS = extra_libs
+
+ if bld.CONFIG_SET('REPLACE_USE_LIBBSD'): extra_libs += ' bsd'
+
if not bld.CONFIG_SET('HAVE_CLOSEFROM'):
REPLACE_HOSTCC_SOURCE += ' closefrom.c'
# hide_symbols=bld.BUILTIN_LIBRARY('replace'),
private_library=True,
provide_builtin_linking=True,
+ builtin_source=REPLACE_BUILTIN_SOURCE,
+ builtin_deps='dl attr' + REPLACE_BUILTIN_DEPS,
deps='dl attr' + extra_libs)
replace_test_cflags = ''