KMC icon indicating copy to clipboard operation
KMC copied to clipboard

Apple Silicon Build Issue

Open jeremiahpslewis opened this issue 3 years ago • 6 comments

Hi! I'm utterly new to the project, but wanted to build your tool for Apple ARM processors and seem to be hitting the following error:

[16:52:36] g++ -Wall -O3 -static-libgcc -static-libstdc++ -pthread -std=c++14 -c kmc_core/cpu_info.cpp -o kmc_core/cpu_info.o
[16:52:36] In member function ‘void CpuInfoImpl::cpuid(int*, int) const’,
[16:52:36]     inlined from ‘const std::string& CpuInfoImpl::GetBrand()’ at kmc_core/cpu_info.cpp:105:8,
[16:52:36]     inlined from ‘static const std::string& CCpuInfo::GetBrand()’ at kmc_core/cpu_info.cpp:135:31:
[16:52:36] kmc_core/cpu_info.cpp:52:17: error: impossible constraint in ‘asm’
[16:52:36]    52 |                 __asm__("cpuid\n\t"
[16:52:36]       |                 ^~~~~~~
[16:52:36] In member function ‘void CpuInfoImpl::cpuid(int*, int) const’,
[16:52:36]     inlined from ‘const std::string& CpuInfoImpl::GetBrand()’ at kmc_core/cpu_info.cpp:112:9,
[16:52:36]     inlined from ‘static const std::string& CCpuInfo::GetBrand()’ at kmc_core/cpu_info.cpp:135:31:
[16:52:36] kmc_core/cpu_info.cpp:52:17: error: impossible constraint in ‘asm’
[16:52:36]    52 |                 __asm__("cpuid\n\t"
[16:52:36]       |                 ^~~~~~~
[16:52:36] make: *** [Makefile:111: kmc_core/cpu_info.o] Error 1
[16:52:36]  ---> make kmc kmc_dump kmc_tools
[16:52:36]  ---> make kmc kmc_dump kmc_tools
[16:52:36] Previous command exited with 2
[16:52:36] Child Process exited, exit code 2

Is this something that might be amenable to a minor tweak?

jeremiahpslewis avatar Sep 26 '22 17:09 jeremiahpslewis

Here's the PR for packaging the binary for the Julia ecosystem in case you're interested. :) https://github.com/JuliaPackaging/Yggdrasil/pull/5582

jeremiahpslewis avatar Sep 26 '22 17:09 jeremiahpslewis

Hello! Thanks. Adding support for ARM build is quite high on our priorities list, but we have some things that are higher and need to be completed first. Unfortunately, I'm unable to say when we will add ARM support.

Best Marek

marekkokot avatar Sep 26 '22 20:09 marekkokot

Cool! Good to know it's a known topic, will just deactivate the platform for now. :)

jeremiahpslewis avatar Sep 26 '22 21:09 jeremiahpslewis

Hi @marekkokot: mentioning a related update! Recently we released cuttlefish v2.2.0, which builds and runs on M1 and M2. For such, we (@TheJasonFan) patched KMC to adopt SIMDe, and this allows KMC to compile natively for ARM. The update-PR is here. This modification should work on other ARM processors too, we believe.

jamshed avatar Mar 02 '23 17:03 jamshed

I was looking into this and I noticed that the only SIMD commands used in KMC (_mm_stream_si64 and _mm_stream_si128) have no equivalents in ARM (at least, none that I could find), so SIMDe defaults to doing a regular copy in its implementations of these. So maybe incorporating SIMDe into KMC for this is overkill.

hmusta avatar Mar 02 '23 17:03 hmusta

Hi @jeremiahpslewis @hmusta @jamshed, thank you all very much!

In principle, we prefer to fix such things on our own instead of using big libraries (if possible with an acceptable development cost of course), and here it was only a couple of places in the code to be changed. I've just created a new release with precompiled binaries for ARM64. We would really appreciate any feedback if something is wrong. Thanks again!

marekkokot avatar Mar 10 '23 11:03 marekkokot