Hi folks 👋

Forgive me if I'm getting the mailing list etiquette wrong — first time poster.

I ended up sitting next to Thomas Munro at PGDU 2018 and talking about testing. 
While trying to get `make check` running on my macbook, I think I may have 
fixed this issue.

System Integrity Protection strips dynamic linker (dyld) environment variables, 
such as DYLD_LIBRARY_PATH, during exec(2) [1] so we need to rewrite the load 
paths inside binaries when relocating then during make temp-install before make 
check on darwin. Homebrew does something similar [2]. I've attached a patch 
which adjust the Makefile and gets make check working on my machine with SIP in 
tact.

Cheers,
Sam

  [1]: 
https://developer.apple.com/library/archive/documentation/Security/Conceptual/System_Integrity_Protection_Guide/RuntimeProtections/RuntimeProtections.html
  [2]: 
https://github.com/Homebrew/brew/blob/77e6a927504c51a1393a0a6ccaf6f2611ac4a9d5/Library/Homebrew/os/mac/keg.rb#L17-L30


On Tue, Sep 18, 2018, at 8:39 AM, Tom Lane wrote:
> Thomas Munro <thomas.mu...@enterprisedb.com> writes:
> > On Tue, Sep 18, 2018 at 2:14 AM Tom Lane <t...@sss.pgh.pa.us> wrote:
> >> "make check" generally won't work on OSX unless you've disabled SIP:
> >> https://www.howtogeek.com/230424/how-to-disable-system-integrity-protection-on-a-mac-and-why-you-shouldnt/
> 
> > Aha!  It looks like it was important to run "make install" before
> > running those tests.
> 
> Right.  If you don't want to disable SIP, you can work around it by always
> doing "make install" before "make check".  Kind of a PITA though.
> 
>                       regards, tom lane
> 
> 
From cdfe53a93453d8cdf12cfaaea13574365fbba66b Mon Sep 17 00:00:00 2001
From: Samuel Cochran <s...@sj26.com>
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

Reply via email to