提交 da4d7f95 编写于 作者: B Bradford D. Boyle 提交者: Bradford D. Boyle

Using $ORIGIN as RUNPATH for runtime link

When upgrading from GPDB5 to GPDB6, gpupgrade will need to be able to call
binaries from both major versions. Relying on LD_LIBRARY_PATH is not an option
because this can cause binaries to load libraries from the wrong version.
Instead, we need the libraries to have RPATH/RUNPATH set correctly. Since the
built binaries may be relocated we need to use a relative path.

This commit disables the rpath configure option (which would result in an
absolute path) and use LDFLAGS to use `$ORIGIN`.

For most ELF files a RUNPATH of `$ORIGIN/../lib` is correct. For pygresql
python module and the quicklz_compressor extension, the RUNPATH needs to be
adjusted accordingly. The LDFLAGS for those artifacts can be modified with
different environment variables PYGRESQL_LDFLAGS and QUICKLZ_LDFLAGS.

We always use `--enable-new-dtags` to set RUNPATH. On CentOS 6, with new dtags,
both DT_RPATH and DT_RUNPATH are set and DT_RPATH will be ignored.

[#171588878]
Co-authored-by: NBradford D. Boyle <bboyle@pivotal.io>
Co-authored-by: NXin Zhang <xzhang@pivotal.io>
(cherry picked from commit 2eec06b39abe8cb5370e949056f26997b9d02572)
上级 5e139b76
......@@ -181,6 +181,8 @@ aix7_ppc_64_CONFIG_ADDITIONS=LDFLAGS="-Wl,-bbigtoc -L/usr/lib/threads"
CONFIG_ADDITIONS=$($(BLD_ARCH)_CONFIG_ADDITIONS)
CONFIGFLAGS+= $(CONFIG_ADDITIONS)
CONFIGFLAGS+= --disable-rpath
CONFIGFLAGS+= LDFLAGS='-Wl,--enable-new-dtags -Wl,-rpath,\$$$$ORIGIN/../lib'
RECONFIG :
rm -f Debug/GNUmakefile
......@@ -248,7 +250,8 @@ BLD_GPDB_BUILDSET=$($(BLD_ARCH)_GPDB_BUILDSET)
# set default build steps
define BUILD_STEPS
@rm -rf $(INSTLOC)
cd $(BUILDDIR) && $(MAKE) $(PARALLEL_MAKE_OPTS) install
cd $(BUILDDIR) && PYGRESQL_LDFLAGS='-Wl,-rpath,\$$$$ORIGIN/../../../lib -Wl,--enable-new-dtags' QUICKLZ_LDFLAGS='-Wl,-rpath,\$$$$ORIGIN/../../lib -Wl,--enable-new-dtags' $(MAKE) $(PARALLEL_MAKE_OPTS) install
#@$(MAKE) greenplum_path INSTLOC=$(INSTLOC)
#@$(MAKE) mgmtcopy INSTLOC=$(INSTLOC)
@$(MAKE) mkpgbouncer INSTLOC=$(INSTLOC) BUILDDIR=$(BUILDDIR)
@$(MAKE) copylibs INSTLOC=$(INSTLOC)
......
......@@ -76,7 +76,7 @@ PYGRESQL_DIR=PyGreSQL-$(PYGRESQL_VERSION)
pygresql:
@echo "--- PyGreSQL"
cd $(PYLIB_SRC_EXT)/ && $(TAR) xzf $(PYGRESQL_DIR).tar.gz
cd $(PYLIB_SRC_EXT)/$(PYGRESQL_DIR)/ && PATH=$(bindir):$$PATH python setup.py build
cd $(PYLIB_SRC_EXT)/$(PYGRESQL_DIR)/ && PATH=$(bindir):$$PATH LDFLAGS='$(LDFLAGS) $(PYGRESQL_LDFLAGS)' python setup.py build
cp -r $(PYLIB_SRC_EXT)/$(PYGRESQL_DIR)/build/lib*/* $(PYLIB_DIR)/
#
......
......@@ -16,6 +16,12 @@ else
include $(top_srcdir)/contrib/contrib-global.mk
endif
# when libquicklz is vendored, it is copied in to GPHOME/lib
# the quicklz_compressor extension is located in GPHOME/lib/postgresql/
ifdef QUICKLZ_LDFLAGS
LDFLAGS += $(QUICKLZ_LDFLAGS)
endif
# Install into cdb_init.d, so that the catalog changes performed by initdb,
# and the compressor is available in all databases.
.PHONY: install-data
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册