~ chicken-core (chicken-5) 3afc649cd97cd5ce62a560e7f28a6e74a2145014
commit 3afc649cd97cd5ce62a560e7f28a6e74a2145014
Author: felix <felix@call-with-current-continuation.org>
AuthorDate: Sun Jun 23 12:15:52 2024 +0200
Commit: Peter Bex <peter@more-magic.net>
CommitDate: Tue Jun 25 09:42:41 2024 +0200
Add build-directory to rpath on MacOS
When running the checks without installing the overrides for DYLD_LIBRARY_PATH
are not seen due to changes in the way certain environment variables are
passed to subprocesses which will result in linking the wrong libchicken.dylib
at runtime. This patch adds the build directory to the rpath of the
"chicken" binary to make the checks run and changes the post-install
command for patching the rpath to the final installation directory to
add the build-path to the change list. install_name_tool accepts any
number of "-change" pairs and will silently ignore those that don't
apply.
Thanks to Christian Himpe for helping to investigate the problem and
test the fix.
Signed-off-by: Peter Bex <peter@more-magic.net>
diff --git a/Makefile.macosx b/Makefile.macosx
index 32253291..59c6f374 100644
--- a/Makefile.macosx
+++ b/Makefile.macosx
@@ -51,7 +51,9 @@ endif
endif
LIBRARIAN ?= $(XCODE_TOOL_PATH)/ar
LINKER_LINK_SHARED_LIBRARY_OPTIONS = -dynamiclib -compatibility_version 1 -current_version 1.0 -install_name $@
-POSTINSTALL_PROGRAM_FLAGS = -change lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO) $(LIBDIR)/lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO)
+HERE = $(shell pwd)
+PREINSTALL_PROGRAM_FIXUP = $(POSTINSTALL_PROGRAM) -change lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO) $(HERE)/lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO)
+POSTINSTALL_PROGRAM_FLAGS = -change lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO) $(LIBDIR)/lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO) -change $(HERE)/lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO) $(LIBDIR)/lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO)
LIBRARIAN_OPTIONS = scru
LINKER_LINK_SHARED_DLOADABLE_OPTIONS = -bundle -L.
ASSEMBLER_OPTIONS =
diff --git a/defaults.make b/defaults.make
index 9e27f5cd..e471c3f0 100644
--- a/defaults.make
+++ b/defaults.make
@@ -90,6 +90,7 @@ REMOVE_COMMAND ?= rm
INSTALL_PROGRAM ?= install
MAKEDIR_COMMAND ?= $(INSTALL_PROGRAM)
endif
+PREINSTALL_PROGRAM_FIXUP ?= true
POSTINSTALL_STATIC_LIBRARY ?= true
POSTINSTALL_PROGRAM ?= true
diff --git a/rules.make b/rules.make
index f7c22b7b..24ad7e2c 100644
--- a/rules.make
+++ b/rules.make
@@ -218,6 +218,7 @@ lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(A): $(LIBCHICKEN_STATIC_OBJECTS)
$(CHICKEN_SHARED_EXECUTABLE): $(COMPILER_OBJECTS) $(PRIMARY_LIBCHICKEN)
$(LINKER) $(LINKER_OPTIONS) $(LINKER_EXECUTABLE_OPTIONS) $(COMPILER_OBJECTS) $(LINKER_OUTPUT) \
$(LINKER_LIBRARY_PREFIX)$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(LINKER_LIBRARY_SUFFIX) $(LINKER_LINK_SHARED_PROGRAM_OPTIONS) $(LIBRARIES)
+ $(PREINSTALL_PROGRAM_FIXUP) $(CHICKEN_SHARED_EXECUTABLE)
define declare-program-from-object
$(1)-RC_FILE = $(if $(and $(RC_COMPILER),$(3)),$(2).rc$(O))
Trap