build: untangle CURLDEBUG and DEBUGBUILD macros

`CURLDEBUG` is meant to enable memory tracking, but in a bunch of cases,
it was protecting debug features that were supposed to be guarded with
`DEBUGBUILD`.

Replace these uses with `DEBUGBUILD`.

This leaves `CURLDEBUG` uses solely for its intended  purpose: to enable
the memory tracking debug feature.

Also:
- autotools: rely on `DEBUGBUILD` to enable `checksrc`.
  Instead of `CURLDEBUG`, which worked in most cases because debug
  builds enable `CURLDEBUG` by default, but it's not accurate.
- include `lib/easyif.h` instead of keeping a copy of a declaration.
- add CI test jobs for the build issues discovered.

Ref: https://github.com/curl/curl/pull/13694#issuecomment-2120311894
Closes #13718
This commit is contained in:
Viktor Szakats 2024-05-20 14:21:05 +02:00
parent 53b4dfe405
commit 59dc9f7e69
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
24 changed files with 53 additions and 43 deletions

View file

@ -145,7 +145,7 @@ checksrc:
$(CHECKSRC)(@PERL@ $(top_srcdir)/scripts/checksrc.pl -D$(srcdir) \
-W$(srcdir)/tool_hugehelp.c $(srcdir)/*.[ch])
if CURLDEBUG
if DEBUGBUILD
# for debug builds, we scan the sources on all regular make invokes
all-local: checksrc
endif

View file

@ -323,7 +323,7 @@ struct GlobalConfig {
bool styled_output; /* enable fancy output style detection */
long ms_per_transfer; /* start next transfer after (at least) this
many milliseconds */
#ifdef CURLDEBUG
#ifdef DEBUGBUILD
bool test_event_based;
#endif
bool parallel;

View file

@ -1825,7 +1825,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
config->sasl_ir = toggle;
break;
case C_TEST_EVENT: /* --test-event */
#ifdef CURLDEBUG
#ifdef DEBUGBUILD
global->test_event_based = toggle;
#else
warnf(global, "--test-event is ignored unless a debug build");

View file

@ -83,14 +83,12 @@
#include "tool_progress.h"
#include "tool_ipfs.h"
#include "dynbuf.h"
#ifdef DEBUGBUILD
#include "easyif.h" /* for libcurl's debug-only curl_easy_perform_ev() */
#endif
#include "memdebug.h" /* keep this as LAST include */
#ifdef CURLDEBUG
/* libcurl's debug builds provide an extra function */
CURLcode curl_easy_perform_ev(CURL *easy);
#endif
#ifndef O_BINARY
/* since O_BINARY as used in bitmasks, setting it to zero makes it usable in
source code but yet it doesn't ruin anything */
@ -1315,7 +1313,7 @@ static CURLcode single_transfer(struct GlobalConfig *global,
my_setopt(curl, CURLOPT_SEEKFUNCTION, tool_seek_cb);
{
#ifdef CURLDEBUG
#ifdef DEBUGBUILD
char *env = getenv("CURL_BUFFERSIZE");
if(env) {
long size = strtol(env, NULL, 10);
@ -1647,7 +1645,7 @@ static CURLcode single_transfer(struct GlobalConfig *global,
* must do the same thing as classic:
* --cert <filename>:<password> --cert-type p12
* but is designed to test blob */
#if defined(CURLDEBUG) || defined(DEBUGBUILD)
#ifdef DEBUGBUILD
if(config->cert && (strlen(config->cert) > 8) &&
(memcmp(config->cert, "loadmem=",8) == 0)) {
FILE *fInCert = fopen(config->cert + 8, "rb");
@ -1690,7 +1688,7 @@ static CURLcode single_transfer(struct GlobalConfig *global,
config->proxy_cert_type);
#if defined(CURLDEBUG) || defined(DEBUGBUILD)
#ifdef DEBUGBUILD
if(config->key && (strlen(config->key) > 8) &&
(memcmp(config->key, "loadmem=",8) == 0)) {
FILE *fInCert = fopen(config->key + 8, "rb");
@ -2484,7 +2482,7 @@ static CURLcode serial_transfers(struct GlobalConfig *global,
break;
}
start = tvnow();
#ifdef CURLDEBUG
#ifdef DEBUGBUILD
if(global->test_event_based)
result = curl_easy_perform_ev(per->curl);
else