Open mode80 opened 1 year ago
I just wasted a lot of time on this myself.
Here is what I learned:
hostCPU
is not determined at runtime, but is inherited from the bootstrapping compiler.--cpu:arm64
doesn't help.nim.cfg
will make this work for clang and ld:
@if macosx:
clang.options.always %= "${clang.options.always} -arch arm64"
clang.options.linker %= "${clang.options.linker} -arch arm64"
@end
choosenim seems to break packages and user code when installing Nim on an M1 mac (Apple silicone, ARM64) .
The issue seems to be that choosenim compiles the nim compiler as an x86 executable. Checking this, I get:
When packages and user code make use of code like
when defined(arm64)
, it incorrectly reports false, and instead reports true fordefined(amd64)
. The program usually crashes thereafter because whatever code path was needed for M1 doesn't run. (For example, the threading module using processor-specific assembly instructions based on this kind of check. )When I install nim with homebrew, and test, I get
Then things work as expected.