build: Disallow unresolved symbol references

In the past, it was often[1] forgotten for xlators to be linked against
the symbols they refer to. This often caused glusterd2 to fail while
loading xlator's shared object (.so) file.

This change adds "--no-undefined" as a linker flag which causes the
linker to treat unresolved symbol references as an error and hence fail
linking.

[1]:
https://review.gluster.org/#/c/19912/
https://review.gluster.org/#/c/19664/
https://review.gluster.org/#/c/19056/
https://review.gluster.org/#/c/17659/
https://bugzilla.redhat.com/show_bug.cgi?id=1532238

Bonus:
Added cloudsync and utime xlator's generated source files to .gitignore

Updates: bz#1193929
Change-Id: I9604a4a87b7313a5fa43bda5fdb37dfa7ef8facd
Signed-off-by: Prashanth Pai <ppai@redhat.com>
This commit is contained in:
Prashanth Pai 2018-05-10 18:25:56 +05:30 committed by Amar Tumballi
parent c2cf3f686f
commit 89e1a4e572
16 changed files with 57 additions and 30 deletions

4
.gitignore vendored
View File

@ -127,3 +127,7 @@ extras/init.d/glustereventsd-Debian
extras/init.d/glustereventsd-FreeBSD
extras/init.d/glustereventsd-Redhat
tools/setgfid2path/src/gluster-setgfid2path
xlators/features/cloudsync/src/cloudsync-autogen-fops.c
xlators/features/cloudsync/src/cloudsync-autogen-fops.h
xlators/features/utime/src/utime-autogen-fops.c
xlators/features/utime/src/utime-autogen-fops.h

View File

@ -340,11 +340,12 @@ AC_ARG_WITH([ipv6-default],
AC_HELP_STRING([--with-ipv6-default], [Set IPv6 as default.]),
[with_ipv6_default=${with_libtirpc}], [with_ipv6_default="no"])
if test "x$ac_cv_file__etc_redhat_release" = "xyes"; then
if rpm -qa centos-release | grep centos; then
if rpm -q centos-release | grep "release-6"; then
with_ipv6_default="no"
fi
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
@ -1600,7 +1601,20 @@ AC_SUBST(USE_EC_DYNAMIC_NEON)
dnl libglusterfs.so uses math functions
GF_LDADD="${GF_LDADD} ${MATH_LIB}"
GF_XLATOR_DEFAULT_LDFLAGS='-avoid-version -export-symbols $(top_srcdir)/xlators/xlator.sym'
case $host_os in
dnl Can't use libtool's portable "-no-undefined" as it seems to be ignored on Linux
linux*)
GF_NO_UNDEFINED='-Wl,--no-undefined'
;;
darwin*)
GF_NO_UNDEFINED='-Wl,-undefined'
;;
*)
dnl There's an issue on FreeBSD with reference to __progname used in some parts of code
GF_NO_UNDEFINED=''
;;
esac
GF_XLATOR_DEFAULT_LDFLAGS='-avoid-version -export-symbols $(top_srcdir)/xlators/xlator.sym '${GF_NO_UNDEFINED}
AC_SUBST(GF_HOST_OS)
AC_SUBST(GF_CFLAGS)
@ -1612,6 +1626,7 @@ AC_SUBST(RLLIBS)
AC_SUBST(LIBAIO)
AC_SUBST(AM_MAKEFLAGS)
AC_SUBST(AM_LIBTOOLFLAGS)
AC_SUBST(GF_NO_UNDEFINED)
AC_SUBST(GF_XLATOR_DEFAULT_LDFLAGS)
CONTRIBDIR='$(top_srcdir)/contrib'

View File

@ -1118,3 +1118,5 @@ glusterfs_leaseid_buf_get
glusterfs_leaseid_exist
gf_replace_old_iatt_in_dict
gf_replace_new_iatt_in_dict
gf_changelog_init
gf_changelog_register_generic

View File

@ -18,20 +18,24 @@ nufa_la_SOURCES = $(dht_common_source) nufa.c
switch_la_SOURCES = $(dht_common_source) switch.c
tier_la_SOURCES = $(dht_common_source) tier.c tier-common.c
dht_la_LDFLAGS = -module -avoid-version -export-symbols \
$(top_srcdir)/xlators/cluster/dht/src/dht.sym
dht_la_LDFLAGS = -module -avoid-version \
-export-symbols $(top_srcdir)/xlators/cluster/dht/src/dht.sym \
$(GF_NO_UNDEFINED)
dht_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
nufa_la_LDFLAGS = -module -avoid-version -export-symbols \
$(top_srcdir)/xlators/cluster/dht/src/nufa.sym
nufa_la_LDFLAGS = -module -avoid-version \
-export-symbols $(top_srcdir)/xlators/cluster/dht/src/nufa.sym \
$(GF_NO_UNDEFINED)
nufa_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
switch_la_LDFLAGS = -module -avoid-version -export-symbols \
$(top_srcdir)/xlators/cluster/dht/src/switch.sym
switch_la_LDFLAGS = -module -avoid-version
-export-symbols $(top_srcdir)/xlators/cluster/dht/src/switch.sym \
$(GF_NO_UNDEFINED)
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
tier_la_LDFLAGS = -module -avoid-version \
-export-symbols $(top_srcdir)/xlators/cluster/dht/src/tier.sym \
$(GF_NO_UNDEFINED)
tier_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
noinst_HEADERS = dht-common.h dht-mem-types.h dht-messages.h \

View File

@ -6,7 +6,7 @@ dht2c_sources = dht2-client-main.c
dht2common_sources = $(top_srcdir)/xlators/experimental/dht2/dht2-common/src/dht2-common-map.c
dht2c_la_SOURCES = $(dht2c_sources) $(dht2common_sources)
dht2c_la_LDFLAGS = -module -avoid-version
dht2c_la_LDFLAGS = -module $(GF_XLATOR_DEFAULT_LDFLAGS)
dht2c_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
AM_CFLAGS = -Wall $(GF_CFLAGS)

View File

@ -8,7 +8,7 @@ dht2s_sources = dht2-server-main.c
dht2common_sources = $(top_srcdir)/xlators/experimental/dht2/dht2-common/src/dht2-common-map.c
dht2s_la_SOURCES = $(dht2s_sources) $(dht2common_sources)
dht2s_la_LDFLAGS = -module -avoid-version
dht2s_la_LDFLAGS = -module $(GF_XLATOR_DEFAULT_LDFLAGS)
dht2s_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
AM_CFLAGS = -Wall $(GF_CFLAGS)

View File

@ -6,7 +6,7 @@ endif
noinst_HEADERS = fdl.h
nodist_fdl_la_SOURCES = fdl.c
fdl_la_LDFLAGS = -module -avoid-version
fdl_la_LDFLAGS = -module $(GF_XLATOR_DEFAULT_LDFLAGS)
fdl_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
if WITH_SERVER

View File

@ -6,7 +6,7 @@ xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/experimental
nodist_jbrc_la_SOURCES = jbrc-cg.c
CLEANFILES = $(nodist_jbrc_la_SOURCES)
jbrc_la_LDFLAGS = -module -avoid-version
jbrc_la_LDFLAGS = -module $(GF_XLATOR_DEFAULT_LDFLAGS)
jbrc_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
noinst_HEADERS = $(top_srcdir)/xlators/lib/src/libxlator.h \

View File

@ -6,7 +6,7 @@ xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/experimental
nodist_jbr_la_SOURCES = jbr-cg.c
CLEANFILES = $(nodist_jbr_la_SOURCES)
jbr_la_LDFLAGS = -module -avoid-version
jbr_la_LDFLAGS = -module $(GF_XLATOR_DEFAULT_LDFLAGS)
jbr_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \
$(top_builddir)/api/src/libgfapi.la

View File

@ -6,7 +6,7 @@ xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/experimental
posix2_ds_sources = posix2-ds-main.c
posix2_ds_la_SOURCES = $(posix2_ds_sources)
posix2_ds_la_LDFLAGS = -module -avoid-version
posix2_ds_la_LDFLAGS = -module $(GF_XLATOR_DEFAULT_LDFLAGS)
posix2_ds_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
posix2_ds_la_LIBADD += $(top_builddir)/xlators/experimental/posix2/common/src/libposix2common.la

View File

@ -6,7 +6,7 @@ xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/experimental
posix2_mds_sources = posix2-mds-main.c
posix2_mds_la_SOURCES = $(posix2_mds_sources)
posix2_mds_la_LDFLAGS = -module -avoid-version
posix2_mds_la_LDFLAGS = -module $(GF_XLATOR_DEFAULT_LDFLAGS)
posix2_mds_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
posix2_mds_la_LIBADD += $(top_builddir)/xlators/experimental/posix2/common/src/libposix2common.la

View File

@ -13,8 +13,9 @@ libgfchangelog_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \
$(top_builddir)/rpc/xdr/src/libgfxdr.la \
$(top_builddir)/rpc/rpc-lib/src/libgfrpc.la
libgfchangelog_la_LDFLAGS = $(GF_LDFLAGS) -version-info \
$(LIBGFCHANGELOG_LT_VERSION)
libgfchangelog_la_LDFLAGS = $(GF_LDFLAGS) \
-version-info $(LIBGFCHANGELOG_LT_VERSION) \
$(GF_NO_UNDEFINED)
libgfchangelogdir = $(includedir)/glusterfs/gfchangelog
lib_LTLIBRARIES = libgfchangelog.la

View File

@ -15,9 +15,9 @@ AM_CFLAGS = $(PYTHONDEV_CPPFLAGS) -Wall -fno-strict-aliasing \
$(GF_CFLAGS)
# Flags to build glupy.so with
glupy_la_LDFLAGS = $(PYTHONDEV_LDFLAGS) -module -avoid-version \
-nostartfiles -export-symbols \
$(top_srcdir)/xlators/features/glupy/src/glupy.sym
glupy_la_LDFLAGS = $(PYTHONDEV_LDFLAGS) -module -avoid-version -nostartfiles \
-export-symbols $(top_srcdir)/xlators/features/glupy/src/glupy.sym \
$(GF_NO_UNDEFINED)
glupy_la_SOURCES = glupy.c
glupy_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \

View File

@ -10,7 +10,7 @@ utime_la_SOURCES = $(utime_sources)
nodist_utime_la_SOURCES = utime-autogen-fops.c utime-autogen-fops.h
BUILT_SOURCES = utime-autogen-fops.h
utime_la_LDFLAGS = -module -avoid-version
utime_la_LDFLAGS = -module $(GF_XLATOR_DEFAULT_LDFLAGS)
utime_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
noinst_HEADERS_utime = $(UTIME_SRC)/utime-helpers.h

View File

@ -4,8 +4,9 @@ endif
xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/nfs
nfsrpclibdir = $(top_srcdir)/rpc/rpc-lib/src
server_la_LDFLAGS = -module -avoid-version -export-symbols \
$(top_srcdir)/xlators/nfs/server/src/nfsserver.sym
server_la_LDFLAGS = -module -avoid-version \
-export-symbols $(top_srcdir)/xlators/nfs/server/src/nfsserver.sym \
$(GF_NO_UNDEFINED)
server_la_SOURCES = nfs.c nfs-common.c nfs-fops.c nfs-inodes.c \
nfs-generics.c mount3.c nfs3-fh.c nfs3.c nfs3-helpers.c nlm4.c \

View File

@ -1,6 +1,6 @@
xlator_LTLIBRARIES = nl-cache.la
xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/performance
nl_cache_la_LDFLAGS = -module -avoid-version
nl_cache_la_LDFLAGS = -module $(GF_XLATOR_DEFAULT_LDFLAGS)
nl_cache_la_SOURCES = nl-cache.c nl-cache-helper.c
nl_cache_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
noinst_HEADERS = nl-cache.h nl-cache-mem-types.h nl-cache-messages.h