Force --enable-debug on FreeBSD if INVARIANTS is set #12185
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
As illustrated in #12163, at least on 14-CURRENT, panics can result if built without --enable-debug when DEBUG and INVARIANTS are enabled. There is already logic present to force building with INVARIANTS if that's enabled, but that's not enough to resolve this problem.
Description
Reshuffled the INVARIANTS check to happen before the --enable-debug check; set a new variable, FORCE_DEBUG, in the INVARIANTS check if it's true, then added if (FORCE_DEBUG) {enable debug} to the --enable-debug check.
How Has This Been Tested?
Before the change, #12163 happened if built on the default GENERIC kernel (with DEBUG=-g and INVARIANTS) without an explicit --enable-debug. After the change, tried on a GENERIC kernel (it correctly forced --enable-debug and did not repro), and tried with a GENERIC-NODEBUG kernel (which explicitly does not have INVARIANTS) (it did not force --enable-debug).
Types of changes
Checklist:
Signed-off-by
.