-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Build for arm64 Macs #12624
Build for arm64 Macs #12624
Conversation
CMakeLists.txt
Outdated
@@ -352,7 +352,7 @@ if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") | |||
add_definitions(-D_GNU_SOURCE) | |||
endif() | |||
|
|||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SIZEOF_VOID_P EQUAL 8) | |||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64" AND CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT PREFER_LUA) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems this isn't needed at all for LuaJIT >= 2.1.0 beta3. That would be a better check than adding the architecture.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the check to look for LUAJIT_VERSION LESS "2.1.0-beta3"
.
+++ b/bin/vterm-ctrl.c | ||
@@ -1,4 +1,4 @@ | ||
-#define _XOPEN_SOURCE 500 /* strdup */ | ||
+#define _XOPEN_SOURCE 600 /* strdup */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be fixed upstream. Cc @leonerd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted the commit and created neovim/libvterm#6.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the PR to use the newest revision of libvterm and adapted a line of code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and adapted a line of code.
That's an unreleased API change. We shouldn't be pulling that in. @leonerd, any chance of a maintenance release while the mainline stabilizes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ups, reverted the commit.
@leonerd Can you please release a new libvterm with the |
0.1.4 now at http://www.leonerd.org.uk/code/libvterm/ |
Updated the PR. I'll test on an arm64 Mac that it really builds next week once I'm back at home. |
@qvacua I just tested this on non-ARM macOS and got
The build works correctly (modulo the EDIT This is due to the following commit pulled in now: LuaJIT/LuaJIT@8961a92
It seems that you can no longer "trick" the LuaJIT build system with an empty MACOSX_DEPLOYMENT_TARGET but actually have to specify a valid target now. Would it make sense to provide a default here?I don't know what the correct (non-ARM) version would be? The same as LuaJIT's default, 10.4, doesn't work, but 10.9 seems to work: if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
if(CMAKE_OSX_DEPLOYMENT_TARGET)
set(DEPLOYMENT_TARGET "MACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}")
else()
set(DEPLOYMENT_TARGET "MACOSX_DEPLOYMENT_TARGET=10.9")
endif()
else()
set(DEPLOYMENT_TARGET "")
endif() This additional change makes this patch build correctly on Intel macOS, at least; lua seems to work fine in a cursory test. (You'd need to add a case for ARM hardware setting DEPLOYMENT_TARGET to 11.0, of course.) Otherwise this change for the macOS build (that you now have to set the EDIT3 Out of interest, I also checked Linux x86_64; there the patch (especially the bumped LuaJIT) builds fine out of the box. EDIT4 Testing a bit further, it seems there are in fact other changes in LuaJIT behavior -- for example, Can you comment on the LuaJIT bump, by the way? Is that a released (beta) version? |
Agreed. Let's do that first, since it's a clean and obvious fix and then there can be follow up work for other issues specific to the macOS/arm problems. |
third-party/CMakeLists.txt
Outdated
set(LIBVTERM_URL https://github.com/neovim/libvterm/archive/65dbda3ed214f036ee799d18b2e693a833a0e591.tar.gz) | ||
set(LIBVTERM_SHA256 95d3c7e86336fbd40dfd7a0aa0a795320bb71bc957ea995ea0e549c96d20db3a) | ||
set(LIBVTERM_URL http://www.leonerd.org.uk/code/libvterm/libvterm-0.1.4.tar.gz) | ||
set(LIBVTERM_SHA256 bc70349e95559c667672fc8c55b9527d9db9ada0fb80a3beda533418d782d3dd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yikes, no https? I really wish git-bzr did not mess up the hashes, that is the main problem with https://github.com/neovim/libvterm as a mirror . OTOH leonerd.org.uk has failed dozens of builds from network errors...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, leonerd.org.uk
doesn't support https... (I checked for #12797)
What is the issue with the hashes? That they have to be recomputed manually?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the issue with the hashes? That they have to be recomputed manually?
somehow git-bzr changes the hashes every time we update the mirror: https://github.com/neovim/bot-ci/blob/c799c16b003db67e353542ee7f1494731931dc6b/ci/sync-mirrors.sh#L46
not sure if we're using git-bzr wrong or if bzr just sucks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually it seems like that maybe isn't happening anymore ? if so then there's no reason to use leonerd.org.uk ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
except that the mirror isn't updated yet...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ups, I did not notice the missing s
in http
. I'll update the PR to use neovim/libvterm@54c03b2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neovim builds successfully and seems to work w/o problems on an arm64 Mac. @clason : I bumped the LuaJIT version since there were recent commits which fixed the build on arm64 Macs. I am not sure about incompatibilities introduced by the bump though. Regarding setting the deployment target: IMO, your suggestion is a good one. @justinmk , @jamessan: What is the officially supported minimum deployment target of Neovim? I guess 10.9, which @clason suggested, would also depend on the version of Xcode used. I think setting a default deployment target should be done in a different PR? For the sake of completeness: AFAICS, there are usually three "sources" for deployment target when building on macOS
It's not a big deal that the deployment targets of the dependencies and the |
Tried to build on MacBook Pro M1, LuaJIT failed to work out of box, an easy fix will be create a symlink for luajit in the bin folder and give it the name Lua. However, even after that fix, still failed to build with error code
|
You are trying to build an older released version that doesn't have the necessary patches, and using homebrew to boot. Can you please try building master ( |
Thank you for testing. So it looks like neovim actually builds correctly, but the binary crashes or hangs(?) afterwards when generating help tags. Could you try running |
This is what I get
I tried to delete the whole folder and clone it again and rebuilt it with |
Can you get a stacktrace or something? That's not a lot to go on... (And just to make sure -- you are using this PR and following the instructions in the description?) |
Not 100% sure if I'm on the right track, but this is what I got
|
@mikelxc: At least on the DTK, the |
BTW: Compilation succeeds only when |
@mikelxc: The |
It now builds without a problem after switching to the "build-arm64-mac" branch! |
For anyone having issues, or simply lazy (like me), the following steps can likely be blindly followed: git clone git@github.com:neovim/neovim
cd neovim
git remote add qvacua git@github.com:qvacua/neovim.git
echo "DEPS_CMAKE_FLAGS += -DCMAKE_OSX_DEPLOYMENT_TARGET=11.00" >> local.mk
make SDKROOT=`xcrun --show-sdk-path` Resulting in a functioning nvim at ~/s/n/neovim (build-arm64-mac)> file build/bin/nvim
build/bin/nvim: Mach-O 64-bit executable arm64 |
It's amazing how when somebody says "if you're lazy, just copy and paste this!" you tend to just do it, even when you know there's obviously a step missing. So if anybody else is as lazy as I was, here is the last comment, slightly corrected. (Either way, thanks @stefanpenner!)
|
ab2cb55
to
4d769b5
Compare
Looks like LuaJIT/LuaJIT@ff34b48 brought out some issues in our test stack -- still not sure if it's in our code or busted. Once we get a handle on those, we should be able to merge this PR. |
@jamessan is there any way I can help this along? Would be great to get this into master. |
We need to figure out why some of our tests are failing like below with this PR and fix it.
|
In particular, why the |
I believe I have a fix for this here: qvacua#1 (Wasn't sure the appropriate was of including this with this pr). |
This is properly handled in LuaJIT now and setting causes "Malformed Mach-o file" error when running the resulting binary on arm64 Macs.
LuaJIT build now requires specifying a deployment target, so use the same baseline as our nightly builds. Co-authored-by: Christian Clason <christian.clason@uni-due.de>
Apparently the new version of LuaJIT changed the consistency with which it sorted table dictionaries. IIRC lua sorts dictionary keys by memory address, so it would appear that the reasons tests were previously passing was because of a differentiation in the implementation of the lua runtime. Ensure that array fields in the lsp protocol tables are consistently created, by using ipair when generating arrays for completionItemKind and symbolItemKind. For CodeActionKind, the current implementation includes both the keys and the values in the array. This is incorrect. Ensure that only the values are included in the array and sort them for consistency.
eac8ea6
to
e8ae3ad
Compare
When I follow this I get: |
@TC72 make sure to |
@clason, for what it's worth, I didn't even need the last two lines to build successfully on my M1 mini. |
Is there any chance you could walk through exactly how you did it. I've tried everything and still can't get it to build. There's obviously something wrong with my setup if it's working for others. |
Same here @TC72 - even after |
There is a patch which fixes everything, I'm now able to build for a native version. Have a look at this thread: BUT, checking there now there may be a new issue. |
Patch for Apple Silicon backported from neovim/neovim#12624 Follow up to Homebrew#68787.
Patch for Apple Silicon backported from neovim/neovim#12624 Follow up to #68787. Closes #70053. Signed-off-by: Sean Molenaar <1484494+SMillerDev@users.noreply.github.com> Signed-off-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
It compiles and runs without crashes. However, to compile, I had to add
to
local.mk
and do