Skip to content

build: require !NDEBUG for debug-enabled (aka development) builds - #22513

Closed
vszakats wants to merge 8 commits into
curl:masterfrom
vszakats:debug-debug
Closed

vszakats wants to merge 8 commits into
curl:masterfrom
vszakats:debug-debug

Conversation

@vszakats

@vszakats vszakats commented Aug 7, 2026 •

Copy link
Copy Markdown
Member

To prevent creating a curl-development (aka debug-enabled, aka
-DENABLE_DEBUG=ON, --enable-debug or DEBUGBUILD) build without
assert()s. Since it may break expectations by missing to catch error
cases. Also to make it less likely to build an inherently insecure
development build by accident.

Also:

  • INSTALL-CMAKE.md: document.
  • GHA/windows: adjust CI jobs to meet the above requirement, where
    missing.

Reported-by Stefan Eissing
Bug: #22484 (comment)
Ref: ea98445 #13592
Fixes #22481
Fixes #22484


  • adjust CI jobs not meeting this criteria.

Multi-Config tested OK (to fail by design) here: https://github.com/curl/curl/actions/runs/31159628749/job/92807878479?pr=22513

@vszakats
vszakats marked this pull request as draft August 7, 2026 07:41
@vszakats
vszakats marked this pull request as draft August 7, 2026 07:41
@vszakats vszakats added build cmake CI Continuous Integration labels Aug 7, 2026
@vszakats
vszakats marked this pull request as ready for review August 7, 2026 08:16
@bagder

bagder commented Aug 7, 2026

Copy link
Copy Markdown
Member

Is there as a reason ENABLE_DEBUG cannot be the same as "build type Debug" with cmake? I had not really considered that cmake has those things and these two separate debug options must be confusing to people as it's not clear what the differences are, if any and why.

@vszakats

vszakats commented Aug 7, 2026 •

Copy link
Copy Markdown
Member Author

Is there as a reason ENABLE_DEBUG cannot be the same as "build type Debug" with cmake? I had not really considered that cmake has those things and these two separate debug options must be confusing to people as it's not clear what the differences are, if any and why.

I took a dive into this here: #22484 (comment)

In conclusion, I don't think this could work, because build type Debug
is not known at configure time, yet there are things needing to know if
we're building development or not. It'd also be a heavy knob, that changes
things arguably in unexpected, and also silent ways, a combination that
causes more trouble than it fixes. It'd also prevent building valid combinations
such as debug-symbols for a safe production build. Such combinations
are at times necessary to track down actual issues. I previously dealt with
many of these, and remain convinced it's not the right way. Also, a single
knob (esp. with an objectively misleading name like it is now) is a bigger
footgun than before this patch, which is the opposite that's probably useful
for most. It also changes the semantics of CMake 'Debug mode' strongly,
which may come unexpected for anyone used to how CMake works. It'd
also make everyone's 'Debug' build suddenly a unsafe development build,
and, silently too.

So, no, I don't think it would work as expected, and that it would improve
things for most, overall. Actually, the opposite.

Copilot AI 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.

Pull request overview

This PR tightens curl “debug-enabled/development” builds to ensure assert()s are not disabled (i.e., prevents DEBUGBUILD being used together with NDEBUG), and updates CMake/docs/Windows CI to comply with that requirement.

Changes:

  • Add a compile-time hard error when DEBUGBUILD and NDEBUG are both defined.
  • Add a CMake configure-time error for common single-config non-Debug configurations when ENABLE_DEBUG=ON.
  • Update CMake install docs and Windows GitHub Actions matrix entries to align with the new constraint.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
lib/curl_setup.h Adds a preprocessor check that forbids DEBUGBUILD + NDEBUG.
docs/INSTALL-CMAKE.md Documents the build-type/configuration requirement when ENABLE_DEBUG is enabled.
CMakeLists.txt Adds a configure-time guard intended to prevent debug-enabled builds with non-Debug build types.
.github/workflows/windows.yml Adjusts Windows CI matrix build types/options to avoid ENABLE_DEBUG with non-Debug configs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CMakeLists.txt Resolved
@bagder

bagder commented Aug 7, 2026

Copy link
Copy Markdown
Member

Also, a single knob (esp. with an objectively misleading name like it is now) is a bigger footgun than before this patch

Which "debug" is the misleading name and why? The way I see it, it is cmake that makes this really complicated not curl.

@bagder

bagder commented Aug 7, 2026

Copy link
Copy Markdown
Member

Or perhaps it is the term "debug" that might mean different things to different people.

@MichalPetryka

Copy link
Copy Markdown
Contributor

Or perhaps it is the term "debug" that might mean different things to different people.

I think most people understand it like CMake, MSBuild and I think Meson define it: built without compiler optimizations and with asserts enabled.

@vszakats

vszakats commented Aug 7, 2026 •

Copy link
Copy Markdown
Member Author

Also, a single knob (esp. with an objectively misleading name like it is now) is a bigger footgun than before this patch

Which "debug" is the misleading name and why? The way I see it, it is cmake that makes this really complicated not curl.

Does it matter? CMake is what it is, it's a tool with things and certain expectations.

Also about the names, does it matter? I believe curl how it worked before this
patch was fine, after, it still is. Surely there is always room for improvement,
if there is a good reason, but at this point I don't think it matters what I personally
think about these names. They are fine too, we got used to them, learned them.
If pressed hard enough, I will say they mislead me quite a number of times in the
past (because they did), and I saw examples when they mislead others. It
doesn't matter, and I don't think we're making more improvements if I spend
another hour saying it again why I found these misleading, if pressed even harder.

@vszakats

vszakats commented Aug 7, 2026 •

Copy link
Copy Markdown
Member Author

Or perhaps it is the term "debug" that might mean different things to different people.

They may well do, yes.

I'd guess for some, it's not necessarily self-evident what each of these options mean:
ENABLE_DEBUG, Debug mode, Debug type, Debug configuration, debug-enabled,
--enable-debug, DEBUGBUILD, CURLDEBUG, NDEBUG, UNITTESTS,
BUILD_TESTING, CURL_DISABLE_TESTS.

@bagder

bagder commented Aug 7, 2026

Copy link
Copy Markdown
Member

I don't think anyone can tell the difference between all of those without looking them up, but I also don't think anyone needs to.

@bagder

bagder commented Aug 7, 2026

Copy link
Copy Markdown
Member

Or perhaps it is the term "debug" that might mean different things to different people.

I think most people understand it like CMake, MSBuild and I think Meson define it: built without compiler optimizations and with asserts enabled.

I think we all can agree to that lose definition. But if that was the completely picture, this whole line of argument wouldn't have happened... 😀

@vszakats

vszakats commented Aug 7, 2026

Copy link
Copy Markdown
Member Author

I don't think anyone can tell the difference between all of those without looking them up, but I also don't think anyone needs to.

It certainly doesn't make it easier to have a discussion about them.

@bagder

bagder commented Aug 7, 2026

Copy link
Copy Markdown
Member

We have a lot of code, names and solutions. They all need names. Some names sometimes get a little confusing and wrong and then we try fix them as we go along to maybe make it easier. I don't think the situation is particularly bad as most things are documented and can be figured out fairly easy.

Comment thread .github/workflows/windows.yml Resolved
@vszakats vszakats closed this in 5050196 Aug 10, 2026
@vszakats
vszakats deleted the debug-debug branch August 10, 2026 16:41
vszakats added a commit that referenced this pull request Aug 10, 2026
Also drop `!DEBUGBUILD` from job names, it's redundant now.

Follow-up to 5050196 #22513

Closes #22535
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build CI Continuous Integration cmake

Development

Successfully merging this pull request may close these issues.

DEBUGBUILD without DEBUGASSERT?

5 participants