Skip to content

Commit fb2cc76

Browse files
committed
Force patchelf to use 64KB page size on aarch64/powerpc64le
This fixes problems with binaries on these two platforms that often use these large page sizes.
1 parent 4e31741 commit fb2cc76

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

Make.inc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,20 @@ else
928928
PCRE_CONFIG := $(build_depsbindir)/pcre2-config
929929
endif
930930

931+
ifeq ($(USE_SYSTEM_PATCHELF),1)
932+
PATCHELF := patchelf
933+
else
934+
PATCHELF := $(build_depsbindir)/patchelf
935+
end
936+
937+
# On aarch64 and powerpc64le, we assume the page size is 64K. Our binutils linkers
938+
# and such already assume this, but `patchelf` seems to be behind the times. We
939+
# explicitly tell it to use this large page size so that when we rewrite rpaths and
940+
# such, we don't accidentally create incorrectly-aligned sections in our ELF files.
941+
ifneq (,$(filter $(ARCH),aarch64 powerpc64le))
942+
PATCHELF += --page-size=65536
943+
endif
944+
931945
# Use ILP64 BLAS interface when building openblas from source on 64-bit architectures
932946
ifeq ($(BINARY), 64)
933947
ifeq ($(USE_SYSTEM_BLAS), 1)

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ ifneq ($(DARWIN_FRAMEWORK),1)
392392
endif
393393
else ifneq (,$(findstring $(OS),Linux FreeBSD))
394394
for j in $(JL_TARGETS) ; do \
395-
patchelf --set-rpath '$$ORIGIN/$(private_libdir_rel):$$ORIGIN/$(libdir_rel)' $(DESTDIR)$(bindir)/$$j; \
395+
$(PATCHELF) --set-rpath '$$ORIGIN/$(private_libdir_rel):$$ORIGIN/$(libdir_rel)' $(DESTDIR)$(bindir)/$$j; \
396396
done
397397
endif
398398

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

0 commit comments

Comments
 (0)