mirror of
https://github.com/curl/curl.git
synced 2026-01-18 17:21:26 +01:00
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:
6
.github/workflows/codeql.yml
vendored
6
.github/workflows/codeql.yml
vendored
@@ -108,8 +108,7 @@ jobs:
|
||||
|
||||
# MultiSSL
|
||||
export PKG_CONFIG_PATH; PKG_CONFIG_PATH="$(brew --prefix c-ares)/lib/pkgconfig:$(brew --prefix mbedtls)/lib/pkgconfig:$(brew --prefix rustls-ffi)/lib/pkgconfig:$(brew --prefix gsasl)/lib/pkgconfig"
|
||||
cmake -B _bld1 -G Ninja -DENABLE_DEBUG=ON \
|
||||
-DCMAKE_C_FLAGS=-DCURL_DISABLE_TYPECHECK \
|
||||
cmake -B _bld1 -G Ninja -DCURL_DISABLE_TYPECHECK=ON -DENABLE_DEBUG=ON \
|
||||
-DCURL_USE_GNUTLS=ON -DCURL_USE_MBEDTLS=ON -DCURL_USE_RUSTLS=ON -DCURL_USE_WOLFSSL=ON \
|
||||
-DUSE_LIBRTMP=ON -DCURL_USE_GSASL=ON -DCURL_USE_GSSAPI=ON -DUSE_SSLS_EXPORT=ON -DUSE_ECH=ON -DENABLE_ARES=ON \
|
||||
-DCURL_DISABLE_VERBOSE_STRINGS=ON
|
||||
@@ -119,8 +118,7 @@ jobs:
|
||||
|
||||
# HTTP/3
|
||||
export PKG_CONFIG_PATH; PKG_CONFIG_PATH="$(brew --prefix libnghttp3)/lib/pkgconfig:$(brew --prefix libngtcp2)/lib/pkgconfig:$(brew --prefix gsasl)/lib/pkgconfig"
|
||||
cmake -B _bld2 -G Ninja \
|
||||
-DCMAKE_C_FLAGS=-DCURL_DISABLE_TYPECHECK \
|
||||
cmake -B _bld2 -G Ninja -DCURL_DISABLE_TYPECHECK=ON \
|
||||
-DCURL_USE_OPENSSL=ON -DOPENSSL_ROOT_DIR="$(brew --prefix openssl)" -DUSE_NGTCP2=ON \
|
||||
-DCURL_USE_LIBSSH2=OFF -DCURL_USE_LIBSSH=ON \
|
||||
-DUSE_LIBRTMP=ON -DCURL_USE_GSASL=ON -DCURL_USE_GSSAPI=ON -DUSE_SSLS_EXPORT=ON
|
||||
|
||||
@@ -462,7 +462,7 @@ option(CURL_DISABLE_SMB "Disable SMB" OFF)
|
||||
mark_as_advanced(CURL_DISABLE_SMB)
|
||||
option(CURL_DISABLE_SMTP "Disable SMTP" OFF)
|
||||
mark_as_advanced(CURL_DISABLE_SMTP)
|
||||
option(CURL_DISABLE_SOCKETPAIR "Disable use of socketpair for curl_multi_poll" OFF)
|
||||
option(CURL_DISABLE_SOCKETPAIR "Disable use of socketpair for curl_multi_poll()" OFF)
|
||||
mark_as_advanced(CURL_DISABLE_SOCKETPAIR)
|
||||
option(CURL_DISABLE_WEBSOCKETS "Disable WebSocket" OFF)
|
||||
mark_as_advanced(CURL_DISABLE_WEBSOCKETS)
|
||||
@@ -470,6 +470,8 @@ option(CURL_DISABLE_TELNET "Disable Telnet" OFF)
|
||||
mark_as_advanced(CURL_DISABLE_TELNET)
|
||||
option(CURL_DISABLE_TFTP "Disable TFTP" OFF)
|
||||
mark_as_advanced(CURL_DISABLE_TFTP)
|
||||
option(CURL_DISABLE_TYPECHECK "Disable curl_easy_setopt()/curl_easy_getinfo() type checking" OFF)
|
||||
mark_as_advanced(CURL_DISABLE_TYPECHECK)
|
||||
option(CURL_DISABLE_VERBOSE_STRINGS "Disable verbose strings" OFF)
|
||||
mark_as_advanced(CURL_DISABLE_VERBOSE_STRINGS)
|
||||
|
||||
|
||||
82
configure.ac
82
configure.ac
@@ -140,36 +140,37 @@ AC_SUBST(VERSIONNUM)
|
||||
|
||||
dnl
|
||||
dnl initialize all the info variables
|
||||
curl_ssl_msg="no (--with-{openssl,gnutls,mbedtls,wolfssl,schannel,amissl,rustls} )"
|
||||
curl_ssh_msg="no (--with-{libssh,libssh2})"
|
||||
curl_zlib_msg="no (--with-zlib)"
|
||||
curl_brotli_msg="no (--with-brotli)"
|
||||
curl_zstd_msg="no (--with-zstd)"
|
||||
curl_gss_msg="no (--with-gssapi)"
|
||||
curl_gsasl_msg="no (--with-gsasl)"
|
||||
curl_tls_srp_msg="no (--enable-tls-srp)"
|
||||
curl_res_msg="blocking (--enable-ares / --enable-threaded-resolver)"
|
||||
curl_ipv6_msg="no (--enable-ipv6)"
|
||||
curl_unix_sockets_msg="no (--enable-unix-sockets)"
|
||||
curl_idn_msg="no (--with-{libidn2,winidn})"
|
||||
curl_docs_msg="enabled (--disable-docs)"
|
||||
curl_manual_msg="no (--enable-manual)"
|
||||
curl_libcurl_msg="enabled (--disable-libcurl-option)"
|
||||
curl_verbose_msg="enabled (--disable-verbose)"
|
||||
curl_sspi_msg="no (--enable-sspi)"
|
||||
curl_ldap_msg="no (--enable-ldap / --with-ldap-lib / --with-lber-lib)"
|
||||
curl_ldaps_msg="no (--enable-ldaps)"
|
||||
curl_ipfs_msg="no (--enable-ipfs)"
|
||||
curl_rtsp_msg="no (--enable-rtsp)"
|
||||
curl_rtmp_msg="no (--with-librtmp)"
|
||||
curl_psl_msg="no (--with-libpsl)"
|
||||
curl_altsvc_msg="enabled (--disable-alt-svc)"
|
||||
curl_headers_msg="enabled (--disable-headers-api)"
|
||||
curl_hsts_msg="enabled (--disable-hsts)"
|
||||
ssl_backends=
|
||||
curl_h1_msg="enabled (internal)"
|
||||
curl_h2_msg="no (--with-nghttp2)"
|
||||
curl_h3_msg="no (--with-ngtcp2 --with-nghttp3, --with-quiche, --with-openssl-quic)"
|
||||
curl_ssl_msg="no (--with-{openssl,gnutls,mbedtls,wolfssl,schannel,amissl,rustls} )"
|
||||
curl_ssh_msg="no (--with-{libssh,libssh2})"
|
||||
curl_zlib_msg="no (--with-zlib)"
|
||||
curl_brotli_msg="no (--with-brotli)"
|
||||
curl_zstd_msg="no (--with-zstd)"
|
||||
curl_gss_msg="no (--with-gssapi)"
|
||||
curl_gsasl_msg="no (--with-gsasl)"
|
||||
curl_tls_srp_msg="no (--enable-tls-srp)"
|
||||
curl_res_msg="blocking (--enable-ares / --enable-threaded-resolver)"
|
||||
curl_ipv6_msg="no (--enable-ipv6)"
|
||||
curl_unix_sockets_msg="no (--enable-unix-sockets)"
|
||||
curl_idn_msg="no (--with-{libidn2,winidn})"
|
||||
curl_docs_msg="enabled (--disable-docs)"
|
||||
curl_manual_msg="no (--enable-manual)"
|
||||
curl_libcurl_msg="enabled (--disable-libcurl-option)"
|
||||
curl_typecheck_msg="enabled (--disable-typecheck)"
|
||||
curl_verbose_msg="enabled (--disable-verbose)"
|
||||
curl_sspi_msg="no (--enable-sspi)"
|
||||
curl_ldap_msg="no (--enable-ldap / --with-ldap-lib / --with-lber-lib)"
|
||||
curl_ldaps_msg="no (--enable-ldaps)"
|
||||
curl_ipfs_msg="no (--enable-ipfs)"
|
||||
curl_rtsp_msg="no (--enable-rtsp)"
|
||||
curl_rtmp_msg="no (--with-librtmp)"
|
||||
curl_psl_msg="no (--with-libpsl)"
|
||||
curl_altsvc_msg="enabled (--disable-alt-svc)"
|
||||
curl_headers_msg="enabled (--disable-headers-api)"
|
||||
curl_hsts_msg="enabled (--disable-hsts)"
|
||||
ssl_backends=
|
||||
curl_h1_msg="enabled (internal)"
|
||||
curl_h2_msg="no (--with-nghttp2)"
|
||||
curl_h3_msg="no (--with-ngtcp2 --with-nghttp3, --with-quiche, --with-openssl-quic)"
|
||||
|
||||
enable_altsvc="yes"
|
||||
hsts="yes"
|
||||
@@ -4345,6 +4346,26 @@ AC_CHECK_HEADER(dirent.h,
|
||||
|
||||
CURL_CONVERT_INCLUDE_TO_ISYSTEM
|
||||
|
||||
dnl ************************************************************
|
||||
dnl disable curl_easy_setopt()/curl_easy_getinfo() type checking
|
||||
dnl
|
||||
AC_MSG_CHECKING([whether to enable curl_easy_setopt()/curl_easy_getinfo() type checking])
|
||||
AC_ARG_ENABLE(typecheck,
|
||||
AS_HELP_STRING([--enable-typecheck],[Enable type checking (default)])
|
||||
AS_HELP_STRING([--disable-typecheck],[Disable type checking]),
|
||||
[ case "$enableval" in
|
||||
no)
|
||||
AC_MSG_RESULT(no)
|
||||
AC_DEFINE(CURL_DISABLE_TYPECHECK, 1, [to disable type checking])
|
||||
curl_typecheck_msg="no"
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(yes)
|
||||
;;
|
||||
esac ],
|
||||
AC_MSG_RESULT(yes)
|
||||
)
|
||||
|
||||
dnl ************************************************************
|
||||
dnl disable verbose text strings
|
||||
dnl
|
||||
@@ -5521,6 +5542,7 @@ AC_MSG_NOTICE([Configured to build curl/libcurl:
|
||||
Build libcurl: Shared=${enable_shared}, Static=${enable_static}
|
||||
Built-in manual: ${curl_manual_msg}
|
||||
--libcurl option: ${curl_libcurl_msg}
|
||||
Type checking: ${curl_typecheck_msg}
|
||||
Verbose errors: ${curl_verbose_msg}
|
||||
Code coverage: ${curl_coverage_msg}
|
||||
SSPI: ${curl_sspi_msg}
|
||||
|
||||
@@ -68,8 +68,8 @@ Disable the FTP (and FTPS) protocol
|
||||
|
||||
## `CURL_DISABLE_GETOPTIONS`
|
||||
|
||||
Disable the `curl_easy_options` API calls that lets users get information
|
||||
about existing options to `curl_easy_setopt`.
|
||||
Disable the `curl_easy_options()` API calls that lets users get information
|
||||
about existing options to `curl_easy_setopt()`.
|
||||
|
||||
## `CURL_DISABLE_GOPHER`
|
||||
|
||||
@@ -182,6 +182,12 @@ Disable the TELNET protocol
|
||||
|
||||
Disable the TFTP protocol
|
||||
|
||||
## `CURL_DISABLE_TYPECHECK`
|
||||
|
||||
Disable `curl_easy_setopt()`/`curl_easy_getinfo()` type checking.
|
||||
|
||||
Useful to improve build performance for the `tests/libtest` test tool.
|
||||
|
||||
## `CURL_DISABLE_VERBOSE_STRINGS`
|
||||
|
||||
Disable verbose strings and error messages.
|
||||
|
||||
@@ -317,10 +317,11 @@ target_link_libraries(my_target PRIVATE CURL::libcurl)
|
||||
- `CURL_DISABLE_SHUFFLE_DNS`: Disable shuffle DNS feature. Default: `OFF`
|
||||
- `CURL_DISABLE_SMB`: Disable SMB. Default: `OFF`
|
||||
- `CURL_DISABLE_SMTP`: Disable SMTP. Default: `OFF`
|
||||
- `CURL_DISABLE_SOCKETPAIR`: Disable use of socketpair for curl_multi_poll. Default: `OFF`
|
||||
- `CURL_DISABLE_SOCKETPAIR`: Disable use of socketpair for curl_multi_poll(). Default: `OFF`
|
||||
- `CURL_DISABLE_SRP`: Disable TLS-SRP support. Default: `OFF`
|
||||
- `CURL_DISABLE_TELNET`: Disable Telnet. Default: `OFF`
|
||||
- `CURL_DISABLE_TFTP`: Disable TFTP. Default: `OFF`
|
||||
- `CURL_DISABLE_TYPECHECK`: Disable curl_easy_setopt()/curl_easy_getinfo() type checking. Default: `OFF`
|
||||
- `CURL_DISABLE_VERBOSE_STRINGS`: Disable verbose strings. Default: `OFF`
|
||||
- `CURL_DISABLE_WEBSOCKETS`: Disable WebSocket. Default: `OFF`
|
||||
- `HTTP_ONLY`: Disable all protocols except HTTP (This overrides all `CURL_DISABLE_*` options). Default: `OFF`
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/* wraps curl_easy_setopt() with typechecking */
|
||||
/* wraps curl_easy_setopt() with type checking */
|
||||
|
||||
/* To add a new kind of warning, add an
|
||||
* if(curlcheck_sometype_option(_curl_opt))
|
||||
@@ -159,7 +159,7 @@
|
||||
curl_easy_setopt(handle, option, value); \
|
||||
})
|
||||
|
||||
/* wraps curl_easy_getinfo() with typechecking */
|
||||
/* wraps curl_easy_getinfo() with type checking */
|
||||
#define curl_easy_getinfo(handle, info, arg) \
|
||||
__extension__({ \
|
||||
if(__builtin_constant_p(info)) { \
|
||||
|
||||
@@ -151,7 +151,7 @@
|
||||
/* disabled WebSocket */
|
||||
#cmakedefine CURL_DISABLE_WEBSOCKETS 1
|
||||
|
||||
/* disables use of socketpair for curl_multi_poll */
|
||||
/* disables use of socketpair for curl_multi_poll() */
|
||||
#cmakedefine CURL_DISABLE_SOCKETPAIR 1
|
||||
|
||||
/* disables TELNET */
|
||||
@@ -160,6 +160,9 @@
|
||||
/* disables TFTP */
|
||||
#cmakedefine CURL_DISABLE_TFTP 1
|
||||
|
||||
/* disables curl_easy_setopt()/curl_easy_getinfo() type checking */
|
||||
#cmakedefine CURL_DISABLE_TYPECHECK 1
|
||||
|
||||
/* disables verbose strings */
|
||||
#cmakedefine CURL_DISABLE_VERBOSE_STRINGS 1
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user