Skip to content

Commit

Permalink
Force patchelf to use 64KB page size on aarch64/powerpc64le
Browse files Browse the repository at this point in the history
This fixes problems with binaries on these two platforms that often use
these large page sizes.
  • Loading branch information
staticfloat committed Nov 1, 2019
1 parent 4e31741 commit fb2cc76
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
14 changes: 14 additions & 0 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,20 @@ else
PCRE_CONFIG := $(build_depsbindir)/pcre2-config
endif

ifeq ($(USE_SYSTEM_PATCHELF),1)
PATCHELF := patchelf
else
PATCHELF := $(build_depsbindir)/patchelf
end

# On aarch64 and powerpc64le, we assume the page size is 64K. Our binutils linkers
# and such already assume this, but `patchelf` seems to be behind the times. We
# explicitly tell it to use this large page size so that when we rewrite rpaths and
# such, we don't accidentally create incorrectly-aligned sections in our ELF files.
ifneq (,$(filter $(ARCH),aarch64 powerpc64le))
PATCHELF += --page-size=65536
endif

# Use ILP64 BLAS interface when building openblas from source on 64-bit architectures
ifeq ($(BINARY), 64)
ifeq ($(USE_SYSTEM_BLAS), 1)
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ ifneq ($(DARWIN_FRAMEWORK),1)
endif
else ifneq (,$(findstring $(OS),Linux FreeBSD))
for j in $(JL_TARGETS) ; do \
patchelf --set-rpath '$$ORIGIN/$(private_libdir_rel):$$ORIGIN/$(libdir_rel)' $(DESTDIR)$(bindir)/$$j; \
$(PATCHELF) --set-rpath '$$ORIGIN/$(private_libdir_rel):$$ORIGIN/$(libdir_rel)' $(DESTDIR)$(bindir)/$$j; \
done
endif

Expand All @@ -412,15 +412,15 @@ endif
endif
# On FreeBSD, remove the build's libdir from each library's RPATH
ifeq ($(OS),FreeBSD)
$(JULIAHOME)/contrib/fixup-rpath.sh $(build_depsbindir)/patchelf $(DESTDIR)$(libdir) $(build_libdir)
$(JULIAHOME)/contrib/fixup-rpath.sh $(build_depsbindir)/patchelf $(DESTDIR)$(private_libdir) $(build_libdir)
$(JULIAHOME)/contrib/fixup-rpath.sh $(build_depsbindir)/patchelf $(DESTDIR)$(bindir) $(build_libdir)
$(JULIAHOME)/contrib/fixup-rpath.sh "$(PATCHELF)" $(DESTDIR)$(libdir) $(build_libdir)
$(JULIAHOME)/contrib/fixup-rpath.sh "$(PATCHELF)" $(DESTDIR)$(private_libdir) $(build_libdir)
$(JULIAHOME)/contrib/fixup-rpath.sh "$(PATCHELF)" $(DESTDIR)$(bindir) $(build_libdir)
# Set libgfortran's RPATH to ORIGIN instead of GCCPATH. It's only libgfortran that
# needs to be fixed here, as libgcc_s and libquadmath don't have RPATHs set. If we
# don't set libgfortran's RPATH, it won't be able to find its friends on systems
# that don't have the exact GCC port installed used for the build.
for lib in $(DESTDIR)$(private_libdir)/libgfortran*$(SHLIB_EXT)*; do \
$(build_depsbindir)/patchelf --set-rpath '$$ORIGIN' $$lib; \
$(PATCHELF) --set-rpath '$$ORIGIN' $$lib; \
done
endif

Expand Down

0 comments on commit fb2cc76

Please sign in to comment.