From 89e1a4e5720509c096ff6860c1a8c483e0019278 Mon Sep 17 00:00:00 2001 From: Prashanth Pai Date: Thu, 10 May 2018 18:25:56 +0530 Subject: 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 --- .gitignore | 4 ++++ configure.ac | 27 +++++++++++++++++----- libglusterfs/src/libglusterfs.sym | 2 ++ xlators/cluster/dht/src/Makefile.am | 20 +++++++++------- .../experimental/dht2/dht2-client/src/Makefile.am | 2 +- .../experimental/dht2/dht2-server/src/Makefile.am | 2 +- xlators/experimental/fdl/src/Makefile.am | 2 +- xlators/experimental/jbr-client/src/Makefile.am | 2 +- xlators/experimental/jbr-server/src/Makefile.am | 2 +- xlators/experimental/posix2/ds/src/Makefile.am | 2 +- xlators/experimental/posix2/mds/src/Makefile.am | 2 +- xlators/features/changelog/lib/src/Makefile.am | 5 ++-- xlators/features/glupy/src/Makefile.am | 6 ++--- xlators/features/utime/src/Makefile.am | 2 +- xlators/nfs/server/src/Makefile.am | 5 ++-- xlators/performance/nl-cache/src/Makefile.am | 2 +- 16 files changed, 57 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index d9903bc3cd8..4b266e544bd 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/configure.ac b/configure.ac index b818d3fac0d..fe25ec2bc02 100644 --- a/configure.ac +++ b/configure.ac @@ -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' diff --git a/libglusterfs/src/libglusterfs.sym b/libglusterfs/src/libglusterfs.sym index 17651e47e36..c4027a759f7 100644 --- a/libglusterfs/src/libglusterfs.sym +++ b/libglusterfs/src/libglusterfs.sym @@ -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 diff --git a/xlators/cluster/dht/src/Makefile.am b/xlators/cluster/dht/src/Makefile.am index 525a214c24a..59f87cf7bdc 100644 --- a/xlators/cluster/dht/src/Makefile.am +++ b/xlators/cluster/dht/src/Makefile.am @@ -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 \ diff --git a/xlators/experimental/dht2/dht2-client/src/Makefile.am b/xlators/experimental/dht2/dht2-client/src/Makefile.am index a16b9df2f76..3a13a2a3986 100644 --- a/xlators/experimental/dht2/dht2-client/src/Makefile.am +++ b/xlators/experimental/dht2/dht2-client/src/Makefile.am @@ -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) diff --git a/xlators/experimental/dht2/dht2-server/src/Makefile.am b/xlators/experimental/dht2/dht2-server/src/Makefile.am index 12d66d126f0..c76fab0ca74 100644 --- a/xlators/experimental/dht2/dht2-server/src/Makefile.am +++ b/xlators/experimental/dht2/dht2-server/src/Makefile.am @@ -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) diff --git a/xlators/experimental/fdl/src/Makefile.am b/xlators/experimental/fdl/src/Makefile.am index da80ce28317..f39978c3930 100644 --- a/xlators/experimental/fdl/src/Makefile.am +++ b/xlators/experimental/fdl/src/Makefile.am @@ -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 diff --git a/xlators/experimental/jbr-client/src/Makefile.am b/xlators/experimental/jbr-client/src/Makefile.am index a894e69c8d7..15616d13798 100644 --- a/xlators/experimental/jbr-client/src/Makefile.am +++ b/xlators/experimental/jbr-client/src/Makefile.am @@ -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 \ diff --git a/xlators/experimental/jbr-server/src/Makefile.am b/xlators/experimental/jbr-server/src/Makefile.am index fe1342dbaff..b3ceb2d9eda 100644 --- a/xlators/experimental/jbr-server/src/Makefile.am +++ b/xlators/experimental/jbr-server/src/Makefile.am @@ -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 diff --git a/xlators/experimental/posix2/ds/src/Makefile.am b/xlators/experimental/posix2/ds/src/Makefile.am index d77ef8cb540..7a792a8d07b 100644 --- a/xlators/experimental/posix2/ds/src/Makefile.am +++ b/xlators/experimental/posix2/ds/src/Makefile.am @@ -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 diff --git a/xlators/experimental/posix2/mds/src/Makefile.am b/xlators/experimental/posix2/mds/src/Makefile.am index c6411f46114..0681cb73c45 100644 --- a/xlators/experimental/posix2/mds/src/Makefile.am +++ b/xlators/experimental/posix2/mds/src/Makefile.am @@ -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 diff --git a/xlators/features/changelog/lib/src/Makefile.am b/xlators/features/changelog/lib/src/Makefile.am index 92ee26827da..6baafd6cf27 100644 --- a/xlators/features/changelog/lib/src/Makefile.am +++ b/xlators/features/changelog/lib/src/Makefile.am @@ -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 diff --git a/xlators/features/glupy/src/Makefile.am b/xlators/features/glupy/src/Makefile.am index f1802c3545e..1fadbe3e68d 100644 --- a/xlators/features/glupy/src/Makefile.am +++ b/xlators/features/glupy/src/Makefile.am @@ -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 \ diff --git a/xlators/features/utime/src/Makefile.am b/xlators/features/utime/src/Makefile.am index 52f2eb5df24..e94a00a8326 100644 --- a/xlators/features/utime/src/Makefile.am +++ b/xlators/features/utime/src/Makefile.am @@ -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 diff --git a/xlators/nfs/server/src/Makefile.am b/xlators/nfs/server/src/Makefile.am index 5d1136d04ee..dfdcdee8a17 100644 --- a/xlators/nfs/server/src/Makefile.am +++ b/xlators/nfs/server/src/Makefile.am @@ -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 \ diff --git a/xlators/performance/nl-cache/src/Makefile.am b/xlators/performance/nl-cache/src/Makefile.am index f45e8be78c5..c44ce871627 100644 --- a/xlators/performance/nl-cache/src/Makefile.am +++ b/xlators/performance/nl-cache/src/Makefile.am @@ -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 -- cgit