Skip to content

Commit 687df0c

Browse files
committed
fix(nix): strip the unused libiconv dependency with dead_strip_dylibs
Removing libiconv from buildInputs was not enough: the nixpkgs Darwin stdenv injects -liconv regardless, so the arm64 binary still recorded the unused /nix/store libiconv dylib (the otool gate caught it). ccusage references no iconv symbols, so add -Wl,-dead_strip_dylibs to the Darwin link, which drops dylib load commands with no used symbols. The arm64 binary now links only /usr/lib/libSystem.B.dylib (verified), so the install-name rewrite stays gone. (Linux ships a fully static musl binary with no dynamic deps, so no equivalent is needed there.)
1 parent 7afcec6 commit 687df0c

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎package.nix‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ let
2727
doCheck = false;
2828
cargoExtraArgs = "-p ccusage --bin ccusage";
2929
CCUSAGE_PRICING_JSON_PATH = "${inputs.litellm}/model_prices_and_context_window.json";
30-
RUSTFLAGS = lib.optionalString stdenv.isLinux "-C link-arg=-fuse-ld=mold";
30+
RUSTFLAGS =
31+
lib.optionalString stdenv.isLinux "-C link-arg=-fuse-ld=mold"
32+
# The nixpkgs Darwin stdenv injects -liconv even though ccusage uses no
33+
# iconv symbols, recording an unused /nix/store libiconv dependency that
34+
# crashes non-Nix Macs (#1251). dead_strip_dylibs drops dylib load
35+
# commands with no referenced symbols, so the unused libiconv is removed
36+
# and the binary links only system dylibs.
37+
+ lib.optionalString stdenv.isDarwin "-C link-arg=-Wl,-dead_strip_dylibs";
3138
nativeBuildInputs = [
3239
pkg-config
3340
]

0 commit comments

Comments
 (0)