Skip to content

fix(nix): build kcov in the dev shell on macOS#9681

Open
jaredramirez wants to merge 1 commit into
mainfrom
jared/nix-dev-shell-kcov-macos
Open

fix(nix): build kcov in the dev shell on macOS#9681
jaredramirez wants to merge 1 commit into
mainfrom
jared/nix-dev-shell-kcov-macos

Conversation

@jaredramirez

Copy link
Copy Markdown
Collaborator

Problem

zig build build-ci (the minici flow) builds the custom kcov coverage tool from source on every platform, but the dev shell only provided kcov's link dependencies on Linux (++ optionals isLinux kcovBuildDeps). On macOS the build failed:

error: unable to find dynamic system library 'z' using strategy 'paths_first'

Root cause

kcov links its system libraries via zig's linkSystemLibrary, which resolves them through pkg-config. nixpkgs ships these as the modules zlib/libcurl/libdwarf, but kcov asks for z/curl/dwarf. curl happens to resolve; z and dwarf do not. The nix pkg-config wrapper only reads .pc directories from buildInputs (via PKG_CONFIG_PATH_FOR_TARGET), not an exported PKG_CONFIG_PATH, so the aliases must be real packages.

Fix (src/flake.nix)

  • Provide pkg-config/curl/zlib on all platforms (not just Linux).
  • Add alias .pc packages so pkg-config z → zlib and pkg-config dwarf → libdwarf resolve.
  • On macOS add libdwarf (kcov links it as dwarf); keep elfutils Linux-only (kcov uses libdw/libelf there).

Verification (macOS, inside nix develop ./src)

  • pkg-config z and pkg-config dwarf both resolve
  • zig build build-coverage-tools → exit 0
  • zig build build-ci --summary all --color off → exit 0, no failures (kcov compiles + installs)

🤖 Generated with Claude Code

@jaredramirez jaredramirez self-assigned this Jun 17, 2026
@jaredramirez jaredramirez force-pushed the jared/nix-dev-shell-kcov-macos branch 2 times, most recently from af4569b to b8c6dfa Compare June 17, 2026 02:37
@jaredramirez jaredramirez requested a review from Anton-4 June 17, 2026 02:39
@jaredramirez jaredramirez marked this pull request as ready for review June 17, 2026 02:39
@jaredramirez jaredramirez force-pushed the jared/nix-dev-shell-kcov-macos branch from b8c6dfa to c8ffb09 Compare June 17, 2026 12:38
Anton-4
Anton-4 previously approved these changes Jun 17, 2026

@Anton-4 Anton-4 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good :)

@jaredramirez jaredramirez force-pushed the jared/nix-dev-shell-kcov-macos branch 5 times, most recently from 3d4d2a6 to b658a07 Compare June 18, 2026 18:20
`zig build build-ci` builds the custom kcov coverage tool from source on every
platform, but the dev shell only provided kcov's link dependencies on Linux, so
on macOS the build failed with "unable to find dynamic system library 'z'/'curl'".

Provide curl/zlib/pkg-config on all platforms, and on macOS add libdwarf (kcov
links it as "dwarf"). kcov resolves system libraries through pkg-config but asks
for the module names "z"/"dwarf", which nixpkgs ships as "zlib"/"libdwarf"; add
alias .pc files so those resolve (the nix pkg-config wrapper only reads .pc dirs
from buildInputs, not an exported PKG_CONFIG_PATH).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jaredramirez jaredramirez force-pushed the jared/nix-dev-shell-kcov-macos branch from b658a07 to fe81053 Compare June 18, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants