build: add build-level CURL_DISABLE_TYPECHECK options

Usage:
- autotools: `--disable-typecheck` (or `--enable-typecheck` (default))
- cmake: `-DCURL_DISABLE_TYPECHECK=ON`.

To disable `curl_easy_setopt()`/`curl_easy_getinfo()` type checking with
supported (new) gcc and clang compilers. It is useful to improve build
performance for the `tests/libtest` target. In particular the CodeQL
analyzer may take above an hour to compile with type checking enabled,
and disabling it brings it down to seconds. On local machines it may
also cut build times in half when build testdeps, depending on platform
and compiler.

Other than these cases, we recommend leaving type checking enabled.

Ref: fdacf34aae #19632

Also:
- GHA/codeql: use it.
- test1165: check in `include/curl`.
- lib1912: delete stray todo comment.
- spelling and comment nits.

Closes #19637
This commit is contained in:
Viktor Szakats 2025-11-21 12:43:54 +01:00
parent eaa7651374
commit 9e6f1c5efb
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
9 changed files with 76 additions and 44 deletions

View file

@ -31,7 +31,7 @@
static CURLcode test_lib1912(const char *URL)
{
/* Only test if GCC typechecking is available */
/* Only test if GCC/clang type checking is available */
int error = 0;
#ifdef CURLINC_TYPECHECK_GCC_H
const struct curl_easyoption *o;
@ -73,7 +73,6 @@ static CURLcode test_lib1912(const char *URL)
print_err(o->name, "CURLOT_OBJECT");
error++;
}
/* Todo: no gcc typecheck for CURLOPTTYPE_BLOB types? */
}
#endif
(void)URL;

View file

@ -86,7 +86,7 @@ sub scan_cmake_config_h {
scanconf_cmake(\%disable_cmake_config_h, "$root/lib/curl_config.h.cmake");
}
my %whitelisted = ("CURL_DISABLE_TYPECHECK" => 1);
my %whitelisted = ('CURL_DISABLE_DEPRECATION' => 1);
sub scan_file {
my ($source)=@_;
@ -114,6 +114,7 @@ sub scan_dir {
}
sub scan_sources {
scan_dir("$root/include/curl");
scan_dir("$root/src");
scan_dir("$root/lib");
scan_dir("$root/lib/vtls");