Skip to content

Commit 641df59

Browse files
committed
fix macOS 15.4 beta crashes due to LC_RPATH dups
Fixes the UG crashes caused by the multiplication of "@executable_path/../libs/" caused by replacing multiple (originally distinct) LC_RPATH values with this one. + removed invalid comment from Makefile (actually was related to "bundle-nolib" target that is no longer present) closes GH-436
1 parent 1970daf commit 641df59

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,6 @@ release:
573573
hd-rum-multi/hd-rum:
574574
make -C hd-rum-multi
575575

576-
# Makes dummy bundle (almost empty). May not be portable due to missing libs.
577576
$(BUNDLE): $(TARGET) $(REFLECTOR_TARGET) @MANPAGES@ hd-rum-multi/hd-rum
578577
rm -rf $(BUNDLE)
579578
$(MKDIR_P) $(BUNDLE)/Contents/MacOS $(BUNDLE)/Contents/libs
@@ -587,6 +586,7 @@ $(BUNDLE): $(TARGET) $(REFLECTOR_TARGET) @MANPAGES@ hd-rum-multi/hd-rum
587586
| $(DYLIBBUNDLER) $(DYLIBBUNDLER_FLAGS) -of -cd -b \
588587
-d $(BUNDLE)/Contents/libs/ -p @executable_path/../libs/ -x $$n; \
589588
done
589+
$(srcdir)/data/scripts/macos_fix_multiple_rpaths.sh $(BUNDLE)
590590
if [ -d Frameworks ]; then $(CP) -R Frameworks $(BUNDLE)/Contents/; fi
591591
if [ -n '@MANPAGES@' ]; then mkdir -p $(BUNDLE)/Contents/man/man1; \
592592
$(CP) @MANPAGES@ $(BUNDLE)/Contents/man/man1/; fi
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/sh -eu
2+
#
3+
## Remove multiple LC_RPATH occurences of @executable_path/../libs/
4+
## as can be seen by cmd `otool -l $lib | grep -B 1 -A 2 LC_RPATH`
5+
## which seem to be refused by dyld since macOS 15.4 as can be seen
6+
## here <https://github.com/CESNET/UltraGrid/issues/436>. The multiplied
7+
## paths are caused by dylibbundler LC_RPATH replacements.
8+
##
9+
## @param $1 bundle path
10+
11+
rpath=@executable_path/../libs/
12+
13+
# output number of $rpath occurences in 'cmd LC_RPATH'
14+
num_rel_lc_rpath() {
15+
otool -l "$1" | sed -n '/LC_RPATH/,+2p' | grep -c "$rpath" || true
16+
}
17+
18+
find "$1" -type f -print0 |
19+
while IFS= read -r -d '' n; do
20+
count=$(num_rel_lc_rpath "$n")
21+
# remove all but at most one LC_RPATH $path occurences
22+
while [ "$count" -gt 1 ]; do
23+
install_name_tool -delete_rpath "$rpath" "$n"
24+
count=$((count - 1))
25+
done
26+
done

0 commit comments

Comments
 (0)