]> Savannah Git Hosting - gnulib.git/commitdiff
crc-x86_64: Fix compilation error with clang.
authorBruno Haible <bruno@clisp.org>
Sat, 21 Dec 2024 21:59:18 +0000 (22:59 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 21 Dec 2024 22:00:10 +0000 (23:00 +0100)
* modules/crc-x86_64 (Makefile.am): Declare a separate library
libpclmul.{a,la}.
* lib/crc-x86_64-pclmul.c: Remove the GCC pragmas.

ChangeLog
lib/crc-x86_64-pclmul.c
modules/crc-x86_64

index 02a1a23ba3e7f2da069777c7182490d72f20383c..70dfe4f0a74b5cbd43c5c6c1aeb403fdc9ad8a1b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2024-12-21  Bruno Haible  <bruno@clisp.org>
 
+       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.
index edda2081ef8a58a683cd29f053ac9b6672f6dc88..91f361d2ce73d467f36df32f2fee6761de7fe4dc 100644 (file)
@@ -24,8 +24,6 @@
 
 #include <string.h>
 
-#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
index 2e4b5bf744bfcbae7c1d2517e3e1a8fdf7b3d508..15876991abe290db7d1594c304237b7a7d1eb903 100644 (file)
@@ -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
+# <https://www.gnu.org/software/make/manual/html_node/Target_002dspecific.html>
+# 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: