Makefile.inc1: fix intermittent libmagic build failure under high parallelism by laffer1 · Pull Request #399 · MidnightBSD/src · GitHub
Skip to content

Makefile.inc1: fix intermittent libmagic build failure under high parallelism#399

Merged
laffer1 merged 1 commit into
stable/4.0from
fix-libmagic-libz-dep
Jun 15, 2026
Merged

Makefile.inc1: fix intermittent libmagic build failure under high parallelism#399
laffer1 merged 1 commit into
stable/4.0from
fix-libmagic-libz-dep

Conversation

@laffer1

@laffer1 laffer1 commented Jun 15, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds missing lib/libmagic__L: lib/libz__L dependency in Makefile.inc1
  • lib/libmagic/Makefile has LIBADD= z so libmagic must link -lz, but no __L ordering constraint was declared
  • Under -j28 (or any high -j), the linker step for libmagic.so.4.full could race ahead of libz being installed into the sysroot

Observed failure:

ld: error: unable to find library -lz
cc: error: linker command failed with exit code 1
*** [libmagic.so.4.full] Error code 1
make[4]: stopped in /usr/src/lib/libmagic

All other libraries that depend on libz already have explicit __L constraints (lib/libarchive__L, secure/lib/libssh__L, cddl/lib/libzfs__L, lib/libsqlite3__L, etc.). libmagic was simply overlooked.

Test plan

  • make -j28 buildworld on amd64 — confirm lib/libmagic builds cleanly without the race
  • make -j4 buildworld — confirm no regression at lower parallelism

🤖 Generated with Claude Code

Summary by Sourcery

Add a missing build dependency to ensure libmagic links against libz reliably under high parallelism.

Bug Fixes:

  • Prevent intermittent libmagic link failures when building with high make parallelism by enforcing proper libz dependency ordering.

Build:

  • Declare libmagic's dependency on libz in Makefile.inc1 to guarantee correct build ordering in parallel builds.

libmagic links against -lz (LIBADD= z in lib/libmagic/Makefile) but
Makefile.inc1 had no explicit lib/libmagic__L: lib/libz__L dependency.
Under high parallelism (e.g. make -j28) libmagic could begin linking
before libz was installed into the sysroot, producing:

  ld: error: unable to find library -lz
  *** [libmagic.so.4.full] Error code 1

All other libraries that link libz already have this dependency
declared (libarchive, libssh, libzfs, libsqlite3, etc).

Signed-off-by: Lucas Holt <luke@foolishgames.com>
@sourcery-ai

sourcery-ai Bot commented Jun 15, 2026

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates Makefile.inc1 to declare a dependency for lib/libmagic__L on lib/libz__L. There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@laffer1 laffer1 merged commit cf6d109 into stable/4.0 Jun 15, 2026
4 of 5 checks passed
@laffer1 laffer1 deleted the fix-libmagic-libz-dep branch June 15, 2026 17:51
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