From d35085480fc31ed92b20bea4abe8a0216be64363 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 21 Dec 2024 22:59:18 +0100 Subject: [PATCH] crc-x86_64: Fix compilation error with clang. * modules/crc-x86_64 (Makefile.am): Declare a separate library libpclmul.{a,la}. * lib/crc-x86_64-pclmul.c: Remove the GCC pragmas. --- ChangeLog | 5 +++++ lib/crc-x86_64-pclmul.c | 4 ---- modules/crc-x86_64 | 12 +++++++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 02a1a23ba3..70dfe4f0a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2024-12-21 Bruno Haible + crc-x86_64: Fix compilation error with clang. + * modules/crc-x86_64 (Makefile.am): Declare a separate library + libpclmul.{a,la}. + * lib/crc-x86_64-pclmul.c: Remove the GCC pragmas. + gnulib-tool: Recognize @LT@, @la@, @lo@ tokens in module descriptions. * gnulib-tool.sh (func_emit_lib_Makefile_am): Replace @LT@, @la@, @lo@ tokens. diff --git a/lib/crc-x86_64-pclmul.c b/lib/crc-x86_64-pclmul.c index edda2081ef..91f361d2ce 100644 --- a/lib/crc-x86_64-pclmul.c +++ b/lib/crc-x86_64-pclmul.c @@ -24,8 +24,6 @@ #include -#pragma GCC push_options -#pragma GCC target("pclmul,avx") uint32_t crc32_update_no_xor_pclmul (uint32_t crc, const void *buf, size_t len) { @@ -204,5 +202,3 @@ crc32_update_no_xor_pclmul (uint32_t crc, const void *buf, size_t len) return crc; } - -#pragma GCC pop_options diff --git a/modules/crc-x86_64 b/modules/crc-x86_64 index 2e4b5bf744..15876991ab 100644 --- a/modules/crc-x86_64 +++ b/modules/crc-x86_64 @@ -15,7 +15,17 @@ AC_REQUIRE([gl_CRC_X86_64_PCLMUL]) Makefile.am: if GL_CRC_X86_64_PCLMUL -lib_SOURCES += crc-x86_64-pclmul.c +# We need a separate library, in order to compile crc-x86_64-pclmul.c with +# particular CFLAGS. +# (Recall that '#pragma GCC target (...)' works only with gcc, not with clang. +# And the alternative approach of target-specific CFLAGS in 'make' syntax +# +# is not portable: it does not work with OpenBSD 'make'.) +noinst_@LT@LIBRARIES += libpclmul.@la@ +libpclmul_@la@_SOURCES = crc-x86_64-pclmul.c +libpclmul_@la@_CFLAGS = $(AM_CFLAGS) -mavx -mpclmul +lib_LIBADD += libpclmul_@la@-crc-x86_64-pclmul.@lo@ +lib_DEPENDENCIES += libpclmul.@la@ endif Include: -- 2.39.5