From f141ad84cdda8758d60dd5655024e9d2be662da7 Mon Sep 17 00:00:00 2001 From: Raghuveer Devulapalli Date: Thu, 21 Nov 2024 14:59:29 -0800 Subject: [PATCH v5 2/2] Use consistent logic in configure and meson to generate USE_SSE42_CRC32C --- meson.build | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index 671ac7052b..c04c250631 100644 --- a/meson.build +++ b/meson.build @@ -2236,11 +2236,9 @@ if host_cpu == 'x86' or host_cpu == 'x86_64' sse42_crc_prog = ''' #include -#ifdef TEST_SSE42_WITH_ATTRIBUTE #if defined(__has_attribute) && __has_attribute (target) __attribute__((target("sse4.2"))) #endif -#endif int main(void) { unsigned int crc = 0; @@ -2251,16 +2249,16 @@ int main(void) } ''' - if cc.links(sse42_crc_prog, name: '_mm_crc32_u8 and _mm_crc32_u32 without -msse4.2', - args: test_c_args) + canbuild_sse42_crc = cc.links(sse42_crc_prog, + name: 'Compile CRC32 SSE4.2 intrinsics with function attribute', + args: test_c_args) + if (cc.get_define('__SSE4_2__') != '' and canbuild_sse42_crc) # Use Intel SSE 4.2 unconditionally. cdata.set('USE_SSE42_CRC32C', 1) have_optimized_crc = true - elif cc.links(sse42_crc_prog, name: '_mm_crc32_u8 and _mm_crc32_u32 with sse4.2 function attribute', - args: test_c_args + ['-D TEST_SSE42_WITH_ATTRIBUTE']) + elif canbuild_sse42_crc # Use Intel SSE 4.2, with runtime check. The CPUID instruction is needed for # the runtime check. - cflags_crc += '-msse4.2' cdata.set('USE_SSE42_CRC32C', false) cdata.set('USE_SSE42_CRC32C_WITH_RUNTIME_CHECK', 1) have_optimized_crc = true -- 2.43.0