diff options
author | Niels de Vos <ndevos@redhat.com> | 2018-08-09 15:52:19 +0200 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-08-30 05:41:26 +0000 |
commit | 44e40404ed1223ba9ccb879373da38efd5ba403c (patch) | |
tree | dcf7abb412ee5ad2280ede11872ce96ea36f1ac9 | |
parent | d27e8870c1882b1abfffefaf7b40bc7f2a1ec05f (diff) |
build: add --enable-asan configure options
Introduce a `./configure --enable-asan` to build with
`-fsanitize=address -fno-omit-frame-pointer` options. This uses the
libasan.so shared library, so that needs to be available.
While running builds with the ASAN options, several linker issues
surfaced and these have been addressed with this change as well.
Building with --enable-asan has been tested on Fedora 28.
Change-Id: I428a9da70dd8f7d0056cfbe5c398619a571469b2
Updates: #492
Signed-off-by: Niels de Vos <ndevos@redhat.com>
-rw-r--r-- | api/src/Makefile.am | 16 | ||||
-rw-r--r-- | configure.ac | 29 | ||||
-rw-r--r-- | glusterfsd/src/Makefile.am | 2 | ||||
-rw-r--r-- | xlators/cluster/dht/src/Makefile.am | 2 | ||||
-rw-r--r-- | xlators/features/cloudsync/src/Makefile.am | 2 | ||||
-rw-r--r-- | xlators/features/glupy/src/Makefile.am | 2 | ||||
-rw-r--r-- | xlators/protocol/server/src/Makefile.am | 2 |
7 files changed, 37 insertions, 18 deletions
diff --git a/api/src/Makefile.am b/api/src/Makefile.am index 3d25823925b..6ed30bc99f6 100644 --- a/api/src/Makefile.am +++ b/api/src/Makefile.am @@ -9,10 +9,12 @@ libgfapi_la_SOURCES = glfs.c glfs-mgmt.c glfs-fops.c glfs-resolve.c \ glfs-handleops.c libgfapi_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \ $(top_builddir)/rpc/rpc-lib/src/libgfrpc.la \ - $(top_builddir)/rpc/xdr/src/libgfxdr.la \ - $(GF_LDADD) + $(top_builddir)/rpc/xdr/src/libgfxdr.la + +libgfapi_la_LDFLAGS = -version-info $(GFAPI_LT_VERSION) $(GF_LDFLAGS) \ + $(GFAPI_EXTRA_LDFLAGS) $(ACL_LIBS) -AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \ +libgfapi_la_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \ -I$(top_srcdir)/rpc/rpc-lib/src \ -I$(top_srcdir)/rpc/xdr/src \ -I$(top_builddir)/rpc/xdr/src \ @@ -21,9 +23,6 @@ AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \ AM_CFLAGS = -Wall $(GF_CFLAGS) -libgfapi_la_LDFLAGS = -version-info $(GFAPI_LT_VERSION) $(GF_LDFLAGS) \ - $(GFAPI_EXTRA_LDFLAGS) $(ACL_LIBS) - xlator_LTLIBRARIES = api.la xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/mount # workaround for broken parallel install support in automake with LTLIBRARIES @@ -33,9 +32,12 @@ $(install_xlatorLTLIBRARIES): install-libLTLIBRARIES api_la_SOURCES = glfs-master.c api_la_DEPENDENCIES = libgfapi.la +api_la_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \ + -I$(top_srcdir)/rpc/xdr/src \ + -I$(top_builddir)/rpc/xdr/src api_la_LDFLAGS = -module $(GF_XLATOR_DEFAULT_LDFLAGS) +#api_la_LDFLAGS = -module $(GF_XLATOR_DEFAULT_LDFLAGS) $(GF_LDFLAGS) api_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \ $(top_builddir)/rpc/rpc-lib/src/libgfrpc.la \ $(top_builddir)/rpc/xdr/src/libgfxdr.la \ $(top_builddir)/api/src/libgfapi.la - diff --git a/configure.ac b/configure.ac index 54b52a35f8c..4db28ef1c11 100644 --- a/configure.ac +++ b/configure.ac @@ -318,6 +318,20 @@ else CFLAGS="${CFLAGS} -g -rdynamic" fi +AC_ARG_ENABLE([asan], + AC_HELP_STRING([--enable-asan], + [Enable Address Sanitizer support])) +if test "x$enable_asan" = "xyes"; then + BUILD_ASAN=yes + AC_CHECK_LIB([asan], [__asan_init], , + [AC_MSG_ERROR([libasan.so not found, this is required for --enable-asan])]) + GF_CFLAGS="${GF_CFLAGS} -O1 -g -fsanitize=address -fno-omit-frame-pointer" + dnl -lasan always need to be the first library, otherwise libxml complains + GF_LDFLAGS="-lasan ${GF_LDFLAGS}" +else + BUILD_ASAN=no +fi + dnl When possible, prefer libtirpc over glibc rpc. dnl @@ -345,13 +359,15 @@ AC_ARG_WITH([ipv6-default], AC_CHECK_FILE([/etc/centos-release]) if test "x$ac_cv_file__etc_centos_release" = "xyes"; then - dnl On CentOS '-ldl' isn't automatically added to LIBS - AC_CHECK_LIB([dl], [dlopen]) if grep "release 6" /etc/centos-release; then with_ipv6_default="no" fi fi +dnl On some distributions '-ldl' isn't automatically added to LIBS +AC_CHECK_LIB([dl], [dlopen], [LIB_DL=-ldl]) +AC_SUBST(LIB_DL) + AC_ARG_ENABLE([privport_tracking], AC_HELP_STRING([--disable-privport_tracking], [Disable internal tracking of privileged ports.])) @@ -1144,7 +1160,7 @@ fi AC_SUBST(GF_DISTRIBUTION) GF_HOST_OS="" -GF_LDFLAGS="-rdynamic" +GF_LDFLAGS="${GF_LDFLAGS} -rdynamic" dnl see --with-libtirpc option check above, libtirpc(-devel) is required for dnl ipv6-default @@ -1285,7 +1301,7 @@ case $host_os in GF_FUSE_CFLAGS="-DFUSERMOUNT_DIR=\\\"\$(sbindir)\\\"" GF_LDADD="${ARGP_LDADD}" if test "x$ac_cv_header_execinfo_h" = "xyes"; then - GF_LDFLAGS="-lexecinfo" + GF_LDFLAGS="${GF_LDFLAGS} -lexecinfo" fi GF_FUSE_LDADD="-lperfuse" BUILD_FUSE_CLIENT=yes @@ -1306,7 +1322,7 @@ case $host_os in GF_FUSE_CFLAGS="-DFUSERMOUNT_DIR=\\\"\$(sbindir)\\\"" GF_LDADD="${ARGP_LDADD}" if test "x$ac_cv_header_execinfo_h" = "xyes"; then - GF_LDFLAGS="-lexecinfo" + GF_LDFLAGS="${GF_LDFLAGS} -lexecinfo" fi BUILD_FUSE_CLIENT=yes BUILD_FUSERMOUNT=no @@ -1321,7 +1337,7 @@ case $host_os in GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_BASENAME" GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_DIRNAME" GF_LDADD="${ARGP_LDADD}" - GF_LDFLAGS="" + GF_LDFLAGS="${GF_LDFLAGS}" GF_FUSE_CFLAGS="-I\$(CONTRIBDIR)/macfuse" BUILD_FUSERMOUNT="no" FUSERMOUNT_SUBDIR="" @@ -1723,6 +1739,7 @@ echo "readline : $BUILD_READLINE" echo "georeplication : $BUILD_SYNCDAEMON" echo "Linux-AIO : $BUILD_LIBAIO" echo "Enable Debug : $BUILD_DEBUG" +echo "Enable ASAN : $BUILD_ASAN" echo "Block Device xlator : $BUILD_BD_XLATOR" echo "glupy : $BUILD_GLUPY" echo "Use syslog : $USE_SYSLOG" diff --git a/glusterfsd/src/Makefile.am b/glusterfsd/src/Makefile.am index 3286e639bcf..141a7108ae7 100644 --- a/glusterfsd/src/Makefile.am +++ b/glusterfsd/src/Makefile.am @@ -7,7 +7,7 @@ glusterfsd_SOURCES = glusterfsd.c glusterfsd-mgmt.c glusterfsd_LDADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \ $(top_builddir)/rpc/rpc-lib/src/libgfrpc.la \ $(top_builddir)/rpc/xdr/src/libgfxdr.la ${GF_LDADD} -glusterfsd_LDFLAGS = $(GF_LDFLAGS) +glusterfsd_LDFLAGS = $(GF_LDFLAGS) $(LIB_DL) gf_attach_SOURCES = gf_attach.c gf_attach_LDADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \ diff --git a/xlators/cluster/dht/src/Makefile.am b/xlators/cluster/dht/src/Makefile.am index 59f87cf7bdc..c8a343e0469 100644 --- a/xlators/cluster/dht/src/Makefile.am +++ b/xlators/cluster/dht/src/Makefile.am @@ -35,7 +35,7 @@ switch_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la tier_la_LDFLAGS = -module -avoid-version \ -export-symbols $(top_srcdir)/xlators/cluster/dht/src/tier.sym \ - $(GF_NO_UNDEFINED) + $(LIB_DL) $(GF_NO_UNDEFINED) tier_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la noinst_HEADERS = dht-common.h dht-mem-types.h dht-messages.h \ diff --git a/xlators/features/cloudsync/src/Makefile.am b/xlators/features/cloudsync/src/Makefile.am index 0f3381f1d7d..0c3966c968b 100644 --- a/xlators/features/cloudsync/src/Makefile.am +++ b/xlators/features/cloudsync/src/Makefile.am @@ -21,7 +21,7 @@ cloudsync_la_SOURCES = $(cloudsync_sources) $(cloudsynccommon_sources) nodist_cloudsync_la_SOURCES = cloudsync-autogen-fops.c cloudsync-autogen-fops.h BUILT_SOURCES = cloudsync-autogen-fops.h -cloudsync_la_LDFLAGS = -module $(GF_XLATOR_DEFAULT_LDFLAGS) +cloudsync_la_LDFLAGS = $(LIB_DL) -module $(GF_XLATOR_DEFAULT_LDFLAGS) cloudsync_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la diff --git a/xlators/features/glupy/src/Makefile.am b/xlators/features/glupy/src/Makefile.am index 1fadbe3e68d..b5d1c964432 100644 --- a/xlators/features/glupy/src/Makefile.am +++ b/xlators/features/glupy/src/Makefile.am @@ -21,7 +21,7 @@ glupy_la_LDFLAGS = $(PYTHONDEV_LDFLAGS) -module -avoid-version -nostartfiles \ glupy_la_SOURCES = glupy.c glupy_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \ - -lpthread -l$(BUILD_PYTHON_LIB) + -lpthread -l$(BUILD_PYTHON_LIB) $(LIB_DL) noinst_HEADERS = glupy.h diff --git a/xlators/protocol/server/src/Makefile.am b/xlators/protocol/server/src/Makefile.am index bcce615877a..01edbd35d9c 100644 --- a/xlators/protocol/server/src/Makefile.am +++ b/xlators/protocol/server/src/Makefile.am @@ -4,7 +4,7 @@ endif xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/protocol -server_la_LDFLAGS = -module $(GF_XLATOR_DEFAULT_LDFLAGS) +server_la_LDFLAGS = $(LIB_DL) -module $(GF_XLATOR_DEFAULT_LDFLAGS) server_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \ $(top_builddir)/rpc/rpc-lib/src/libgfrpc.la \ |