Closed sophiebits closed 14 years ago
Which is considered the standard fortran compiler? GCC vanilla I guess? Is there a Mac Fortran GCC port or build that people use in general?
Can we build just the fortran plugin for gcc and make the system gcc use it?
Is LLVM too new for fortran? As it is only for C stable as I understand currently.
Sorry to answer questions with questions :D
I'm not an expert on this by any means, but there's http://r.research.att.com/tools/, which looks like it uses Apple's patches to GCC.
I wonder how macports handles it.
I'll accept any approach to this, and we'll let open source sort out the best option in the long run. If we choose wrong I'll warrant someone will take sufficient offence to fix it ;)
I just added a formula for GCC that builds with c, c++, fortran support. I have it aliased to g++ and gfortran.
http://github.com/mxcl/homebrew/issuesearch?state=open&q=gcc#issue/374
I just slapped together a formula that pulls binaries from http://r.research.att.com/tools, the commit can be located at:
http://github.com/Sharpie/homebrew/commit/fb7badb
Features:
/usr/local/
which works well with the way homebrew
is set up.Issues:
.dmg
disk image. As far as I know, homebrew
does not cache these files. Unpacking and extracting the source takes some monkey business.Ruby
in general and homebrew
in particular are limited, this exacerbates the "monkey business" mentioned above. If anyone is intrigued by this formula and spots a way to clean up or compact the install commands, let me know!gfortran
.I have used this binary distribution for quite a while and have found no major issues with it- I hope it can be of use to the community.
There are binary gcc and gfortran packages available for mac here: http://hpc.sourceforge.net/index.php
I think there may be some issues with the HPC gfortran binaries. To quote http://r.research.att.com/tools :
For convenience we provide a binary of the GNU Fortran compiler, because most other binaries are either incomplete or broken (do not use compilers from HPC, they won't work correctly!)
I like Sharpie's solution here. I'm massively against anything which introduces a new "gcc" binary. However, reading that web page, I think it should be possible to reproduce the build method they've used. I've sent a message to their mailing list asking for reproduction instructions so I'll update this bug when I hear back.
Just to throw it out there, I just finished working on a gcc 4.5.0 release formula about an hour ago. I have not tested it with fortran yet, but there is no reason why it shouldn't work. I have only compiled c, c++ so far, and like I said have not tested it yet, but feel free to take a look if you would like. I actually set it up to have an alias for gfortran, and then if invoked with that alias fortran would be automatically added to the list of installed compilers. Obviously binaries have the advantage in the speed of being able to use it, but I just posted about gcc in another issue, so I thought I would throw it in here as well. Also, I plan on trying to get it to work with gccs' trunk as well, for what that is worth
Jon
mulderje/homebrew@57c0f5588c8a0f64addf32380288daf1eb74d9cd
At this point it seems like we may have two viable options emerging:
gfortran-4.2.3
using some of Apple's gcc patches from the R project.My arguments for adopting this version are:
core2
as an argument to -mtune
is not present.Providing a version of gcc
that is newer than the one provided by Apple is a worthy and important endeavor- especially concerning the gfortran
compiler. This is due to significant progress that has been made on implementing the Fortran 2003 and 2008 standards since the release of gcc 4.2. Newer compilers provide support for features such as:
See the changelog at http://gcc.gnu.org/wiki/GFortran#news for a more complete listing of the progress that has occurred.
My own opinion is currently that the 4.2.3 version of gfortran fits closely with the Homebrew project's philosophy of "providing the tools that apple forgot" as it is from the same major release as other Apple supplied gcc components and incorporates some of their patches.
However, newer versions of the compiler are critically important to people who want to finally explore some of the new Fortran language features we all got excited about 7 years ago. I would propose the following:
gfortran
- this version would be the default used to build other programs and libraries that specified gfortran
as a dependency.gfortran-4.5
, that would be produced from the current release of gcc. This version would support those of us who want to use newer language features and we could easily make the choice individually to rename it to gfortran
if we wanted it as the default compiler for our own personal build system.I'm really impressed with the debate on this topic so far- there have been a lot of good ideas presented!
I think it's a lot more likely that gfortran 4.2.3 will get accept. Newer GCCs might get put into a duplicates branch but I think it would be a very bad idea to include it in mainstream.
The already patched sources (for the Xcode build) are in:
10.5: http://r.research.att.com/src/gcc/gcc_42-5577-with-gfortran-4.2.4.tar.xz
10.6: http://r.research.att.com/src/gcc/gcc_42-5646-with-gfortran-4.2.4.tar.xz
Apple doesn't use configure/make - they use their own build system so the builds goes like this:
mkdir -p build/obj build/dst build/sym
gnumake install RC_OS=macos RC_ARCHS='x86_64 i386 ppc' TARGETS='x86_64 i386 ppc' \
SRCROOT=pwd
OBJROOT=pwd
/build/obj \
DSTROOT=pwd
/build/dst SYMROOT=pwd
/build/sym
The result is in build/dst
One tricky part is that it creates entire Xcode chain so ideally you need to have the same Xcode version installed so you can just add the Fortran. But sources are not always available (e.g. Xcode 3.2.2 has just been released but there are no sources yet). Unfortunately the Fortran needs cc1 augmented with the understanding of some Fortran-specific flags, so we have to replace Apple's cc1 which is why there is that restriction of the Xcode version (in practice it should play no role, but some people are paranoid ;)).
I just changed the alias in my version of gcc to read gfortran-4.5, just in case it gets adopted into mainline as per sharpie's suggestion.
mulderje/homebrew@04c9d417f954d04a270977c852bd1f00c44595ec
Jon
Oh man, I just spent a few days coming up with a gfortran formula and then saw this. My working formula is here:
http://github.com/kmowery/homebrew/commit/c9dd90fdadff88984369121d5e9979c99d8ec6c8
It works well enough to install scipy, which is all I wanted. It builds from vanilla gcc 4.2.1, but doesn't pollute /usr/local/bin with other gcc binaries.
Fortran still is not avaialble in Homebrew. Will this formula be included any time soon?
I have been working on a new gfortran brew that I am planning to propose as a solution to this issue in the next couple of days once I finish running it through some stress tests on OS X 10.5 and OS X 10.6.
Stay tuned!
Update- "a couple of days later"
Well, they say the last 10% of the work takes the other 90% of the time. I almost have a new brew ready based on the gfortran 4.2.4
binaries available at r.research.att. However, there have been some snags supporting OS X 10.5 as it appears that the 4.2.4 binaries are loosely pegged to XCode versions and therefore are not backwards compatible across major OS X releases.
I am working on increasing the flexibility of the brew to deal with this situation and hope to have it done in time for the holidays.
I just finished rolling up and testing a new formula that installs binaries for gfortran
version 4.2.4 sourced from:
http://r.research.att.com/tools/
The commit can be obtained at:
Sharpie/homebrew@7ad7fa30e071a5717f20b20ff97ca7286c8c5908
These binaries were compiled by Simon Urbanek to support the R Language for Statistical Computing on OS X. They are also recommended by the SciPy community for use in compiling the Numpy and SciPy scientific computing modules. The binaries have been built from Apple XCode GCC sources and include Apple patches. I have put the compiler through a series of test builds on the following platforms:
The test suite is packaged as an external brew command, brew test-fortran
, and can be obtained from the following commit:
Sharpie/homebrew@84b3db13ca3048414db6fa4022c64b726e3f24b5
For more details concerning the compiler and the test suite, see the log entry for each commit.
I am recommending these binaries as a solution to providing support in Homebrew for Fortran-based brews. Briefly, the main points supporting my recommendation are:
llvm-gfortran
.CFLAGS
set by Homebrew. This facilitates setting environment variables for Fortran-based brews.Since officially providing Fortran support would be an experimental effort at this point, the brew includes the following caveats:
Fortran compiler support in brews is currently experimental. One of the consequences of this is that Homebrew does not set environment flags to ensure that a particular Fortran compiler is used and that the resulting code is optimized properly. Therefore, in addition to using:
depends_on "gfortran"
Fortran-based brews should also specify environment variables for the Fortran compiler in the install section:
# Select the Fortran compiler to be used: ENV["FC"] = ENV["F77"] "#{HOMEBREW_PREFIX}/bin/gfortran" # Set Fortran optimization flags: ENV["FFLAGS"] = ENV["FCFLAGS"] = ENV["CFLAGS"]
Following these guidelines will allow Fortran-based brews to be easily edited so that alternate Fortran compilers, such as ifort, can be used instead of the version of gfortran provided by Homebrew.
The idea behind these caveats is emphasize the experimental nature of Fortran support by not requiring changes to core Homebrew files such as extend/ENV.rb
. By following these caveats when brewing, the community will be able to create brews that install software that depends on the presence and configuration of a Fortran compiler. Additionally, the user will be free to substitute another Fortran compiler by modifying at most 3 lines in the brew file.
Any comments or questions are greatly appreciated!
Sorry for the quick follow-up post, but I had a typo in the commit address for the gfortran
brew. It can be found at:
Sharpie/homebrew@7ad7fa30e071a5717f20b20ff97ca7286c8c5908
Thanks for the great work Sharpie!
I think, longer-term, it would be great if we can copy his build process so we can actually build the binaries ourselves.
I'm merging this into the "brew07" branch: http://github.com/adamv/homebrew/commits/brew07
Merged into master! Thanks for everyone's work and patience here.
We'll see if this is a maintenance burden or not; I suppose it will have to be updated for new point-releases of Xcode?
Thanks for the merge!
There could be a maintenance issue with there being some lag time between when Apple releases a new version of Xcode, releases the sources for that new version and then a new gfortran package is created. However, the older version of gfortran may continue to work- the 3.2 binaries were able to pass my test suite on a machine that had 3.2.2 installed.
I think the changes from OS X 10.5 -> 10.6 broke backward compatibility because there were changes to the Mach-O binary format during that time. The upcoming release of Xcode 4 could present a problem- but I think the probability is low as LLVM seems to be the star of that release. I doubt Apple is planning any earth-shattering changes to the gcc tool chain.
I am using XCode 3.2.3 and I am unable to compile this. Also, even when I do unrelated tasks, I keep getting this error: Error: Currently the gfortran compiler provided by this brew is only supported for XCode 3.1.4 on OS X 10.5.x and XCode 3.2.2 on OS X 10.6.x
You can probably add the gcc build number to the case statement for 3.2.3 and have it work...
I have this version $ gcc --version i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664) Copyright (C) 2007 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
but http://r.research.att.com/gfortran-42-5664.pkg isn't available.
5664 looks like it may be 3.2.3 which is the iPhone dev pre-release. This version is not publicly available- so I could not download it and run tests to make sure the Fortran binaries work correctly as they were compiled against Xcode 3.2.2 (build 5659).
However, in my testing I noticed that the Fortran binaries are only loosely tied to Xcode versions- so you can edit the Xcode version number on the case statements as Adam suggested and things will probably work out fine.
If anyone has Xcode 5664 and is interested in running the 5659 Fortran binaries through the test suite in 32 and 64 bit mode, we could see if they pass.
You can now install in Xcode 3.2.3 using "brew install --force gfortran" It uses the 3.2.2 support, so is experimental/unsupported, but R compiled fine for me when I did this.
Please open new Issues for new gfortran problems.
Thanks!
A bunch of projects depend on the existence of a Fortran compiler, but Mac OS X doesn't come with one. How should we handle it? compile plain GCC? compile Apple's GCC? use LLVM's Fortran compiler (http://llvm.org/docs/GCCFEBuildInstrs.html#fortran)?