-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Apple Silicon / M1 #16211
Comments
can you please give it a try? not many people will have M1 macs so your help is appreciated a few things are need:
|
Calling build_all.sh gives this:
But it works smoothly after modyfing the following lines. Do I just do a pull request with the changes to the Makefile? I'm not too familiar with all the CI stuff :) Lines 152-154 in Makefile:
And then, lines 305-307 in Makefile: (copied from amd64)
|
I prepared a change to the Makefile in the csources repo, but I can't initiate a pull request because that repo is archived/read-only. https://github.com/nim-lang/csources/compare/master...kolinko:patch-1?expand=1 |
I ran koch tests, and there are some failed ones. I'm not sure if this is normal.
|
csources.Makefile is auto-generated; instead the fix should go in
when csources is finally updated (not loosing hope), it'll then pick up this change.
I would've been surprised if it worked out of the box; just like for any platform, not everything has to work from day 1, this is a start (we can turn this issue into a meta-issue tracking M1, like #14075 for freebsd) EDIT
maybe with M1, the time has come for csources2 (and revive/redo #13854), and bootstrap from latest stable (1.4.2) ? |
Yep, that's all that should be needed to get it going. It most definitely works, the C Sources just don't get built for arm64 on macOS (since that wasn't a thing in the past). But Nim has been working fine on arm for years. |
Tried it, changing installer.ini, nor makefile.nimf, doesn't work. build_all.sh fetches csources from repo, and just calls csources/build.sh as it is, with no auto-generation. There is also no way to change build_all to regenerate csources/build.sh, because regenerating from template requires koch or niminstall, and those are yet to be built at that stage. The only easy solution that comes to my mind, without updating the csources repo, would be to modify build_all.sh to patch build.sh if it notices MacOS&arm64 architecture. A bit hackish, but would allow people to build for M1 until csources2 arrives. |
maybe try |
Yes, but
|
We're preparing a csources2 repo based on Nim version 1, stay tuned. |
@Araq great to finally hear that, but can we please have an RFC so people can chime in? I can write it if needed.
|
Why? What do we want to use in the Nim compiler that is not in version 1.0? Note that every stdlib addition can directly be used within the Nim compiler as only the v1.0 nim binary is used for bootstrapping. |
If you implement this then the next Nim release will be built for arm64 on Mac OS. The C Sources for devel builds might still be broken sure, but you'll just be able to use the newest released Nim version instead. |
Every single compiler (non-stdlib) improvement (bugfix, feature, new cmdline flags) since 1.0, which is a lot. Nim kept bootstrapping from previous stable at regular intervals in the past (v0.20.0 v0.19.0 v0.18.0 v0.17.2 v0.16.0 v0.15.2 v0.13.0 v0.9.4, see https://github.com/timotheecour/csources/tags) which allowed compiler to benefit from latest stable release improvements and cleanup code, there's no reason why this should stop just because 1.0 was released. All those conditionals in
Beyond compiler sources, I'd also like koch (+ all the files it depends on, kochdocs etc) to benefit from recent compiler features; this also helps with promoting more recent best practices. I'm curious what are the downsides you have in mind for bootstrapping from latest stable and updating csources2 as was the case until recently. I'm not aware of people ever complaining about that (apart from not knowing which nim is needed for bootstrapping, which is easily fixed, eg as I did in #13854). If you still disagree, then how about opening an RFC to discuss that. |
That's not an answer, that is avoiding an answer. Which language features past 1.0 are useful inside the Nim compiler? Again, library additions don't count, we can use pretty much all of them.
1.0 is not just a number, it's our long-term stable release. And currently our only one. It makes sense to demand that a Nim version 1.0 compiler can compile later Nim compilers.
I remember the times we updated the csources frequently, I'm not looking back. The current way is much more pleasant to work with.
Like what? Which features would these be that are helpful for
These cleanups should be done for Nim version 2 IMHO. |
Should be called something like "csources-v1" to reduce confusion IMO. But this is good news! |
Is csources_v1 still being worked on? The last commit seems to be two weeks old, and hacking the build_all.sh to git install it instead of csources isn’t sufficient to build on my M1. |
Yes. Please try again, I cannot test it as I don't have an M1. |
I am getting the same error as mentioned here: |
This solution from the OG seems to work on older commits not using build_all |
|
Maybe I'm doing something wrong? MBP:Desktop$git clone https://github.com/nim-lang/Nim
Cloning into 'Nim'...
remote: Enumerating objects: 400, done.
remote: Counting objects: 100% (400/400), done.
remote: Compressing objects: 100% (77/77), done.
remote: Total 134902 (delta 333), reused 363 (delta 323), pack-reused 134502
Receiving objects: 100% (134902/134902), 97.55 MiB | 6.54 MiB/s, done.
Resolving deltas: 100% (103751/103751), done.
MBP:Desktop$cd Nim/
MBP:Nim$./build_all.sh
git clone -q --depth 1 https://github.com/nim-lang/csources.git
build_nim_csources
/usr/bin/make
make -C csources -j 10 -l 8
makefile:156: *** unknown processor: arm64. Stop.
cd csources
sh build.sh
# OS: macosx
# CPU: arm
clang -o ../bin/nim -ldl -lm
Undefined symbols for architecture arm64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation) |
You need to use |
I can confirm that csources_v1.git works getting Nim to compile on M1. So the following steps worked for me: (EDIT(timotheecour): I've updated instructions in this commment because people are confused, refs https://forum.nim-lang.org/t/8240#53030): git clone https://github.com/nim-lang/Nim
cd Nim
sh build_all.sh
|
(for implementation, we could do similarly as was done in #12931 which called |
@joubertnel I think this should be |
@elijahr you're right; thanks for catching. I updated my original comment so that future readers don't get thrown off. |
correct instructions to install nim are: git clone https://github.com/nim-lang/Nim
cd Nim
sh build_all.sh (as explained in readme in https://github.com/nim-lang/Nim) |
./build.sh seems to fail on M1, I managed to compile it by hacking the file, but I'm not sure if it's a proper solution.
Example
Current Output
Possible Solution
I switched amd64 to arm64 in the line 6640 of ./build.sh.
It just compiled and it seems to be running well on my laptop. I don't know enough about makefiles and build scripts to make a proper pull request though.
The text was updated successfully, but these errors were encountered: