[R-SIG-Mac] Which Fortran Compiler is usable

Simon Urbanek simon.urbanek at r-project.org
Wed Apr 28 23:39:26 CEST 2010


On Apr 28, 2010, at 4:26 PM, Yan Zhou wrote:

> I have a some sort silly question. Which fortran compiler is usable with R, e.g., building package from source.
> 
> I intended to install the gfortran from CRAN. But noticed that it will install cc1 and the text in installer stated that it is not recommended to install it with Xcode later than 3.2. I have 3.2.2 installed right now.
> 

Apple has not released Xcode 3.2.2 sources yet so we cannot build the corresponding version. What you can do (if you want) is to save the cc1 from Xcode and install the Fortran anyway.

That said, you don't have to. You can equally well use the separate Fortran from CRAN
http://cran.us.r-project.org/bin/macosx/tools/
if you want. (It's not how we build R anymore but it also works - at least with R 2.11.0)


> Besides I find on the website that gfortran from HPC will not work.
> 
> So my question is that, what is the problem with the HPC version of gfortran. What is the criteria for a fortran compiler to be usable with R.

It must support Apple driver's driver (for things like -arch ppc -arch i386 etc.) and have the corresponding cross-compilers included so you can build universal binaries. The HPC fortran is typically a single-host same-target compiler so it won't be able to do that (and has no Apple driver). In addition HPC compilers used to be a mess - they mostly didn't work at all due to library issues and cross-OS pollution, but I didn't test them lately, so may be things have improved in the meantime.


> I have intel fortran compiler installed. I managed to use it to compile a usable R-devel build from source. However, successful compiling doesn't imply that the generated code has no problem.
> 

If you build R from scratch from sources, there is no issue - you can use almost anything. What we are talking about is CRAN R binary - and by definition you can only use compilers that are compatible to the compilers used to compile that binary. That's what the recommended compilers are about. If you build your own R, you can use whatever flags you wish, so you can get different compilers to work -- but you won't be able to install package binaries from CRAN (in general).

I hope it helps.

Cheers,
Simon



More information about the R-SIG-Mac mailing list