Skip to content

Commit

Permalink
disable avx2 on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbachmann authored May 19, 2024
1 parent ffa4a81 commit 5b4a014
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 36 deletions.
18 changes: 7 additions & 11 deletions .github/workflows/releasebuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,28 +109,24 @@ jobs:
path: ./wheelhouse/*.whl

build_wheels_macos:
name: Build wheel on macos-13/${{matrix.arch}}/${{matrix.python_tag}}
name: Build wheel on ${{ matrix.os }}/native/${{matrix.python_tag}}
needs: [build_sdist]
runs-on: macos-13
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
arch: [x86_64, arm64, universal2]
os: [macos-13, macos-14]
python_tag: ["cp38-*", "cp39-*", "cp310-*", "cp311-*", "cp312-*", "pp38-*", "pp39-*"]
exclude:
# PyPy not supported on MacOS Arm
- arch: arm64
- os: macos-14
python_tag: "pp38-*"
- arch: arm64
python_tag: "pp39-*"
- arch: universal2
python_tag: "pp38-*"
- arch: universal2
- os: macos-14
python_tag: "pp39-*"
env:
CIBW_BUILD: ${{matrix.python_tag}}
CIBW_ARCHS: ${{matrix.arch}}
CIBW_TEST_SKIP: "{*-macosx_{arm64,universal2},pp*-macosx_*}"
CIBW_ARCHS: native
CIBW_TEST_SKIP: "pp*-macosx_*"
#CIBW_TEST_REQUIRES: pytest hypothesis pandas
CIBW_TEST_REQUIRES: pytest hypothesis
CIBW_TEST_COMMAND: pytest {package}/tests
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
---------

[3.9.1] - 2024-05-19
^^^^^^^^^^^^^^^^^^^^
Fixed
~~~~~
* disable AVX2 on MacOS since it did lead to illegal instructions being generated


[3.9.0] - 2024-05-02
^^^^^^^^^^^^^^^^^^^^
Changed
Expand Down
25 changes: 14 additions & 11 deletions src/rapidfuzz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,22 @@ target_link_libraries(fuzz_cpp PRIVATE rapidfuzz::rapidfuzz)
install(TARGETS fuzz_cpp LIBRARY DESTINATION src/rapidfuzz)

if(RAPIDFUZZ_ARCH_X64 OR RAPIDFUZZ_ARCH_X86)
create_cython_target(fuzz_cpp_avx2)
rf_add_library(fuzz_cpp_avx2 ${fuzz_cpp_avx2})
target_compile_features(fuzz_cpp_avx2 PUBLIC cxx_std_17)
# on macOs this generates illegal instructions https://github.com/rapidfuzz/RapidFuzz/issues/383
if(NOT APPLE)
create_cython_target(fuzz_cpp_avx2)
rf_add_library(fuzz_cpp_avx2 ${fuzz_cpp_avx2})
target_compile_features(fuzz_cpp_avx2 PUBLIC cxx_std_17)

if(MSVC)
set_target_properties(fuzz_cpp_avx2 PROPERTIES COMPILE_FLAGS "/arch:AVX2")
else()
set_target_properties(fuzz_cpp_avx2 PROPERTIES COMPILE_FLAGS "-mavx2")
endif()
if(MSVC)
set_target_properties(fuzz_cpp_avx2 PROPERTIES COMPILE_FLAGS "/arch:AVX2")
else()
set_target_properties(fuzz_cpp_avx2 PROPERTIES COMPILE_FLAGS "-mavx2")
endif()

target_include_directories(fuzz_cpp_avx2 PRIVATE ${RF_BASE_DIR}/rapidfuzz)
target_link_libraries(fuzz_cpp_avx2 PRIVATE rapidfuzz::rapidfuzz)
install(TARGETS fuzz_cpp_avx2 LIBRARY DESTINATION src/rapidfuzz)
target_include_directories(fuzz_cpp_avx2 PRIVATE ${RF_BASE_DIR}/rapidfuzz)
target_link_libraries(fuzz_cpp_avx2 PRIVATE rapidfuzz::rapidfuzz)
install(TARGETS fuzz_cpp_avx2 LIBRARY DESTINATION src/rapidfuzz)
endif()
endif()

if(RAPIDFUZZ_ARCH_X86)
Expand Down
31 changes: 17 additions & 14 deletions src/rapidfuzz/distance/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,25 @@ target_link_libraries(metrics_cpp PRIVATE rapidfuzz::rapidfuzz)
install(TARGETS metrics_cpp LIBRARY DESTINATION src/rapidfuzz/distance)

if(RAPIDFUZZ_ARCH_X64 OR RAPIDFUZZ_ARCH_X86)
create_cython_target(metrics_cpp_avx2)
rf_add_library(metrics_cpp_avx2 ${metrics_cpp_avx2})
target_compile_features(metrics_cpp_avx2 PUBLIC cxx_std_17)
# on macOs this generates illegal instructions https://github.com/rapidfuzz/RapidFuzz/issues/383
if(NOT APPLE)
create_cython_target(metrics_cpp_avx2)
rf_add_library(metrics_cpp_avx2 ${metrics_cpp_avx2})
target_compile_features(metrics_cpp_avx2 PUBLIC cxx_std_17)

if(MSVC)
set_target_properties(metrics_cpp_avx2 PROPERTIES COMPILE_FLAGS
"/arch:AVX2")
else()
set_target_properties(metrics_cpp_avx2 PROPERTIES COMPILE_FLAGS "-mavx2")
endif()
if(MSVC)
set_target_properties(metrics_cpp_avx2 PROPERTIES COMPILE_FLAGS
"/arch:AVX2")
else()
set_target_properties(metrics_cpp_avx2 PROPERTIES COMPILE_FLAGS "-mavx2")
endif()

target_include_directories(
metrics_cpp_avx2 PRIVATE ${RF_BASE_DIR}/rapidfuzz
${RF_BASE_DIR}/rapidfuzz/distance)
target_link_libraries(metrics_cpp_avx2 PRIVATE rapidfuzz::rapidfuzz)
install(TARGETS metrics_cpp_avx2 LIBRARY DESTINATION src/rapidfuzz/distance)
target_include_directories(
metrics_cpp_avx2 PRIVATE ${RF_BASE_DIR}/rapidfuzz
${RF_BASE_DIR}/rapidfuzz/distance)
target_link_libraries(metrics_cpp_avx2 PRIVATE rapidfuzz::rapidfuzz)
install(TARGETS metrics_cpp_avx2 LIBRARY DESTINATION src/rapidfuzz/distance)
endif()
endif()

if(RAPIDFUZZ_ARCH_X86)
Expand Down

0 comments on commit 5b4a014

Please sign in to comment.