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.
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}.
#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)
{
# 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,
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)
{
fi
AM_CONDITIONAL([GL_CRC_X86_64_PCLMUL],
[test $gl_cv_crc_pclmul = yes])
- CFLAGS=$ac_save_CFLAGS
])
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: