Open cmaloney111 opened 1 week ago
I don't think we need an special handling for Apple M3.
Somehow the following replacement was not performed
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64le" OR CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
string(REPLACE "-march" "-mcpu" OCCA_CXXFLAGS ${OCCA_CXXFLAGS})
string(REPLACE "-march" "-mcpu" CMAKE_Fortran_FLAGS_RELWITHDEBINFO ${CMAKE_Fortran_FLAGS_RELWITHDEBINFO})
string(REPLACE "-march" "-mcpu" CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO})
string(REPLACE "-march" "-mcpu" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
endif()
Can you please check why.
In general I suggest to remove -mtune
. It's not needed.
Okay, I removed the -mtune flag and the special handling for Apple M3. The replacement you mentioned was performed. I apologize as I should not have included that part in my pull request as it occured when I was testing the master branch and not this branch. Only the second error (with -mtune) is relevant for this branch.
Description:
This PR introduces changes to the
CMakeLists.txt
file to support compilation for the Apple M3 architecture. Initially, the following errors were encountered due to incorrect or unsupported compiler flags for the M3 processor.Errors Encountered:
-march During the build, the following error was thrown:
This error occurred because the compiler does not recognize
-march=apple-m3
, but rather, it suggests using-mcpu=apple-m3
.-mtune After correcting the
-march
flag, the following error was encountered:This error occurred because the
-mtune
flag does not supportapple-m3
as a valid argument.Changes Made:
To address these issues, the following changes were made to the
CMakeLists.txt
file:A check was added for detecting the Apple M3 architecture using
sysctl -n machdep.cpu.brand_string
to get the processer name. If the brand string contains Apple M3, the code changes certain compiler flags-march
: The incorrect-march=native
was replaced with-mcpu=native
, which is the correct flag to target Apple M3 processors.-mtune
: The-mtune=native
flag was removed, as it is not supported.