-
-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
llvm@7: add support for Apple Silicon #65628
Conversation
This commit updates the llvm@7 formula to allow it to be built on Apple Silicon Macs. This package is needed to build ghc@8.8 on this platform. The change includes backporting several patches from llvm master which fix compilation and building on macOS with arm64. Signed-off-by: Nathan Hjelm <hjelmn@google.com>
patch do | ||
url "https://gist.githubusercontent.com/hjelmn/9fa1a7742acad71f404544a03bda414a/raw/b56a25f7208023d9724f671dfd7a80cbdac2a612/cfe-7.1.0-darwin-arm64.patch" | ||
sha256 "eb6be925cdab150f5d01d51fa6bd6a4fe1dbf481794b83976ff877524192d1c1" | ||
end |
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.
These are gonna need to be submitted upstream to be considered for inclusion in homebrew
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.
LLVM 7 isn't updated anymore upstream, this is basically a legacy package.
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 it's abandoned it should be deprecated and we still shouldn't use random patches that aren't submitted upstream
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.
These changes are all upstream. Just backported to llvm7 because it is no longer maintained. The only reason I request this is llvm7 is needed to build the ghc llvm backend. There is no native backend for ARM64 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.
I suppose the alternative is I make a keg, correct?
In Homebrew, the only thing that depends on
Can you explain this? None of our ghc formulas need LLVM to build, they all build fine with system compiler. |
Building ghc 8.8 (I need to try 8.10 but it likely has the same issue since there still is no native code generator) and it errors out with a newer llvm. Complains that the llvm is too new and says to use 7. From what I can tell this doesn't affect x86_64 because that uses a different backend. I can run some more attempts but the turn around is slow since ghc needs to be built twice. Once cross compiled and once native. I may just build a call with these until upstream ghc natively supports arm64. |
This will take a couple of days but I will try to build with the latest llvm in homebrew. I will report back if there is an error (I saw one before with llvm 11). I don't really care about llvm@7 except as a dependency to ghc@8.8. |
ghc 8.10.2 builds with llvm 11 (the formula in homebrew already works on Apple Silicon). ghc 8.10.2 requires patching to deal with issues with the aarch64 vs arm64 architecture naming but otherwise it seems to work fine. 8.8.4 mostly works but has some issues (after the same set of patches) with the linker code. these were fixed somewhere between 8.8.4 and 8.10.2. |
Does the stable version of llvm 11 work? With libomp? |
Released llvm 11.0.0 builds and works on ARM Big Sur. We carry a small patch for libomp in the formula. |
Both my ghc 8.8 and 8.10 formula changes fail because of the shim compiler adding linker flags when cross compiling:
I tried to bypass these wrappers by prepending /usr/bin to the path but they still get used. If there isn't a way to bypass the shim compilers then I will have to modify them to work when cross compiling in this way. |
I've seen standard overrides for the shims by replacing/setting environment variables, though I imagine you've already tried that... Also, |
Looks like With
Without:
|
Dropping llvm from the dependency list helps. Will see how far that gets since ghc 8.8.4 would always fail it it couldn't locate llc (it also complained about opt missing). 8.10 may be more forgiving if it isn't a full llvm install. If this works I will get the ghc.rb change up in a PR today. |
Looks like it will work with the system compiler. Forgot the |
🍺 /opt/homebrew/Cellar/ghc/8.10.2_2: 6,889 files, 1.9GB, built in 157 minutes 40 seconds
|
Great! |
Yeah. ghc 8.8 is not worth fixing at this time. |
This commit updates the llvm@7 formula to allow it to be built on Apple
Silicon Macs. This package is needed to build ghc@8.8 on this platform.
The change includes backporting several patches from llvm master which
fix compilation and building on macOS with arm64.
Signed-off-by: Nathan Hjelm hjelmn@google.com
brew install --build-from-source <formula>
, where<formula>
is the name of the formula you're submitting?brew test <formula>
, where<formula>
is the name of the formula you're submitting?brew audit --strict <formula>
(after doingbrew install <formula>
)?