From 592fb803c094817dfda0ea3b08c97d6b64d07e7d Mon Sep 17 00:00:00 2001 From: Zentrik Date: Fri, 29 Mar 2024 17:20:07 +0000 Subject: [PATCH] Fix spurious unused function warning when compiling crc32 with clang and ifunc support Clang incorrectly warns functions only used through ifuncs are unused, https://github.com/llvm/llvm-project/issues/63957. --- src/crc32c.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/crc32c.c b/src/crc32c.c index 1d667b3dbf656..68d81732002fb 100644 --- a/src/crc32c.c +++ b/src/crc32c.c @@ -178,6 +178,10 @@ JL_DLLEXPORT uint32_t jl_crc32c(uint32_t crc, const char *buf, size_t len) return crc32c_sse42(crc, buf, len); } # else +#ifdef JL_CRC32C_USE_IFUNC && _COMPILER_CLANG_ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-function" +#endif static crc32c_func_t crc32c_dispatch(void) { // When used in ifunc, we cannot call external functions (i.e. jl_cpuid) @@ -199,6 +203,9 @@ static crc32c_func_t crc32c_dispatch(void) return crc32c_sse42; return jl_crc32c_sw; } +#if JL_CRC32C_USE_IFUNC && _COMPILER_CLANG_ +#pragma clang diagnostic pop +#endif // For ifdef detection below # define crc32c_dispatch crc32c_dispatch # define crc32c_dispatch_ifunc "crc32c_dispatch"