Homebrew / legacy-homebrew

💀 The former home of Homebrew/homebrew (deprecated)
https://brew.sh
26.97k stars 11.34k forks source link

ARM toolchain #5673

Closed teamon closed 13 years ago

teamon commented 13 years ago

Many osx users (including myself) are missing easy way to install arm-gcc + tools. I just found an article describing how to install everything from source: http://www.jroller.com/maded/entry/toolchain_for_arm_on_osx

I think the biggest problem is that it requires compiling gcc (and duplicates are not welcome here, but it could be custom gcc with everything prefixed "arm-") As I checked available formulae, every required libraries (besides newlib) are already available but are built without required configure options.

I've already created newlib formula and started creating formulae with "arm-" prefix (like arm-binutils, arm-gmp etc) but I notices several problems. First, it probably isn't the best idea to kind of duplicate all those formulae just to add few configure options. Next, I have no idea what to do with options like "--with-gmp=$prefix" or "--with-mpfr=$prefix" (I'm not a hacker in compiling stuff).

Other solution that I came up with is to create only one "arm-gcc" formula that would install everything as bundled package (those libraries are used only by arm-gcc so there is no need to access them from "outside").

I just want to know if anyone is interested in helping with that.

(Even if the whole idea is too crazy for official brew repository having such packages in one of alternative repositories would be really great)

Related issues: https://github.com/mxcl/homebrew/issues/4445 https://github.com/mxcl/homebrew/pull/3851 https://github.com/mxcl/homebrew/issues/1553

jacknagel commented 13 years ago

Have you seen the formulas for gcc 4.5.x and 4.6 in http://github.com/adamv/homebrew-alt? They might serve as a template for an arm-gcc formula (and show how to use --with-gmp, etc. with Homebrew).

Perhaps there could be an ARM-specific directory in homebrew-alt, or someone else could maintain a separate repo and link it from the "Interesting Branches" page on the wiki.

jacknagel commented 13 years ago

Also, I'd be willing to help with anything related to this.

teamon commented 13 years ago

Nice to hear that :)

I stopped at "--with-headers=../../newlib-1.16.0/newlib/libc/include" configure option for gcc. Do you know how to make that?

teamon commented 13 years ago

I did some hacking and created few arm-related packages. They are available at https://github.com/synergia/homebrew .

New formulae: arm-binutils, arm-gmp, arm-libmpc, arm-mpfr, arm-gcc, newlib

There is problem installing gcc, the order must be like this: (gcc) make all-gcc install-gcc // install gcc only (newlib) make all install // install newlib (gcc) make all install // install the rest from gcc package

@jacknagel - could you take a look at it?

jacknagel commented 13 years ago

Will do.

Edit: I'll hack on this later on this evening if I get the chance.

jacknagel commented 13 years ago

So the main hurdle is that we have to build a temporary gcc to bootstrap newlib, and then when newlib is built, finish building gcc (right?).

It's possible to build intermediate formulas during the build process of another formula, e.g. Newlib.new.brew, so we'd have to be able to unpack the newlib tarball and determine the correct path to the header files for --with-headers first, then build gcc, then newlib, and then gcc again.

This is interesting.

Anyway, I haven't done anything other than glance at the formulas, but this should be doable, somehow.

teamon commented 13 years ago

Following instructions on http://www.jroller.com/maded/entry/toolchain_for_arm_on_osx that is the way. Without gcc newlib will not build as it requires arm-elf-cc.

jacknagel commented 13 years ago

So I'm not sure if it's possible to determine the location of files for an extracted "subformula" tarball using conventional Homebrew methods, but if push comes to shove we could just do something like

system "curl (newlib URL)" system "tar xf (newlib tarball)"

and then we can use Pathname.getwd, etc to get the location of the header files and just use that temporary set of header files to build gcc, then do the normal Newlib.new.brew to build newlib and then finish gcc. It isn't ideal, because we'd be downloading newlib twice, but it's not too bad.

teamon commented 13 years ago

I figured out how to fetch newlib

newlib = Formula.factory 'newlib'
dwnldr = newlib.downloader
dwnldr.fetch # fetch (uses cache!)
dwnldr.stage # unpack

But I'm stucked here, some weird error during gcc compilation...

jacknagel commented 13 years ago

Sorry, got busy the last couple of days. Want to gist the error/install output?

jacknagel commented 13 years ago

I'm still willing to help with this in any way that I can be useful, but at this point I don't think it's really a Homebrew "issue" so much as a project, and discussion could probably take place elsewhere: either on another repo or via email.

jacknagel commented 13 years ago

Closing; feel free to link to an alternate repo with this stuff on the wiki, though.