-
Notifications
You must be signed in to change notification settings - Fork 181
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 ARM mac #303
Comments
I'm about 30 years out of date on ARM assembly 😂 The last time I worked with it was on Acorn. But I'd be happy to contribute towards an Apple Transition Developer Kit! |
@rudedogg Yes. |
Is this still a problem? A friend of mine with one of the developer preview Mac mini's was able to run make and it compiled successfully. However he didn't code sign Xcode so he can't confirm fully if XVim2 runs or not. |
Yes, this still appears to be an issue. I was able to build XVim2 successfully for Xcode 12.2, but Xcode does not seem to like installing/running Xcode plugins compiled for x86-64 only (using Rosetta2), as XVim2 currently excludes arm64. Initial attempt to build for arm64 failed -- will have to dig into it further. (This was done on a MacBook Pro 13 w/ Apple M1 on Big Sur 11.0.1) |
Is there anyway I can help (maybe by trying to cross-compile)? I have an Intel based MBP running 10.15.7 Catalina. |
Well, the issue seems to be well understood, as identified above -- replacing the x86 asm in SourceEditorViewWrapper.s. In the short term, Xcode can be forced to be opened using Rosetta2, and I can confirm XVim2 functions when using Rosetta2. |
Yeah, I saw the x86 assembly. But I was wondering maybe there is/are other problems in addition to that. That's good news in terms of a (temporary) workaround. That's enough for me to order an M1 machine. |
@jspavlick What's the workaround to use XVim2 on ARM mac? Thanks. |
@rookiezn I don't know. I don't have my M1 mac yet. As jrsharp eluded to, if you force Xcode to run using Rosetta2 (it's a universal binary, right? So it will run the x86 version through emulation) then it will work, but presumably everything (compiling etc) will be slower? |
There is a workaround. You can run Xcode using rosetta. Xcode is an universal application.
It's unfortunately that the performance of Xcode is worse using Rosetta, especially building a big project. |
hmm, its assemby code is for call swift only interface (have not @objc attribute) instance method that implemented in xcode from xvim(objc), right? |
It's possible to convert Intel assembly to Objective-C/C using decompiler. https://www.hopperapp.com/ |
I found one more related issue dependent intel arch. XVim2 project imported NOTE: yes, using function Refs: |
I do this five steps and run XCode ,see Edit->Xvim2 -> about:
but , xvim2 not work in code editer . |
I have tested it on Xcode 12.2, it works. Because Xcode 12.3 isn't usable on my Mac, I haven't tested it on Xcode 12.3. |
Do you add Xcode 12.3 UUID? |
YES,i set UUID by this command:
Now , when the mouse is focused on the editor, Xcode cannot respond for a long time. |
Hello! So, my understanding from reading through this issue is that in order for XVim to work natively on M1, this assembly code needs to be removed/changed to work on ARM somehow, and If so, I have a few questions; for starters, what does that x86 assembly do exactly/why is it used? Could it be replaced by Objective-C or C code? Also, a quick glance over I'm happy to help with this where I can, even if that just means testing out a PR or PRs on my machine to verify it works on M1. Also, I can confirm that running Xcode under Rosetta does allow XVim to work, but I suspect running Xcode under Rosetta is something many M1 users (myself included) would rather avoid, considering the advantages to running Xcode natively on the M1. |
@smolck I believe your assessment is correct. I do not know what the x86 assembly is doing. I am by no means an assembly expert. However, @r-plus is seeming to indicate that the assembly code is doing the same thing as rd_route, or somehow calling it? That doesn't seem to be the case to me, but I am no expert. XVim2 is only using I predict that converting the x86 assembly to ARM will be easier than porting the functionality of My M1 Mac is on the way, and when it gets here I'll be happy to play with In the meanwhile, I have posted a $500 bug bounty on this for anyone who is more competent than I am. |
Just looking at that first file, this is where XVim2/XVim2/Xcode/SourceEditorViewWrapper.swift Lines 102 to 106 in b723d4e
Those seem to just be pointers to Objective-C functions, right? For example, As for (b), I imagine that might be the easier way of doing this, unless there's a serious reason why Again, though, I'm not familiar with this codebase (and hardly know anything about Swift/Objective-C), so I might be wrong here. (And even if I'm not and those are valid solutions, I don't think I currently have the understanding/knowledge necessary to implement the fix.) |
Sorry for confusion. Both parts (assembly code and rd_route) are necessary for invoke Swift method implemented in Xcode.app by Apple.
NOTE: Usually, pure Swift function (not have objc interface and not public level access control) have not dynamic callable system out side of original module (in this case, Xcode). |
Yeah, after studying the code a little more, I think @r-plus is completely correct. Let me explain what I think is going on @smolck.
The workaround (which seems to be quite brilliant) is to get a function pointer that points to the function/method in question (I guess it's sitting in a v-table somewhere?) and then "manually" invoke the function as a method, by remembering to pass |
@smolck could you please save this file as |
@jspavlick
Need rewrite the whole procedure by ARM, de-compile some swift arm binaries should helping known how swift call a symbol in ARM. |
And I think that's totally doable. But what do you think the chances are we get function_ptr_from_name also working on ARM? |
@jspavlick yes, completely correct. I’m thinking fishhook https://github.com/facebook/fishhook implementation is maybe helpful for getting function pointer on ARM. (looks like not have function like rd_route, so need work to fit for XVim) |
That's the problem I'm having right now; for some reason there appears to be very little documentation on x64 assembly vs arm assembly, and it's quite frustrating. However, I did find this write up which seems pretty useful: https://developer.apple.com/documentation/xcode/writing_armv6_code_for_ios At the bottom of that there's a section regarding the prolog/epilog of a function, and some code as an example. My understanding from looking over the code there/reading a bit (I think I'll properly read through the whole thing later) is that the equivalent to push {r4-r7, lr} // Save Lr, R7, R4-R6.
mov r6, r11 // Move high registers to low registers, so
mov r5, r10 // they can be saved. (Skip this part if
mov r4, r8 // the routine doesn’t use R8, R10, or R11.)
push {r4-r6) // Save R8, R10, R11 (now in R4-R6).
add r7, sp, #24 // Adjust R7 to point to saved R7.
sub sp, #36 // Allocate space for local storage. If nothing else, it seems like a useful example of arm assembly. |
I've been learning x64 assembly for the last few days before learning arm64 assembly. made this pull request for adding many comment and refactoring. #352 |
Hey guys! This is the branch to building universal binary. (Thank you @JugglerShu for commit permission) Let me know to this issue if you have the problem in arm, but not problem in intel. known issues for arm
|
OMG! |
ah, first known issue I wrote is only for Debug build. |
Are these issues present on Intel? I can't seem to find how to run these tests in Edit. |
not yet checked about it. tests are here. |
Am I crazy? I'm on master b723d4e |
Oh, its menu will show only in debug mode. debug mode will add file logging AFAIK.
https://github.com/XVimProject/XVim2/blob/master/Documents/Contributing.md#debug-with-log |
In my intel mac (MBP Late 2016), same three failure result I previously pasted. |
Why does mine fail so badly? Maybe we can ignore it? |
@jspavlick Is there anything other than For me, I ran the tests on the latest from the Running it under Rosetta appeared to give the same thing. Just from a quick test moving around the editor, it works well! Great work @r-plus! |
Test result will be changed by Xcode preference.
After disabled it, only one failing case, same as @smolck's. |
looks like last failing test case initial text is Actually, |
fixed blank text initializing for unit test and test case expected result for fitting Xcode 12. a8a3e88 |
after emptying my .xvimrc and switching to feature/support_arm a8a3e88 I still get this. Maybe we should just ignore my sad machine and test results 😅 |
@jspavlick This unit test expected Xcode default preference. |
Good thinking, @r-plus ! After changing my indentation from |
I got my M1 Mac Mini (finally) and have set it up. Wow, this thing is amazing. Product > Archive is 3.7x faster than my Mid 2014 MBP, and I simply cannot get this thing to make fan noise. It's dead silent. I got XVim2 installed and working. All 463 tests pass. And Xvim seems to work perfectly from what I can tell. Very good job @r-plus ! I did get one crash while running the tests, but I can't replicate it. Probably not a big deal. I am also experiencing this issue: #340 |
@r-plus, thank you for tackling this! 🦾 |
@r-plus when are we merging this into master? Go claim your bounty! |
@jspavlick I'm wondering if it's okay to self-merging pull request. (I’m new face of committer for this repo) |
@r-plus |
okey, thanks! I'll merge it. |
I just merge it to develop and master branches. |
XVim2 has Intel assemby code.
The text was updated successfully, but these errors were encountered: