From cdfe53a93453d8cdf12cfaaea13574365fbba66b Mon Sep 17 00:00:00 2001 From: Samuel Cochran Date: Fri, 7 Dec 2018 15:27:30 +1100 Subject: [PATCH] Fix `make check` on darwin System Integrity Protection strips dynamic linker (dyld) environment variables, such as DYLD_LIBRARY_PATH, during exec(2), so we need to rewrite the load paths inside binaries when relocating then during make temp-install before make check on darwin. https://developer.apple.com/library/archive/documentation/Security/Conceptual/System_Integrity_Protection_Guide/RuntimeProtections/RuntimeProtections.html diff --git a/src/Makefile.global.in b/src/Makefile.global.in index 956fd274cd..48f2e2bcc7 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -390,6 +390,10 @@ ifeq ($(MAKELEVEL),0) rm -rf '$(abs_top_builddir)'/tmp_install $(MKDIR_P) '$(abs_top_builddir)'/tmp_install/log $(MAKE) -C '$(top_builddir)' DESTDIR='$(abs_top_builddir)'/tmp_install install >'$(abs_top_builddir)'/tmp_install/log/install.log 2>&1 + # darwin doesn't propagate DYLD_* vars due to system integrity + # protection, so we need to rewrite the load commands inside the + # binaries when relocating them + $(if $(filter $(PORTNAME),darwin),find '$(abs_top_builddir)/tmp_install$(bindir)' -type f -exec install_name_tool -change '$(libdir)/libpq.5.dylib' '$(abs_top_builddir)/tmp_install$(libdir)/libpq.5.dylib' {} \;) endif $(if $(EXTRA_INSTALL),for extra in $(EXTRA_INSTALL); do $(MAKE) -C '$(top_builddir)'/$$extra DESTDIR='$(abs_top_builddir)'/tmp_install install >>'$(abs_top_builddir)'/tmp_install/log/install.log || exit; done) endif