-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Backport macOS ARM to 4.10 #10026
Backport macOS ARM to 4.10 #10026
Conversation
Many thanks Eduardo! I'm just updating my DTK to the release of Big Sur at the moment, so I'll take a look at the state of Homebrew then. My intention is to point to this branch until some of the 4.12-specific tools are fixed up in ocaml/opam-repository#17530 (at which point we can just publish the 4.12beta into Homebrew ARM as the recommended version to use) |
Naive question: if the 4.11 backport is easier (and, I suppose, less bug-prone), why not use the 4.11 backport in homebrew instead of this 4.10 backport? |
Just to minimise changes with the x86 version, which is current upstream at 4.10.0. https://github.com/Homebrew/homebrew-core/blob/master/Formula/ocaml.rb#L16 |
Good thing they are not stuck at 4.04.2 like some other package collection that ends in "win" :-) I'm running this PR through CI precheck at Inria so that it gets tested on ARM64/Linux. |
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.
After a quick look, I think the diffs in asmcomp/ are fine, and those in asmrun/arm64.S are probably OK, but we need to test. "Precheck" CI on ARM64/Linux is positive, so all we need now is testing on ARM64/macOS.
Provide a more precise description of the types of unboxed arguments, | ||
so that the ARM64 iOS/macOS calling conventions can be honored. | ||
(Xavier Leroy, review by Mark Shinwell and Github user @EduardoRFS) | ||
|
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.
If you wish to keep the Changes log accurate, you should mention the (backport of the) original ARM64/macOS pull request.
Well, the fan has exploded in my DTK (wasn't that 400 quid well spent!), so we have to wait for an M1 delivery. The first Mac Mini arriving that should be suitable for Inria Jenkins CI should be @MagnusS' on the 25th Sept, and mine is arriving on the 1st Dec. Anyone else got access to one sooner? |
Just
|
Many thanks for checking this @claui! Does |
Without this patch applied, |
Perfect, that's a relief -- our forthcoming release will work correctly. This backport PR has only run on arm64/Linux as we don't have an M1 or DTK in CI at the moment. Since @EduardoRFS doesn't have access to one either, I wonder if we should just forge ahead and put 4.12.0beta1 into Homebrew. What we really need is a working opam when compiled with 4.12.0alpha2+ -- what's the status of that @dra27 @Octachron @kit-ty-kate? ocaml/opam-repository#17530 indicates that opam doesn't build currently on the 4.12 snaps. |
In case you decide to backport to 4.11.1 as suggested by @gasche and others: |
I will try building this again on iOS, I don't have a Mac ARM but this patch was developed for iOS so that should be enough as a preliminar result |
opam itself does build, it just needs a release of extlib. However homebrew uses the vendored libraries way of building opam so ygrek/ocaml-extlib#55 (or better, the next release, cc @ygrek) needs to be vendored (cc @rjbou) As for the rest of the ecosystem the main issue is dune (see ocaml/dune#3793 / ocaml/dune#3904). Most of the packages build fine with opam-alpha-repository but many "core packages" have to be released/fixed (dune, base, core, lwt, utop, ppx_deriving, js_of_ocaml, extlib, coq, …). See full list here: https://github.com/kit-ty-kate/opam-alpha-repository/tree/master/packages |
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.
Based on the Brew compilation log: some of the OS isolation macros are not properly used in runtime/arm64.S. I marked some occurrences below. There is also 4 occurrences of b .Lcaml_call_gc
that need to be macro-ized.
The error message posted by @claui is pretty informative, actually. It should be easy to fix runtime/arm64.S to get rid of those errors. No need to rush an upgrade to 4.12. |
I also replicated the errors from @claui on the iPhone and I remember needing to fix those the last time I did this backport |
eecf8fe
to
ba11dab
Compare
Did some adjustments, and got this to build and tested on iPhone and I'm currently testing on a raspberry pi4. Changes @claui could you try it again? |
@EduardoRFS Had to modify the patch file to remove the |
Excellent news! Now we're in business! Thanks to all the participants to this discussion for being so reactive. |
Uploaded a snapshot to Homebrew/formula-patches#318 so we can prepare the 4.10 formula PR on Homebrew’s side. |
Taken from ocaml/ocaml#10026 after confirming that after applying @EduardoRFS’s patch, `brew install -s ocaml` builds and runs fine, and passes `brew test`.
All green on Linux ARM64 |
I have one which you can borrow, if you want to pick it up, if you're in Cambridge at the moment. Email for the address... |
@xavierleroy anything preventing us from mergin this? Especially now that is already being used by homebrew |
Actually I don't know what we are going to do here. We could merge in the 4.10 development branch, even though there will probably be no new 4.10 releases. But it's a big amount of code. And then it would make equal sense to backport to 4.11 and merge there, because there might be a new 4.11 release. But it is again a big amount of code. I'll let our release manager @Octachron decide. |
Based on the backport at ocaml/ocaml#10026 but with a 4.10.1 version so that it is a dropin replacement in opam-repo
Based on the backport at ocaml/ocaml#10026 but with a 4.10.1 version so that it is a dropin replacement in opam-repo
I was able to build this with the 4.10 branch on an Apple M1 mini and xcode 12.2. One test failed with the error below, but looks like this test is skipped on 4.12 (482b7fe + 8b6241c):
With homebrew @claui I was unable to use the patch from Homebrew/formula-patches#318 as I get |
@xavierleroy , if we want to distribute the patch widely on a tier-1 platform, I think it might make sense to have an exceptional 4.10.2 release, with an understanding that any ulterior bug fixes would happen on 4.12. Otherwise, we could merge to the dev version of 4.10, but then packagers would need to patch the VERSION file to get usable sources. The other solution would be to merge the change in a specialized branch. But this create a new kind of release branches with a quite conditional existence. From an exterior point of view, an exceptional "new-tier-1-platform-initial-support" version seems simpler than an exceptional source of distribution. |
@Octachron : it's your choice. Personally, I'd be happy with a patched 4.10 in homebrew and perhaps macports, everyone else using 4.12 alpha/beta/final, and this PR not merged. If you choose to merge this in 4.10, watch out for config.guess and config.sub updates that may be missing from this PR. |
The opam-repository PR is basically ready to go in that case (aside from a bit of fiddling with the package name). The only reason I'm not merging it immediately is that the branch is sitting in avsm/ocaml and is a bit unofficial-looking. I do wonder if we're underestimating the amount of time it'll take (e.g.) Coq to move to 4.12 instead of 4.10 though. If @Octachron doesn't mind cutting a 4.10.2 release, I'd prefer that rather than an ad-hoc branch in opam-repository. |
I also discussed in the past on having a patched version for esy + mac arm. But it would be a lot easier if we have this merged. The config script here is already ready, but maybe a proper |
Let's go with an official exceptional release for a new tier 1 architecture then ; the maintenance cost seems quite balanced with the frequency of such events. The changes files will need to be updated indeed. |
ba11dab
to
d6a77c1
Compare
Removed the changelog from this PR, @Octachron will do the changelog for us |
Ok, I'll adjust the opam-repo PR to anticipate a 4.10.2 then. |
To version 2020-07-12 from git://git.savannah.gnu.org/config.git This adds support for iOS/macOS AArch64.
Revised handing of calling conventions for external C functions
Add support for iOS and macOS on ARM64
8a3ea2e
to
270a7df
Compare
@xavierleroy This is ready for a review / merge. Changes was fixed by @Octachron |
I don't know how to dismiss a "Changes required" review other than doing another review. I'm very sure the required changes have been made, since the patched code is working in Homebrew and in OPAM. I'm not going to do another review of the +2422/-1820 commit 7b9612f. Squashing commits is great to have a nice history but prevents incremental reviewing. @Octachron is welcome to merge in 4.10 on the basis that this PR is very probably equivalent to the patched code that is already working in Homebrew and OPAM. |
Ok, I will take care of the merge and release on Monday. |
Just in case you didn't know, the github interface allows you to see the changes by clicking on the In this particular case, here is the diff it gives you: https://github.com/ocaml/ocaml/compare/8a3ea2e144ca0eee5eb95597c8c80faaaf856e09..270a7dfe467ed43911f4a58f5ff3e5f155389956 |
No, I did not know, and it looks very useful, so thanks @kit-ty-kate for pointing it out. However, the link you give shows completely unrelated changes (@dra27 's fixes for mingw-64 issues), so I'm not reassured yet :-( |
To be very clear: I'm expecting to see changes in runtime/arm64.S and in Changes, in response to the review comments, and no other changes. |
Indeed, the diff also shows you the upstreamed changes as I'm guessing the last force-push was made to be totally up-to-date with the However if you scroll just a bit above, 2 other force-push were made 4 and 16 days ago and they contain the changes you're looking for: |
@kit-ty-kate thank you, I also didn't knew it. The last commit is just to fix the |
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.
Concerning the latest commit d1b0dab : this is not the house indentation style, and it diverges from the same code in the trunk
Lines 170 to 179 in 0f7d0a6
let loc_parameters arg = | |
let (loc, _) = | |
calling_conventions 0 last_int_register 100 115 incoming arg | |
in | |
loc | |
let loc_results res = | |
let (loc, _) = | |
calling_conventions 0 last_int_register 100 115 not_supported res | |
in | |
loc |
d1b0dab
to
acdb5c6
Compare
@xavierleroy thank you, fixed it and rewrote the commit, there is any indentation guideline for OCaml? |
This was requested by @avsm to publish ocaml to homebrew for a month or so. 4.11 is an easier backport, almost literally just cherry-picking the commits.
#9699
Conflicts
The
memprof.c
change was removed as it's not needed for 4.10, because it was introduced on 4.11 IIRC.For
arm64.s
, all the conflicts were related to 7fe3604, so maybe cherry-picking it is desirable, but I did fix the conflicts, needs testingiOS
The changes required for iOS was also cherry-picked, as they're quite minor and less than 10 lines of code:
system()
detection on configureHAS_SYSTEM
guard atsys.c
signals_osdep.h
#9752
Conflicts
Changes
was added to the top of the file.printcmm
who had a small conflict because the change onDebuginfo.to_string
tolocation
Testing
I don't have access to a macOS ARM anymore, to test this changes specifically, but as they're in the wild it shouldn't be hard to find a box to run the tests.