Page MenuHomeFreeBSD

share/mk: Deduplicate some handling of debug info
ClosedPublic

Authored by markj on Aug 7 2025, 8:27 PM.
Tags
None
Referenced Files
F128376552: D51805.id160052.diff
Wed, Sep 10, 7:55 AM
F128371039: D51805.id159995.diff
Wed, Sep 10, 6:50 AM
F128365946: D51805.id160079.diff
Wed, Sep 10, 5:48 AM
Unknown Object (File)
Fri, Sep 5, 2:06 PM
Unknown Object (File)
Thu, Sep 4, 1:04 PM
Unknown Object (File)
Tue, Sep 2, 2:40 PM
Unknown Object (File)
Sun, Aug 31, 2:10 PM
Unknown Object (File)
Sun, Aug 31, 10:39 AM
Subscribers

Details

Summary

bsd.prog.mk and bsd.lib.mk contain a bunch of duplicated logic used to
handle DEBUG_FLAGS and standalone debug file info (enabled by
MK_DEBUG_FILES). In anticipation of adding more duplicated logic, let's
try factoring it out into a separate bsd.debug.mk first.

bsd.debug.mk now handles the following:

  • MK_ASSERT_DEBUG
  • installation rules for debug files (the consumer has to set DEBUGFILE)
  • updating CFLAGS and CXXFLAGS based on DEBUG_FLAGS
  • optionally stripping installed files

No functional change intended.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 66119
Build 63002: arc lint + arc unit

Event Timeline

markj requested review of this revision.Aug 7 2025, 8:27 PM

Seems okay. Be sure to test a bsd.progs.mk user too.

This revision is now accepted and ready to land.Aug 7 2025, 8:33 PM

I tested this by doing a reproducible buildworld+installworld, with and without the patch. I ran diff -r to look for differences in the installed directories. The only ones are in /rescue binaries. This is due to a small behaviour changes here which I think is harmless: before, bsd.prog.mk would not add DEBUG_FLAGS to CFLAGS if CRUNCH_CFLAGS was set. (But bsd.lib.mk added it regardless.) So now bsd.prog.mk behaves like bsd.lib.mk, i.e., we don't do anything special for crunchgen binaries. That is, rescue files are built with -g and stripped, resulting in slightly different executables.

  • Add a top-level comment
  • Remove a guard whose purpose I'm not sure about
  • Remove an unneeded include
This revision now requires review to proceed.Aug 8 2025, 1:23 PM

It's fine to remove the guard but it's not a bad idea to have it there too.

Can you also add this file to bsd.README?

I don't recall what, if any, pattern we have for not-user-includable files. But worth mentioning something there still.

It's fine to remove the guard but it's not a bad idea to have it there too.

What exactly do the guards protect against?

Can you also add this file to bsd.README?

Will do.

I don't recall what, if any, pattern we have for not-user-includable files. But worth mentioning something there still.

I extended the comment a bit.

  • List the file in bsd.README
  • Note in the header comment that user makefiles shouldn't include this directly

I'll commit this in a few days if there are no objections.

This revision was not accepted when it landed; it landed in state Needs Review.Thu, Aug 21, 3:58 PM
This revision was automatically updated to reflect the committed changes.