Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix install names in binaries #166

Merged
merged 2 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,13 @@ build/$(APP_NAME).app/Contents/%: Contents/%
mkdir -p $(@D)
cp -a $< $@

build/$(APP_NAME).app/Contents/Resources/$(APP_NAME).dmg: build/$(APP_NAME)-build.sparsebundle build/$(APP_NAME).app/Contents/Resources/icon.icns
build/$(APP_NAME).app/Contents/Resources/$(APP_NAME).dmg: build/$(APP_NAME)-build.sparsebundle build/$(APP_NAME).app/Contents/Resources/icon.icns fix_install_names.sh
[ ! -d $(VOLUME) ] || hdiutil detach $(VOLUME)
hdiutil attach \
build/$(APP_NAME)-build.sparsebundle \
-shadow
cd $(VOLUME) \
&& "$(CURDIR)/fix_install_names.sh"
cp build/$(APP_NAME).app/Contents/Resources/icon.icns $(VOLUME)/.VolumeIcon.icns
SetFile -c icnC $(VOLUME)/.VolumeIcon.icns
SetFile -a C $(VOLUME)
Expand Down Expand Up @@ -238,7 +240,7 @@ test-dmg:
cd $(TEST_DIR)/test-dmg \
&& source $(VOLUME)/etc/bashrc \
&& foamInstallationTest \
&& bash -ex "$(CURDIR)/test.sh"
&& "$(CURDIR)/test.sh"
hdiutil detach $(VOLUME)

clean-app:
Expand Down
34 changes: 34 additions & 0 deletions fix_install_names.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash -e

# -----------------------------------------------------------------------------
# Fix install names of libraries and binaries so that they load the MPI-enabled
# variants of libraries by default (instead of the "dummy" ones that don't work
# in parallel).
#
# This makes the installation less prone to runtime errors caused by the dummy
# libraries being loaded as a consequence of the System Integrity Protection
# (SIP) feature of macOS, which can clear the $DYLD_LIBRARY_PATH set by
# OpenFOAM.
#
# Discussed at https://develop.openfoam.com/Development/openfoam/-/issues/2801
# -----------------------------------------------------------------------------

source etc/bashrc

fix_install_names() {
for dummylib in $FOAM_LIBBIN/dummy/lib*; do
install_name_tool \
-change \
"$dummylib" \
"$FOAM_LIBBIN/$FOAM_MPI/$(basename "$dummylib")" \
"$1"
done
}

for lib in $FOAM_LIBBIN/lib*; do
fix_install_names "$lib"
done

for bin in $FOAM_APPBIN/*; do
fix_install_names "$bin"
done