build: fix clang-cl builds, add CI job
- appveyor: add build-only job for clang-cl. - cmake: `-pedantic-errors` enables `-Werror,-Wlanguage-extension-token` automatically, which makes `__int64` detection fail. Explictly disable this compiler warning for clang-cl to make the feature detection work and to accept `__int64` in the source code. - cmake: disable `-Wlanguage-extension-token` warning for clang-cl to fix these when encountering `__int64`: ``` lib/formdata.c(797,29): error : extension used [-Werror,-Wlanguage-extension-token] lib/warnless.c(117,33): error : extension used [-Werror,-Wlanguage-extension-token] lib/warnless.c(60,28): message : expanded from macro 'CURL_MASK_SCOFFT' lib/warnless.c(59,38): message : expanded from macro 'CURL_MASK_UCOFFT' include\curl/system.h(352,40): message : expanded from macro 'CURL_TYPEOF_CURL_OFF_T' ``` - make `__GNUC__` warning suppressions apply to `__clang__` too. Necessary for clang-cl, which defines the latter, but not the former. (Regular clang defines both.) - examples: fix clang-cl compiler warning in `http2-upload.c`. ``` docs\examples\http2-upload.c(56,5): error : no previous prototype for function 'my_gettimeofday' [-Werror,-Wmissing-prototypes] docs\examples\http2-upload.c(56,1): message : declare 'static' if the function is not intended to be used outside of this translation unit ``` - unit2604: add missing `#pragma GCC diagnostic pop`. Follow-up toe53523fef0#14859 - unit1652: limit compiler warning suppression to GCC. They do not affect clang builds. Follow-up to71cf0d1fca#14772 Closes #15449
This commit is contained in:
parent
9acecc923d
commit
fb711b5098
@ -31,6 +31,9 @@ if(CURL_WERROR AND
|
|||||||
NOT CMAKE_VERSION VERSION_LESS 3.23.0) OR # to avoid check_symbol_exists() conflicting with GCC -pedantic-errors
|
NOT CMAKE_VERSION VERSION_LESS 3.23.0) OR # to avoid check_symbol_exists() conflicting with GCC -pedantic-errors
|
||||||
CMAKE_C_COMPILER_ID MATCHES "Clang"))
|
CMAKE_C_COMPILER_ID MATCHES "Clang"))
|
||||||
list(APPEND _picky "-pedantic-errors")
|
list(APPEND _picky "-pedantic-errors")
|
||||||
|
if(MSVC) # clang-cl
|
||||||
|
list(APPEND _picky "-Wno-language-extension-token") # Override default error to make __int64 size detection pass
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(APPLE AND
|
if(APPLE AND
|
||||||
@ -130,9 +133,13 @@ if(PICKY_COMPILER)
|
|||||||
${_picky_common_old}
|
${_picky_common_old}
|
||||||
-Wshift-sign-overflow # clang 2.9
|
-Wshift-sign-overflow # clang 2.9
|
||||||
-Wshorten-64-to-32 # clang 1.0
|
-Wshorten-64-to-32 # clang 1.0
|
||||||
-Wlanguage-extension-token # clang 3.0
|
|
||||||
-Wformat=2 # clang 3.0 gcc 4.8
|
-Wformat=2 # clang 3.0 gcc 4.8
|
||||||
)
|
)
|
||||||
|
if(NOT MSVC)
|
||||||
|
list(APPEND _picky_enable
|
||||||
|
-Wlanguage-extension-token # clang 3.0 # Avoid for clang-cl to allow __int64
|
||||||
|
)
|
||||||
|
endif()
|
||||||
# Enable based on compiler version
|
# Enable based on compiler version
|
||||||
if((CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.6) OR
|
if((CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.6) OR
|
||||||
(CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 6.3))
|
(CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 6.3))
|
||||||
|
|||||||
@ -38,6 +38,7 @@ openssl_root="$(cygpath "${openssl_root_win}")"
|
|||||||
if [ "${BUILD_SYSTEM}" = 'CMake' ]; then
|
if [ "${BUILD_SYSTEM}" = 'CMake' ]; then
|
||||||
options=''
|
options=''
|
||||||
[[ "${TARGET:-}" = *'ARM64'* ]] && SKIP_RUN='ARM64 architecture'
|
[[ "${TARGET:-}" = *'ARM64'* ]] && SKIP_RUN='ARM64 architecture'
|
||||||
|
[ -n "${TOOLSET:-}" ] && options+=" -T ${TOOLSET}"
|
||||||
[ "${OPENSSL}" = 'ON' ] && options+=" -DOPENSSL_ROOT_DIR=${openssl_root_win}"
|
[ "${OPENSSL}" = 'ON' ] && options+=" -DOPENSSL_ROOT_DIR=${openssl_root_win}"
|
||||||
[ -n "${CURLDEBUG:-}" ] && options+=" -DENABLE_CURLDEBUG=${CURLDEBUG}"
|
[ -n "${CURLDEBUG:-}" ] && options+=" -DENABLE_CURLDEBUG=${CURLDEBUG}"
|
||||||
[ "${PRJ_CFG}" = 'Debug' ] && options+=' -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG='
|
[ "${PRJ_CFG}" = 'Debug' ] && options+=' -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG='
|
||||||
@ -62,6 +63,9 @@ if [ "${BUILD_SYSTEM}" = 'CMake' ]; then
|
|||||||
'-DCMAKE_INSTALL_PREFIX=C:/curl' \
|
'-DCMAKE_INSTALL_PREFIX=C:/curl' \
|
||||||
"-DCMAKE_BUILD_TYPE=${PRJ_CFG}" \
|
"-DCMAKE_BUILD_TYPE=${PRJ_CFG}" \
|
||||||
'-DCURL_USE_LIBPSL=OFF'
|
'-DCURL_USE_LIBPSL=OFF'
|
||||||
|
if false; then
|
||||||
|
cat _bld/CMakeFiles/CMakeConfigureLog.yaml 2>/dev/null || true
|
||||||
|
fi
|
||||||
echo 'curl_config.h'; grep -F '#define' _bld/lib/curl_config.h | sort || true
|
echo 'curl_config.h'; grep -F '#define' _bld/lib/curl_config.h | sort || true
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
if ! cmake --build _bld --config "${PRJ_CFG}" --parallel 2 -- ${BUILD_OPT:-}; then
|
if ! cmake --build _bld --config "${PRJ_CFG}" --parallel 2 -- ${BUILD_OPT:-}; then
|
||||||
@ -119,10 +123,6 @@ else
|
|||||||
echo "Skip running curl.exe. Reason: ${SKIP_RUN}"
|
echo "Skip running curl.exe. Reason: ${SKIP_RUN}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if false; then
|
|
||||||
cat CMakeFiles/CMakeConfigureLog.yaml 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
# build tests
|
# build tests
|
||||||
|
|
||||||
if [[ "${TFLAGS}" != 'skipall' ]] && \
|
if [[ "${TFLAGS}" != 'skipall' ]] && \
|
||||||
|
|||||||
10
appveyor.yml
10
appveyor.yml
@ -89,6 +89,16 @@ environment:
|
|||||||
SCHANNEL: 'ON'
|
SCHANNEL: 'ON'
|
||||||
ENABLE_UNICODE: 'OFF'
|
ENABLE_UNICODE: 'OFF'
|
||||||
EXAMPLES: 'ON'
|
EXAMPLES: 'ON'
|
||||||
|
- job_name: 'CMake, VS2022, Debug, x64, Schannel, Static, Unicode, Build-tests & examples, clang-cl'
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2022'
|
||||||
|
BUILD_SYSTEM: CMake
|
||||||
|
PRJ_GEN: 'Visual Studio 17 2022'
|
||||||
|
TARGET: '-A x64'
|
||||||
|
PRJ_CFG: Debug
|
||||||
|
SCHANNEL: 'ON'
|
||||||
|
ENABLE_UNICODE: 'ON'
|
||||||
|
EXAMPLES: 'ON'
|
||||||
|
TOOLSET: 'ClangCl'
|
||||||
- job_name: 'CMake, VS2022, Debug, x64, Schannel, Static, Unicode, Build-tests'
|
- job_name: 'CMake, VS2022, Debug, x64, Schannel, Static, Unicode, Build-tests'
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2022'
|
APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2022'
|
||||||
BUILD_SYSTEM: CMake
|
BUILD_SYSTEM: CMake
|
||||||
|
|||||||
@ -53,6 +53,7 @@
|
|||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define gettimeofday(a, b) my_gettimeofday((a), (b))
|
#define gettimeofday(a, b) my_gettimeofday((a), (b))
|
||||||
|
static
|
||||||
int my_gettimeofday(struct timeval *tp, void *tzp)
|
int my_gettimeofday(struct timeval *tp, void *tzp)
|
||||||
{
|
{
|
||||||
(void)tzp;
|
(void)tzp;
|
||||||
|
|||||||
@ -33,13 +33,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_BROTLI
|
#ifdef HAVE_BROTLI
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
/* Ignore -Wvla warnings in brotli headers */
|
/* Ignore -Wvla warnings in brotli headers */
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wvla"
|
#pragma GCC diagnostic ignored "-Wvla"
|
||||||
#endif
|
#endif
|
||||||
#include <brotli/decode.h>
|
#include <brotli/decode.h>
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
/* FIXME: Delete this once the warnings have been fixed. */
|
/* FIXME: Delete this once the warnings have been fixed. */
|
||||||
#if !defined(CURL_WARN_SIGN_CONVERSION)
|
#if !defined(CURL_WARN_SIGN_CONVERSION)
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -63,13 +63,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_BROTLI
|
#ifdef HAVE_BROTLI
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
/* Ignore -Wvla warnings in brotli headers */
|
/* Ignore -Wvla warnings in brotli headers */
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wvla"
|
#pragma GCC diagnostic ignored "-Wvla"
|
||||||
#endif
|
#endif
|
||||||
#include <brotli/decode.h>
|
#include <brotli/decode.h>
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -216,7 +216,7 @@ static void main_free(struct GlobalConfig *config)
|
|||||||
** curl tool main function.
|
** curl tool main function.
|
||||||
*/
|
*/
|
||||||
#ifdef _UNICODE
|
#ifdef _UNICODE
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
/* GCC does not know about wmain() */
|
/* GCC does not know about wmain() */
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||||
@ -287,7 +287,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _UNICODE
|
#ifdef _UNICODE
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
#include "memdebug.h"
|
#include "memdebug.h"
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wformat"
|
#pragma GCC diagnostic ignored "-Wformat"
|
||||||
#pragma GCC diagnostic ignored "-Wformat-extra-args"
|
#pragma GCC diagnostic ignored "-Wformat-extra-args"
|
||||||
@ -1559,6 +1559,6 @@ CURLcode test(char *URL)
|
|||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include "curlcheck.h"
|
#include "curlcheck.h"
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wformat"
|
#pragma GCC diagnostic ignored "-Wformat"
|
||||||
#endif
|
#endif
|
||||||
@ -186,6 +186,6 @@ fail_unless(rc == 128, "return code should be 128");
|
|||||||
|
|
||||||
UNITTEST_STOP
|
UNITTEST_STOP
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -26,15 +26,6 @@
|
|||||||
#include "urldata.h"
|
#include "urldata.h"
|
||||||
#include "sendf.h"
|
#include "sendf.h"
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Wformat"
|
|
||||||
#pragma GCC diagnostic ignored "-Wformat-zero-length"
|
|
||||||
#if !defined(__clang__) && __GNUC__ >= 7
|
|
||||||
#pragma GCC diagnostic ignored "-Wformat-overflow"
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This test hardcodes the knowledge of the buffer size which is internal to
|
* This test hardcodes the knowledge of the buffer size which is internal to
|
||||||
* Curl_infof(). If that buffer is changed in size, this tests needs to be
|
* Curl_infof(). If that buffer is changed in size, this tests needs to be
|
||||||
@ -101,6 +92,15 @@ static int verify(const char *info, const char *two)
|
|||||||
|
|
||||||
UNITTEST_START
|
UNITTEST_START
|
||||||
|
|
||||||
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wformat"
|
||||||
|
#pragma GCC diagnostic ignored "-Wformat-zero-length"
|
||||||
|
#if __GNUC__ >= 7
|
||||||
|
#pragma GCC diagnostic ignored "-Wformat-overflow"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Injecting a simple short string via a format */
|
/* Injecting a simple short string via a format */
|
||||||
msnprintf(input, sizeof(input), "Simple Test");
|
msnprintf(input, sizeof(input), "Simple Test");
|
||||||
Curl_infof(testdata, "%s", input);
|
Curl_infof(testdata, "%s", input);
|
||||||
@ -146,8 +146,8 @@ Curl_infof(testdata, "%s", input);
|
|||||||
fail_unless(strlen(output) == 2051, "Truncation of infof input 3");
|
fail_unless(strlen(output) == 2051, "Truncation of infof input 3");
|
||||||
fail_unless(output[sizeof(output) - 1] == '\0', "Truncation of infof input 3");
|
fail_unless(output[sizeof(output) - 1] == '\0', "Truncation of infof input 3");
|
||||||
|
|
||||||
UNITTEST_STOP
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
UNITTEST_STOP
|
||||||
|
|||||||
@ -46,7 +46,7 @@ struct set {
|
|||||||
UNITTEST_START
|
UNITTEST_START
|
||||||
#ifdef USE_SSH
|
#ifdef USE_SSH
|
||||||
{
|
{
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Woverlength-strings"
|
#pragma GCC diagnostic ignored "-Woverlength-strings"
|
||||||
#endif
|
#endif
|
||||||
@ -78,7 +78,7 @@ UNITTEST_START
|
|||||||
{ NULL, NULL, NULL, NULL, CURLE_OK }
|
{ NULL, NULL, NULL, NULL, CURLE_OK }
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
#pragma GCC diagnostic warning "-Woverlength-strings"
|
#pragma GCC diagnostic warning "-Woverlength-strings"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -114,6 +114,10 @@ UNITTEST_START
|
|||||||
|
|
||||||
free((void *)list[0].cp);
|
free((void *)list[0].cp);
|
||||||
}
|
}
|
||||||
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
UNITTEST_STOP
|
UNITTEST_STOP
|
||||||
|
|||||||
@ -47,7 +47,7 @@ static CURLcode unit_stop(void)
|
|||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Woverlength-strings"
|
#pragma GCC diagnostic ignored "-Woverlength-strings"
|
||||||
#endif
|
#endif
|
||||||
@ -78,7 +78,7 @@ static const char *filecontents[] = {
|
|||||||
"LINE1\x1aTEST"
|
"LINE1\x1aTEST"
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
#pragma GCC diagnostic warning "-Woverlength-strings"
|
#pragma GCC diagnostic warning "-Woverlength-strings"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ UNITTEST_START
|
|||||||
return (CURLcode)rc;
|
return (CURLcode)rc;
|
||||||
UNITTEST_STOP
|
UNITTEST_STOP
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user