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
Unknown Object (File)
Sun, Oct 12, 1:56 PM
Unknown Object (File)
Sat, Oct 11, 12:10 AM
Unknown Object (File)
Sat, Oct 11, 12:10 AM
Unknown Object (File)
Sat, Oct 11, 12:10 AM
Unknown Object (File)
Sat, Oct 11, 12:10 AM
Unknown Object (File)
Sat, Oct 11, 12:10 AM
Unknown Object (File)
Fri, Oct 10, 5:41 PM
Unknown Object (File)
Mon, Oct 6, 8:40 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 Not Applicable
Unit
Tests Not Applicable

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.Aug 21 2025, 3:58 PM
This revision was automatically updated to reflect the committed changes.