-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build both kinds of roots on macOS, fix up dylibs
- Loading branch information
Tom McLaughlin
committed
Dec 6, 2024
1 parent
bc7884b
commit 381ee5b
Showing
4 changed files
with
46 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ result | |
dist-newstyle | ||
|
||
.direnv | ||
.gcroots | ||
.gcroots* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
# Example usage: | ||
# fix_dylib "./myapp" "libffi.8.dylib" "libffi.dylib" | ||
fix_dylib() { | ||
local executable="$1" | ||
local dylib_name="$2" | ||
local target_name="$3" | ||
|
||
if otool -L "$executable" | grep -q "/nix/store/.*/$dylib_name"; then | ||
echo "Fixing $dylib_name reference in $executable" | ||
local old_path=$(otool -L "$executable" | grep "/nix/store/.*/$dylib_name" | awk '{print $1}') | ||
install_name_tool -change "$old_path" "/usr/lib/$target_name" "$executable" | ||
if otool -L "$executable" | grep -q "/usr/lib/$target_name"; then | ||
echo "Successfully fixed $dylib_name in $executable (now points to $target_name)" | ||
else | ||
echo "Failed to fix $dylib_name in $executable (attempted to point to $target_name)" | ||
return 1 | ||
fi | ||
fi | ||
} | ||
|
||
# Example usage: | ||
# check_no_nix_refs "./myapp" | ||
check_no_nix_refs() { | ||
local executable="$1" | ||
|
||
if otool -L "$executable" | tail -n +2 | grep -q "/nix/store/"; then | ||
echo "ERROR: $executable still contains Nix store references:" | ||
otool -L "$executable" | tail -n +2 | grep "/nix/store/" | ||
return 1 | ||
fi | ||
} |