Skip to content

Commit

Permalink
Merge #55129
Browse files Browse the repository at this point in the history
55129: build: correct ELF info for libgeos r=petermattis a=otan

Looks like cross compiling with rpath does not work, so install patchelf
and use them on the given .so files such that dlopen works using the
regular pattern.

Refs #54841

Release note (general change, bug fix): Fixed the rpath and so names of
libgeos.so and libgeos_c.so such that a dlopen to libgeos.so is not
needed.



Co-authored-by: Oliver Tan <[email protected]>
  • Loading branch information
craig[bot] and otan committed Oct 2, 2020
2 parents 411cb5b + 9fa2cfa commit e2627f4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ endif

target-is-windows := $(findstring w64,$(TARGET_TRIPLE))
target-is-macos := $(findstring darwin,$(TARGET_TRIPLE))
target-is-linux := $(findstring linux,$(TARGET_TRIPLE))

# CMAKE_TARGET_MESSAGES=OFF prevents CMake from printing progress messages
# whenever a target is fully built to prevent spammy output from make when
Expand Down Expand Up @@ -778,6 +779,9 @@ ifdef is-cross-compile
ifdef target-is-macos
geos_require_install_name_tool := 1
endif
ifdef target-is-linux
geos_require_patchelf := 1
endif
endif

# For dlopen to work with OSX from any location, we need the @rpath directory prefix.
Expand All @@ -790,6 +794,14 @@ $(LIBGEOS): libgeos_inner .ALWAYS_REBUILD
$(TARGET_TRIPLE)-install_name_tool -id @rpath/libgeos.3.8.1.dylib lib/libgeos.dylib
$(TARGET_TRIPLE)-install_name_tool -id @rpath/libgeos_c.1.dylib lib/libgeos_c.dylib
$(TARGET_TRIPLE)-install_name_tool -change "$(GEOS_NATIVE_LIB_DIR)/libgeos.3.8.1.dylib" "@rpath/libgeos.3.8.1.dylib" lib.docker_amd64/libgeos_c.dylib
else ifdef geos_require_patchelf
# We apply a similar fix for linux, allowing one to dlopen libgeos_c.so without
# dlopening libgeos.so. Setting the rpath in the CMakeLists.txt does not work
# for cross compilation.
$(LIBGEOS): libgeos_inner .ALWAYS_REBUILD
patchelf --set-rpath '/usr/local/lib/cockroach/' lib/libgeos_c.so
patchelf --set-soname libgeos.so lib/libgeos.so
patchelf --replace-needed libgeos.so.3.8.1 libgeos.so lib/libgeos_c.so
else
$(LIBGEOS): libgeos_inner .ALWAYS_REBUILD
endif
Expand Down
2 changes: 1 addition & 1 deletion build/builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -euo pipefail

image=cockroachdb/builder
version=20200818-182851
version=20201001-110640

function init() {
docker build --tag="${image}" "$(dirname "${0}")/builder"
Expand Down
1 change: 1 addition & 0 deletions build/builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libncurses-dev \
make \
patch \
patchelf \
texinfo \
xz-utils \
&& apt-get clean
Expand Down
2 changes: 1 addition & 1 deletion c-deps/geos-rebuild
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Bump the version below when changing geos configure flags. Search for "BUILD
ARTIFACT CACHING" in build/common.mk for rationale.

4
5

0 comments on commit e2627f4

Please sign in to comment.