-
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.
- Loading branch information
Tom McLaughlin
committed
Dec 9, 2024
1 parent
2e0e966
commit cdccb18
Showing
7 changed files
with
73 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
The libffi.a in this folder was compiled from Nixpkgs master on 12/6/2024 on a x86_64-darwin machine. It's include to support cross-compiling to that target on an aarch64-darwin. |
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 | ||
} |
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,29 @@ | ||
{ pkgs }: | ||
|
||
{ | ||
packages.rust-notebook-language-server.components.exes.rust-notebook-language-server.postInstall = '' | ||
${builtins.readFile ./fix-dylib.sh} | ||
fix_dylib "$out/bin/rust-notebook-language-server" libiconv.2.dylib libiconv.dylib | ||
fix_dylib "$out/bin/rust-notebook-language-server" libffi.8.dylib libffi.dylib | ||
fix_dylib "$out/bin/rust-notebook-language-server" libpcre.1.dylib libpcre.dylib | ||
fix_dylib "$out/bin/rust-notebook-language-server" libc++.1.0.dylib libc++.dylib | ||
fix_dylib "$out/bin/rust-notebook-language-server" libc++abi.1.0.dylib libc++abi.dylib | ||
check_no_nix_refs "$out/bin/rust-notebook-language-server" | ||
strip "$out/bin/rust-notebook-language-server" | ||
''; | ||
|
||
packages.rust-notebook-language-server.components.exes.rust-notebook-language-server.configureFlags = let | ||
# Nixpkgs can't currently give us a cross-compiled x86_64-darwin libffi.a when we're building on aarch64-darwin. | ||
# So, we bundle one in the repo. | ||
# Tried to also detect if we're on aarch64-darwin, so it can work normally if the build machine is x86_64-darwin, | ||
# but that is deliberately difficult here (builtins.currentSystem is considered an "impure builtin".) | ||
libffi = if pkgs.stdenv.targetPlatform.system == "x86_64-darwin" | ||
then "${../assets/libffi.a}" | ||
else "${pkgs.pkgsStatic.libffi}/lib/libffi.a"; | ||
in | ||
[ | ||
''--ghc-options="-optl-Wl,-dead_strip -optl-Wl,-dead_strip_dylibs -optl-Wl,-force_load,${libffi}"'' | ||
]; | ||
} |
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