homebrew-arm icon indicating copy to clipboard operation
homebrew-arm copied to clipboard

Building from source

Open fauxpark opened this issue 2 years ago • 4 comments

I've been tinkering with building binutils, newlib and gcc from source, to match homebrew-avr. So far I've got 2/3 going, but before I continue I was wondering if there was any interest in me adding them to the repo. Would be handy for when GHA eventually adds M1 runners.

fauxpark avatar Jun 20 '22 00:06 fauxpark

Thanks @fauxpark for working on that!

I was trying to do the same, but it seemed way too complicated so I gave up. A few take aways:

  • I found this: https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/ -- they have all the platform including Apple ARM64
  • ARM's page for downloading is actually deprecated - https://developer.arm.com/downloads/-/gnu-rm - it has been moved to another website
  • and on the new website they provide GCC 11 - https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/downloads

With all that, it might not be necessary to invest in building from source. They only reason I wanted to do so in the first place was to be able to have newer GCC versions, but it seems that this is now covered.

I've also been using ARM GCC 10 on an Apple M1 for a few months now, and even if it's using Rosetta 2, it's already way faster than on a high end Intel Macbook Pro 16 machine.

With all that said, if you still wish to proceed, I'll be happy to review and merge. In this case, it would be nice to have both formulae separated: from ARM and build from source.

ladislas avatar Jun 23 '22 08:06 ladislas

It is a little complex, mainly because there is something of a circular dependency between newlib and GCC, as a result a "minimal" GCC must be built first in order to build newlib, then GCC. This part was not so much of a problem for me as I could draw on the Arch and MSYS2 build scripts. I've already had a little experience fixing up the ARM and AVR toolchains on MSYS2. In fact the hardest part for me was figuring out how to translate some of the bash-isms to Ruby 😄

Personally I think it's worth having formulae that can be built from source, for a few reasons:

  • It would mirror the AVR repo, in that it has discrete formulae for binutils, a selection of GCC versions, and avr-libc.
  • It allows finer control over the build if necessary; I couldn't find a complete build script for the precompiled ARM toolchain, only a .txt file containing the configure flags, which is helpful but not the whole story.
  • The bottle filesize should be a little smaller (I think). The toolchain from ARM appears to build and have its own versions of isl, mpfr, etc. A minor thing, but since Homebrew already has all of these as separate formulae, they won't need to be built as well.

fauxpark avatar Jun 24 '22 12:06 fauxpark

@fauxpark any news on that? :)

ladislas avatar Apr 18 '23 16:04 ladislas

Sorry, I ran into some issue building GCC 10 and haven't had the time (or, I suspect, the knowledge) to investigate. I can make a draft PR for others to poke at, if you'd like?

fauxpark avatar Apr 19 '23 11:04 fauxpark