Skip to content

Commit

Permalink
Do not pass -m flags when compiling shuffle.c
Browse files Browse the repository at this point in the history
Do not pass `-msse2`, `-mavx2`, etc. flags to the compiler when
compiling `shuffle.c`.  From what I can see, the file itself does not
use any of these intrinsics, and they are only used by functions
declared in `bitshuffle-*.c` and `shuffle-*.c` (where the respective
flags are still passed).  This prevents the compiler from incidentally
optimizing the code called independenlty of the runtime CPU check to
these instruction sets, effectively causing `SIGILL` on other CPUs.

I have verified that this fixes the issue on `-march=znver2`, but also
does not cause any issues on `-march=x86-64` and `-march=i686`.

Fixes Blosc#621
  • Loading branch information
mgorny committed Jun 25, 2024
1 parent dc5d651 commit 8709b80
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions blosc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -300,17 +300,11 @@ if(COMPILER_SUPPORT_SSE2)
set_source_files_properties(
shuffle-sse2.c bitshuffle-sse2.c blosclz.c fastcopy.c
PROPERTIES COMPILE_OPTIONS "/arch:SSE2")
set_property(
SOURCE shuffle.c
APPEND PROPERTY COMPILE_OPTIONS "/arch:SSE2")
endif()
else()
set_source_files_properties(
shuffle-sse2.c bitshuffle-sse2.c blosclz.c fastcopy.c
PROPERTIES COMPILE_OPTIONS -msse2)
set_property(
SOURCE shuffle.c
APPEND PROPERTY COMPILE_OPTIONS -msse2)
# Add SIMD flags for the bytedelta filter and Intel (it seems that ARM64 does not need these)
set_source_files_properties(
${PROJECT_SOURCE_DIR}/plugins/filters/bytedelta/bytedelta.c
Expand All @@ -330,16 +324,10 @@ if(COMPILER_SUPPORT_AVX2)
set_source_files_properties(
shuffle-avx2.c bitshuffle-avx2.c
PROPERTIES COMPILE_OPTIONS "/arch:AVX2")
set_property(
SOURCE shuffle.c
APPEND PROPERTY COMPILE_OPTIONS "/arch:AVX2")
else()
set_source_files_properties(
shuffle-avx2.c bitshuffle-avx2.c
PROPERTIES COMPILE_OPTIONS -mavx2)
set_property(
SOURCE shuffle.c
APPEND PROPERTY COMPILE_OPTIONS -mavx2)
endif()

# Define a symbol for the shuffle-dispatch implementation
Expand All @@ -354,16 +342,10 @@ if(COMPILER_SUPPORT_AVX512)
set_source_files_properties(
bitshuffle-avx512.c
PROPERTIES COMPILE_OPTIONS "/arch:AVX512")
set_property(
SOURCE shuffle.c
APPEND PROPERTY COMPILE_OPTIONS "/arch:AVX512")
else()
set_source_files_properties(
bitshuffle-avx512.c
PROPERTIES COMPILE_OPTIONS "-mavx512f;-mavx512bw")
set_property(
SOURCE shuffle.c
APPEND PROPERTY COMPILE_OPTIONS "-mavx512f;-mavx512bw")
endif()

# Define a symbol for the shuffle-dispatch implementation
Expand All @@ -377,17 +359,11 @@ if(COMPILER_SUPPORT_NEON)
set_source_files_properties(
shuffle-neon.c bitshuffle-neon.c
PROPERTIES COMPILE_OPTIONS "-flax-vector-conversions")
set_property(
SOURCE shuffle.c
APPEND PROPERTY COMPILE_OPTIONS "-flax-vector-conversions")
if(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l)
# Only armv7l needs special -mfpu=neon flag; aarch64 doesn't.
set_source_files_properties(
shuffle-neon.c bitshuffle-neon.c
PROPERTIES COMPILE_OPTIONS "-mfpu=neon;-flax-vector-conversions")
set_property(
SOURCE shuffle.c
APPEND PROPERTY COMPILE_OPTIONS "-mfpu=neon;-flax-vector-conversions")
endif()
# Define a symbol for the shuffle-dispatch implementation
# so it knows NEON is supported even though that file is
Expand Down

0 comments on commit 8709b80

Please sign in to comment.