]> Savannah Git Hosting - gnulib.git/commitdiff
crc-x86_64: Fix compilation error with clang in a simpler way.
authorBruno Haible <bruno@clisp.org>
Sun, 22 Dec 2024 00:09:17 +0000 (01:09 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 22 Dec 2024 00:09:17 +0000 (01:09 +0100)
Suggested by Collin Funk.

* modules/crc-x86_64 (Makefile.am): Revert last change.
* lib/crc-x86_64-pclmul.c: Normalize includes.
(crc32_update_no_xor_pclmul): Use __attribute__ ((__target (...))).
* m4/crc-x86_64.m4 (gl_CRC_X86_64_PCLMUL): Use
__attribute__ ((__target (...))) here as well. Don't use modified
CFLAGS.

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

index 70dfe4f0a74b5cbd43c5c6c1aeb403fdc9ad8a1b..4121ec0018dab0c2055340c584587410a9e46c02 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2024-12-21  Bruno Haible  <bruno@clisp.org>
 
+       crc-x86_64: Fix compilation error with clang in a simpler way.
+       Suggested by Collin Funk.
+       * modules/crc-x86_64 (Makefile.am): Revert last change.
+       * lib/crc-x86_64-pclmul.c: Normalize includes.
+       (crc32_update_no_xor_pclmul): Use __attribute__ ((__target (...))).
+       * m4/crc-x86_64.m4 (gl_CRC_X86_64_PCLMUL): Use
+       __attribute__ ((__target (...))) here as well. Don't use modified
+       CFLAGS.
+
        crc-x86_64: Fix compilation error with clang.
        * modules/crc-x86_64 (Makefile.am): Declare a separate library
        libpclmul.{a,la}.
index 91f361d2ce73d467f36df32f2fee6761de7fe4dc..170ebfcef0a0581bf58ac38aa66043a9a40f1914 100644 (file)
 
 #include <config.h>
 
+/* Specification.  */
 #include "crc-x86_64.h"
-#include "x86intrin.h"
-#include "crc.h"
 
 #include <string.h>
+#include <x86intrin.h>
+
+#include "crc.h"
 
+#if defined __GNUC__ || defined __clang__
+__attribute__ ((__target__ ("pclmul,avx")))
+#endif
 uint32_t
 crc32_update_no_xor_pclmul (uint32_t crc, const void *buf, size_t len)
 {
index fa649a5b82a95a7254e2e77badae450c2291781a..470e6333fffb1d53f8df23a95b57bce1518d5fbe 100644 (file)
@@ -1,5 +1,5 @@
 # crc-x86_64.m4
-# serial 2
+# serial 3
 dnl Copyright (C) 2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -8,14 +8,15 @@ dnl This file is offered as-is, without any warranty.
 
 AC_DEFUN([gl_CRC_X86_64_PCLMUL],
 [
-  ac_save_CFLAGS=$CFLAGS
-  CFLAGS="-mavx -mpclmul $CFLAGS"
   AC_CACHE_CHECK([if pclmul intrinsic exists], [gl_cv_crc_pclmul], [
     AC_LINK_IFELSE(
       [AC_LANG_SOURCE(
         [[
           #include <x86intrin.h>
 
+          #if defined __GNUC__ || defined __clang__
+          __attribute__ ((__target__ ("pclmul,avx")))
+          #endif
           int
           main (void)
           {
@@ -37,5 +38,4 @@ AC_DEFUN([gl_CRC_X86_64_PCLMUL],
   fi
   AM_CONDITIONAL([GL_CRC_X86_64_PCLMUL],
                  [test $gl_cv_crc_pclmul = yes])
-  CFLAGS=$ac_save_CFLAGS
 ])
index 15876991abe290db7d1594c304237b7a7d1eb903..2e4b5bf744bfcbae7c1d2517e3e1a8fdf7b3d508 100644 (file)
@@ -15,17 +15,7 @@ AC_REQUIRE([gl_CRC_X86_64_PCLMUL])
 
 Makefile.am:
 if GL_CRC_X86_64_PCLMUL
-# 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@
+lib_SOURCES += crc-x86_64-pclmul.c
 endif
 
 Include: