abess-team / abess

Fast Best-Subset Selection Library
https://abess.readthedocs.io/
Other
474 stars 41 forks source link

Compilation Fails on AARCH64 / ARM64 Due to x86 Specific Compiler Flags #541

Open MattWenham opened 3 months ago

MattWenham commented 3 months ago

Version 0.4.8 fails to compile for AARCH64 / ARM64 due to the two x86 specific compiler flags in CMakeLists.txt: -mavx and -mfma.

CMakeLists.txt ideally needs to take into account architecture as well as platform.

ecm200 commented 2 months ago

Suggest the following addition to the CMakeLists.txt to accommodate:

Currently the compiler flag options cover the following:

if(MSVC)
    SET(CMAKE_CXX_FLAGS "/EHsc /arch:AVX2")
    SET(CMAKE_CXX_FLAGS_DEBUG "/W4")
elseif(DARWIN)
    SET(CMAKE_CXX_FLAGS "-Wno-int-in-bool-context -std=c++11")
    SET(CMAKE_CXX_FLAGS_DEBUG "-Wall")
else()
    SET(CMAKE_CXX_FLAGS "-march=native -Wno-int-in-bool-context -std=c++11 -mavx -mfma")
    SET(CMAKE_CXX_FLAGS_DEBUG "-Wall")
endif()

Suggest adding a further outcome to cover explicitly the aarch64 compilation and remove flags which cause built errors:

elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
    SET(CMAKE_CXX_FLAGS "-march=native -Wno-int-in-bool-context -std=c++11")
    SET(CMAKE_CXX_FLAGS_DEBUG "-Wall")

I have tested this solution and it builds without issue on aarch64 machine.

Mamba413 commented 2 months ago

Thank you @MattWenham and @ecm200 . We will take a look and update CMakeLists.txt accordingly soon.