mxcl/homebrew — Issue #10424: gfortran FCFLAGS issue when using clang
Author: RuiPereira
Created: 2012-02-23 13:21:54+00:00
State: open

When using `clang` as default compiler (Command Line Tools for Xcode) the `-march=native` flag is set into $FCFLAGS (since it is a copy of $CFLAGS). This breaks the homebrew installed gfortran:

```
$ /usr/local/bin/gfortran -c -Os -w -pipe -march-native -Qunused-arguments ../src/pgarro.f
f951: error: unrecognized command line option "-march-native"

$ gfortran --version
GNU Fortran (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
```

On the other hand, when using the gfortran gnu.org [binary](http://gcc.gnu.org/wiki/GFortranBinaries#MacOS) the problem is with the `-Qunused-arguments` also set only for `clang`:

```
$ /usr/local/bin/gfortran -c -Os -w -pipe -march=native -Qunused-arguments ../src/pgarro.f
gfortran: error: unrecognized option ‘-Qunused-arguments’

$ gfortran --version
GNU Fortran (GCC) 4.6.2 20111019 (prerelease)
```

The latter case can be stepped around by using `ENV.enable_warnings` before `ENV.fortran` though.