From 09846f4e121e45bfd6984f17e9e2dece59523fad Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Mon, 5 May 2025 13:09:35 +0200 Subject: [PATCH] whisper: remove MSVC warnings pragmas (#3090) * ggml : remove MSVC warnings pragmas This commit removes the MSVC-specific pragmas as these are now handled in CMakeLists.txt. * whisper : remove MSVC warning pragmas This commit removes the MSVC-specific pragmas. These are now handled in the CMakeLists.txt file. --- CMakeLists.txt | 1 + examples/cli/cli.cpp | 4 ---- examples/common-whisper.cpp | 4 ---- examples/common.cpp | 4 ---- examples/server/server.cpp | 4 ---- examples/talk-llama/llama.cpp | 4 ---- ggml/CMakeLists.txt | 2 ++ ggml/src/ggml-cpu/ggml-cpu-aarch64.cpp | 2 -- ggml/src/ggml-cpu/ggml-cpu-quants.c | 6 ------ ggml/src/ggml-cpu/ggml-cpu.c | 13 ------------- ggml/src/ggml-cpu/ops.cpp | 13 ------------- ggml/src/ggml-cpu/vec.cpp | 6 ------ ggml/src/ggml-cuda/common.cuh | 4 ---- ggml/src/ggml-quants.c | 6 ------ ggml/src/ggml-sycl/common.hpp | 4 ---- src/whisper.cpp | 4 ---- 16 files changed, 3 insertions(+), 78 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe82c65d..b8ab1cce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,6 +232,7 @@ if (MSVC) endfunction() if (WHISPER_BUILD_EXAMPLES) + disable_msvc_warnings(whisper) disable_msvc_warnings(common) disable_msvc_warnings(common-sdl) disable_msvc_warnings(lsp) diff --git a/examples/cli/cli.cpp b/examples/cli/cli.cpp index b0acefd0..f202ebd5 100644 --- a/examples/cli/cli.cpp +++ b/examples/cli/cli.cpp @@ -20,10 +20,6 @@ #include #endif -#if defined(_MSC_VER) -#pragma warning(disable: 4244 4267) // possible loss of data -#endif - // helper function to replace substrings static void replace_all(std::string & s, const std::string & search, const std::string & replace) { for (size_t pos = 0; ; pos += replace.length()) { diff --git a/examples/common-whisper.cpp b/examples/common-whisper.cpp index 6a9b58e0..8b9229ed 100644 --- a/examples/common-whisper.cpp +++ b/examples/common-whisper.cpp @@ -26,10 +26,6 @@ #define MINIAUDIO_IMPLEMENTATION #include "miniaudio.h" -#if defined(_MSC_VER) -#pragma warning(disable: 4244 4267) // possible loss of data -#endif - #ifdef _WIN32 #include #include diff --git a/examples/common.cpp b/examples/common.cpp index d23709d2..8eb633e5 100644 --- a/examples/common.cpp +++ b/examples/common.cpp @@ -10,10 +10,6 @@ #include #include -#if defined(_MSC_VER) -#pragma warning(disable: 4244 4267) // possible loss of data -#endif - // Function to check if the next argument exists static std::string get_next_arg(int& i, int argc, char** argv, const std::string& flag, gpt_params& params) { if (i + 1 < argc && argv[i + 1][0] != '-') { diff --git a/examples/server/server.cpp b/examples/server/server.cpp index 97c12bdb..14462707 100644 --- a/examples/server/server.cpp +++ b/examples/server/server.cpp @@ -14,10 +14,6 @@ #include #include -#if defined(_MSC_VER) -#pragma warning(disable: 4244 4267) // possible loss of data -#endif - using namespace httplib; using json = nlohmann::ordered_json; diff --git a/examples/talk-llama/llama.cpp b/examples/talk-llama/llama.cpp index d5164720..c52bbe5f 100644 --- a/examples/talk-llama/llama.cpp +++ b/examples/talk-llama/llama.cpp @@ -16,10 +16,6 @@ #include #include -#if defined(_MSC_VER) -#pragma warning(disable: 4244 4267) // possible loss of data -#endif - // // interface implementation // diff --git a/ggml/CMakeLists.txt b/ggml/CMakeLists.txt index b463cbd9..a8300e16 100644 --- a/ggml/CMakeLists.txt +++ b/ggml/CMakeLists.txt @@ -366,6 +366,8 @@ if (MSVC) /wd4005 # Macro redefinition /wd4244 # Conversion from one type to another type, possible loss of data /wd4267 # Conversion from 'size_t' to a smaller type, possible loss of data + /wd4996 # Disable POSIX deprecation warnings + /wd4702 # Unreachable code warnings ) function(disable_msvc_warnings target_name) if(TARGET ${target_name}) diff --git a/ggml/src/ggml-cpu/ggml-cpu-aarch64.cpp b/ggml/src/ggml-cpu/ggml-cpu-aarch64.cpp index 175cba32..8ff6d64a 100644 --- a/ggml/src/ggml-cpu/ggml-cpu-aarch64.cpp +++ b/ggml/src/ggml-cpu/ggml-cpu-aarch64.cpp @@ -72,8 +72,6 @@ static_assert(sizeof(block_iq4_nlx4) == 4 * sizeof(ggml_half) + QK4_NL * 2, "wro #if defined(__GNUC__) #pragma GCC diagnostic ignored "-Woverlength-strings" -#elif defined(_MSC_VER) -#pragma warning(disable: 4244 4267) // possible loss of data #endif #define UNUSED GGML_UNUSED diff --git a/ggml/src/ggml-cpu/ggml-cpu-quants.c b/ggml/src/ggml-cpu/ggml-cpu-quants.c index 91a81bdc..aac589af 100644 --- a/ggml/src/ggml-cpu/ggml-cpu-quants.c +++ b/ggml/src/ggml-cpu/ggml-cpu-quants.c @@ -20,12 +20,6 @@ #define GROUP_MAX_EPS_IQ1_M 1e-7f #define GROUP_MAX_EPS_IQ1_S 1e-12f -#if defined(_MSC_VER) -// disable "possible loss of data" to avoid warnings for hundreds of casts -// we should just be careful :) -#pragma warning(disable: 4244 4267) -#endif - #define UNUSED GGML_UNUSED // some compilers don't provide _mm256_set_m128i, e.g. gcc 7 diff --git a/ggml/src/ggml-cpu/ggml-cpu.c b/ggml/src/ggml-cpu/ggml-cpu.c index 64405449..a30e67f2 100644 --- a/ggml/src/ggml-cpu/ggml-cpu.c +++ b/ggml/src/ggml-cpu/ggml-cpu.c @@ -50,19 +50,6 @@ #include "llamafile/sgemm.h" #endif -#if defined(_MSC_VER) -// disable "possible loss of data" to avoid hundreds of casts -// we should just be careful :) -#pragma warning(disable: 4244 4267) - -// disable POSIX deprecation warnings -// these functions are never going away, anyway -#pragma warning(disable: 4996) - -// unreachable code because of multiple instances of code after GGML_ABORT -#pragma warning(disable: 4702) -#endif - // Note: once we move threading into a separate C++ file // will use std::hardware_destructive_interference_size instead of hardcoding it here // and we'll use C++ attribute syntax. diff --git a/ggml/src/ggml-cpu/ops.cpp b/ggml/src/ggml-cpu/ops.cpp index 7413192b..955fec59 100644 --- a/ggml/src/ggml-cpu/ops.cpp +++ b/ggml/src/ggml-cpu/ops.cpp @@ -8,19 +8,6 @@ #include -#if defined(_MSC_VER) -// disable "possible loss of data" to avoid hundreds of casts -// we should just be careful :) -#pragma warning(disable: 4244 4267) - -// disable POSIX deprecation warnings -// these functions are never going away, anyway -#pragma warning(disable: 4996) - -// unreachable code because of multiple instances of code after GGML_ABORT -#pragma warning(disable: 4702) -#endif - // ggml_compute_forward_dup static void ggml_compute_forward_dup_same_cont( diff --git a/ggml/src/ggml-cpu/vec.cpp b/ggml/src/ggml-cpu/vec.cpp index dfe2218e..02d40618 100644 --- a/ggml/src/ggml-cpu/vec.cpp +++ b/ggml/src/ggml-cpu/vec.cpp @@ -2,12 +2,6 @@ #include -#if defined(_MSC_VER) -// disable "possible loss of data" to avoid hundreds of casts -// we should just be careful :) -#pragma warning(disable: 4244 4267) -#endif - // precomputed gelu table for f16 (128 KB) ggml_fp16_t ggml_table_gelu_f16[1 << 16]; diff --git a/ggml/src/ggml-cuda/common.cuh b/ggml/src/ggml-cuda/common.cuh index 2ea014e6..919217df 100644 --- a/ggml/src/ggml-cuda/common.cuh +++ b/ggml/src/ggml-cuda/common.cuh @@ -130,10 +130,6 @@ static int ggml_cuda_highest_compiled_arch(const int arch) { #define MATRIX_ROW_PADDING 512 // last row of quant. matrices is a multiple of this to avoid out-of-bounds memory accesses -#if defined(_MSC_VER) -#pragma warning(disable: 4244 4267) // possible loss of data -#endif - #define GGML_CUDA_MAX_STREAMS 8 [[noreturn]] diff --git a/ggml/src/ggml-quants.c b/ggml/src/ggml-quants.c index ac918a60..84ec6dfe 100644 --- a/ggml/src/ggml-quants.c +++ b/ggml/src/ggml-quants.c @@ -19,12 +19,6 @@ #define GROUP_MAX_EPS_IQ1_M 1e-7f #define GROUP_MAX_EPS_IQ1_S 1e-12f -#if defined(_MSC_VER) -// disable "possible loss of data" to avoid warnings for hundreds of casts -// we should just be careful :) -#pragma warning(disable: 4244 4267) -#endif - #define UNUSED GGML_UNUSED // reference implementation for deterministic creation of model files diff --git a/ggml/src/ggml-sycl/common.hpp b/ggml/src/ggml-sycl/common.hpp index c3d9d186..c71cc89c 100644 --- a/ggml/src/ggml-sycl/common.hpp +++ b/ggml/src/ggml-sycl/common.hpp @@ -80,10 +80,6 @@ extern int g_ggml_sycl_disable_optimize; // max batch size to use MMQ kernels when tensor cores are available #define MMQ_MAX_BATCH_SIZE 32 -#if defined(_MSC_VER) -#pragma warning(disable : 4244 4267) // possible loss of data -#endif - // dmmv = dequantize_mul_mat_vec #ifndef GGML_SYCL_DMMV_X #define GGML_SYCL_DMMV_X 32 diff --git a/src/whisper.cpp b/src/whisper.cpp index 53b07592..f8707e73 100644 --- a/src/whisper.cpp +++ b/src/whisper.cpp @@ -37,10 +37,6 @@ // dummy -#if defined(_MSC_VER) -#pragma warning(disable: 4244 4267) // possible loss of data -#endif - #if defined(WHISPER_BIG_ENDIAN) template static T byteswap(T value) {