From 77e81ea9fdc3b610edda6443e59d15bb1f7be472 Mon Sep 17 00:00:00 2001 From: Chenxi Mao Date: Thu, 8 Jun 2023 13:17:51 +0800 Subject: [PATCH] Fix build error if AVX2 enabled Build error on X86_64 with AVX2: [ 11s] /home/abuild/rpmbuild/BUILD/c-blosc-1.14.4/blosc/shuffle.c:170:1: error: conflicting types for '_xgetbv' [ 11s] 170 | _xgetbv(uint32_t xcr) { [ 11s] | ^~~~~~~ [ 11s] In file included from /usr/lib/gcc/x86_64-linux-gnu/10.3.1/include/immintrin.h:43, [ 11s] from /home/abuild/rpmbuild/BUILD/c-blosc-1.14.4/blosc/blosc-common.h:77, [ 11s] from /home/abuild/rpmbuild/BUILD/c-blosc-1.14.4/blosc/shuffle.h:18, [ 11s] from /home/abuild/rpmbuild/BUILD/c-blosc-1.14.4/blosc/shuffle.c:10: [ 11s] /usr/lib/gcc/x86_64-linux-gnu/10.3.1/include/xsaveintrin.h:60:1: note: previous definition of '_xgetbv' was here [ 11s] 60 | _xgetbv (unsigned int __A) [ 11s] | ^~~~~~~ [ 11s] make[2]: *** [blosc/CMakeFiles/blosc_shared_testing.dir/build.make:205: blosc/CMakeFiles/blosc_shared_testing.dir/shuffle.c.o] Error 1 Cherry pick upstream patch to fix this issue. Change-Id: I816c8a2bb36735870df8370b0eca6bfc9167c583 Signed-off-by: Chenxi Mao --- blosc.spec | 6 +- ...uplicated-_xgetbv-symbol-when-using-.patch | 63 +++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 upstream-Get-rid-of-the-duplicated-_xgetbv-symbol-when-using-.patch diff --git a/blosc.spec b/blosc.spec index fe1a575..b4c31ff 100644 --- a/blosc.spec +++ b/blosc.spec @@ -1,10 +1,11 @@ Name: blosc Version: 1.14.4 -Release: 4 +Release: 5 Summary: Binary compressor License: MIT URL: https://github.com/Blosc/c-blosc Source: https://github.com/Blosc/c-blosc/archive/v%{version}/blosc-%{version}.tar.gz +Patch0001: upstream-Get-rid-of-the-duplicated-_xgetbv-symbol-when-using-.patch BuildRequires: cmake lz4-devel snappy-devel zlib-devel libzstd-devel gcc-g++ @@ -84,6 +85,9 @@ install -p bench/plot-speeds.py %{buildroot}/%{_bindir}/%{name}-plot-times %{_bindir}/%{name}-plot-times %changelog +* Fri Jun 09 2023 Chenxi Mao - 1.14.4-5 +- Fix build error if AVX2 enabled. + * Mon May 31 2021 baizhonggui - 1.14.4-4 - Fix building error: No CMAKE_CXX_COMPULER could be found - Add gcc-g++ in BuildRequires diff --git a/upstream-Get-rid-of-the-duplicated-_xgetbv-symbol-when-using-.patch b/upstream-Get-rid-of-the-duplicated-_xgetbv-symbol-when-using-.patch new file mode 100644 index 0000000..6121ba5 --- /dev/null +++ b/upstream-Get-rid-of-the-duplicated-_xgetbv-symbol-when-using-.patch @@ -0,0 +1,63 @@ +From 22d679366b7ca9f3f89fb242600f3b6f72ff03dd Mon Sep 17 00:00:00 2001 +From: Francesc Alted +Date: Fri, 24 Apr 2020 18:02:48 +0200 +Subject: [PATCH 1/1] Get rid of the duplicated _xgetbv symbol when using GCC + >= 9 + +--- + blosc/blosc-common.h | 5 ++++- + blosc/shuffle.c | 6 +++++- + 2 files changed, 9 insertions(+), 2 deletions(-) + +diff --git a/blosc/blosc-common.h b/blosc/blosc-common.h +index 0b2c2fc..3709b79 100644 +--- a/blosc/blosc-common.h ++++ b/blosc/blosc-common.h +@@ -12,9 +12,12 @@ + #include "blosc-export.h" + #include + ++#ifdef __GNUC__ ++#define BLOSC_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) ++#endif // __GNUC__ ++ + /* Import standard integer type definitions */ + #if defined(_WIN32) && !defined(__MINGW32__) +- + /* stdint.h only available in VS2010 (VC++ 16.0) and newer */ + #if defined(_MSC_VER) && _MSC_VER < 1600 + #include "win32/stdint-windows.h" +diff --git a/blosc/shuffle.c b/blosc/shuffle.c +index 2d3524b..c8faac9 100644 +--- a/blosc/shuffle.c ++++ b/blosc/shuffle.c +@@ -8,6 +8,7 @@ + **********************************************************************/ + + #include "shuffle.h" ++#include "blosc-common.h" + #include "shuffle-generic.h" + #include "bitshuffle-generic.h" + #include +@@ -163,6 +164,8 @@ __cpuidex(int32_t cpuInfo[4], int32_t function_id, int32_t subfunction_id) { + + #define _XCR_XFEATURE_ENABLED_MASK 0 + ++#if !(defined(_IMMINTRIN_H_INCLUDED) && (BLOSC_GCC_VERSION >= 900)) ++ + /* Reads the content of an extended control register. + https://software.intel.com/en-us/articles/how-to-detect-new-instruction-support-in-the-4th-generation-intel-core-processor-family + */ +@@ -182,7 +185,8 @@ _xgetbv(uint32_t xcr) { + return ((uint64_t)edx << 32) | eax; + } + +-#endif /* defined(_MSC_FULL_VER) */ ++#endif // !(defined(_IMMINTRIN_H_INCLUDED) && (BLOSC_GCC_VERSION >= 900)) ++#endif /* defined(_MSC_FULL_VER) */ + + #ifndef _XCR_XFEATURE_ENABLED_MASK + #define _XCR_XFEATURE_ENABLED_MASK 0x0 +-- +2.33.0 + -- Gitee