Skip to content

Commit

Permalink
disabling AVX routines under Visual Studio (#603)
Browse files Browse the repository at this point in the history
* disabling AVX routines under Visual Studio

* formatting

* Adding link to PR

* asking MSVS to export all symbols when building amal. library

* typo
  • Loading branch information
lemire authored Mar 1, 2024
1 parent 81c5e04 commit 67cddc3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ if(ENABLE_ROARING_TESTS AND BASH)
add_test(amalgamate_demo amalgamate_demo)

add_library(croaring-singleheader-source-lib $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/roaring.c>)
set_target_properties(croaring-singleheader-source-lib PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS YES)
target_include_directories(croaring-singleheader-source-lib PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)

add_executable(amalgamate_demo_cpp $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/amalgamation_demo.cpp>)
Expand Down
11 changes: 11 additions & 0 deletions src/isadetection.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ POSSIBILITY OF SUCH DAMAGE.
#include <stdint.h>
#include <stdlib.h>

// Binaries produced by Visual Studio with solely AVX2 routines
// can compile to AVX-512 thus causing crashes on non-AVX-512 systems.
// This appears to affect VS 17.8 and 17.9. We disable AVX-512 and AVX2
// on these systems. It seems that ClangCL is not affected.
// https://github.com/RoaringBitmap/CRoaring/pull/603
#ifndef __clang__
#if _MSC_VER >= 1938
#define ROARING_DISABLE_AVX 1
#endif // _MSC_VER >= 1938
#endif // __clang__

// We need portability.h to be included first, see
// https://github.com/RoaringBitmap/CRoaring/issues/394
#include <roaring/portability.h>
Expand Down

0 comments on commit 67cddc3

Please sign in to comment.