Skip to content

fix(nix): the dev shell disables fortify hardening so jemalloc configures - #1614

Open
nikhilunni wants to merge 1 commit into
mainfrom
fix/nix-shell-fortify
Open

nikhilunni wants to merge 1 commit into
mainfrom
fix/nix-shell-fortify

Conversation

@nikhilunni

Copy link
Copy Markdown
Contributor

Problem

A native Linux build of engram-host-agent inside nix develop fails every time in the jemalloc build script:

configure: error: cannot determine return type of strerror_r

config.log shows the cause:

features.h:435:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]

The Nix cc-wrapper's fortify hardening adds -D_FORTIFY_SOURCE to every C compile. Debug builds compile C at -O0. jemalloc's configure probes compile with -Werror, so the glibc warning fails each probe. musl does not emit this warning, so the musl cross targets were not affected.

Fix

hardeningDisable = [ "fortify" ] on the dev shell. The shell only makes development builds; CI and the image builds do not run inside it.

Validation

  • Linux x86_64 dev VM, fresh clone, fresh target dir, inside nix develop:
    • before: cargo build -p tikv-jemalloc-sys fails with the error above.
    • after: it builds, and cargo test --no-run -p engram-host-agent builds every test binary.
  • macOS, inside nix develop, fresh target dir: cargo build --target aarch64-unknown-linux-musl -p tikv-jemalloc-sys builds.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UHxL6gj4o8EvxYpgtwEWaM

…ures

The cc-wrapper's fortify hardening adds -D_FORTIFY_SOURCE to every C
compile. Debug builds compile C at -O0, so glibc emits "_FORTIFY_SOURCE
requires compiling with optimization". jemalloc's configure probes use
-Werror, so each probe fails and configure stops with "cannot determine
return type of strerror_r". A native Linux `cargo build` of
engram-host-agent inside `nix develop` failed every time. musl does not
emit the warning, so the musl cross targets were not affected.

The dev shell only makes development builds; CI and the images do not
build inside it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UHxL6gj4o8EvxYpgtwEWaM

This branch has not been deployed

No deployments
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.

1 participant