gfortran FCFLAGS issue when using clang #10424

Closed
RuiPereira opened this Issue Feb 23, 2012 · 6 comments

Comments

Projects
None yet
3 participants
Contributor

RuiPereira commented Feb 23, 2012

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 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.

Contributor

Sharpie commented Feb 23, 2012

Thanks for the report, I figured something was going sideways with GFortran and Clang. I'll take a look at changing the default FCFLAGS so they are not a copy of CFLAGS.

Contributor

Sharpie commented Feb 29, 2012

This one is getting tricky as it is critical to copy from CFLAGS because other environmental modifiers, such as ENV.m32 or ENV.03 will get carried over.

The major problem here is the archflags---Homebrew currently has a convoluted and messy way of setting these that makes it difficult to re-set them for a different compiler.

Contributor

2bits commented Mar 2, 2012

Thanks. I forgot to search, and fixing it did not look easy. I suppose you could awk a few things out of the clang flags that looked useful: optimization, any arch flags. Don't run the code again, just make safe choices so it works. Maybe when there is a system call, check if ENV.fortran and clang, then set FCFLAGS as needed. That way the check would be the last thing done before any configure or make etc.

Sharpie was assigned Mar 8, 2012

Contributor

Sharpie commented Mar 8, 2012

Proposed fix in #10774. Please evaluate.

Contributor

RuiPereira commented Mar 8, 2012

The fix works great, thanks! Just a question, is there any difference between FCFLAGS and FFLAGS?

Contributor

Sharpie commented Mar 8, 2012

FFLAGS was used by old Fortran 77 compilers such as g77 and possibly by modern compilers when processing old code. FCFLAGS is the modern variable---I set them both to cover all bases.

@Sharpie Sharpie added a commit to Sharpie/homebrew that referenced this issue Mar 9, 2012

@Sharpie Sharpie ENV.rb: Set GCC-style CPU flags for GFortran
GFortran chokes when it is passed CPU flags specific to Clang. This change
ensures the environment variables `FCFLAGS` and `FFLAGS` contain the same CPU
flags that would be set for the GCC compiler.

Fixes #10424.
a782e95

Sharpie closed this in 0f467bb Mar 9, 2012

@etehtsea etehtsea added a commit to etehtsea/homebrew that referenced this issue Mar 10, 2012

@Sharpie @etehtsea Sharpie + etehtsea ENV.rb: Set GCC-style CPU flags for GFortran
GFortran chokes when it is passed CPU flags specific to Clang. This change
ensures the environment variables `FCFLAGS` and `FFLAGS` contain the same CPU
flags that would be set for the GCC compiler.

Fixes #10424.
Fixes #10744.

Closes #10774.

Signed-off-by: Charlie Sharpsteen <source@sharpsteen.net>
e4c4ee3

@Sharpie Sharpie added a commit to Sharpie/homebrew that referenced this issue Jun 18, 2012

@Sharpie Sharpie ENV.rb: Set GCC-style CPU flags for GFortran
GFortran chokes when it is passed CPU flags specific to Clang. This change
ensures the environment variables `FCFLAGS` and `FFLAGS` contain the same CPU
flags that would be set for the GCC compiler.

Fixes #10424.
Fixes #10744.

Closes #10774.

Signed-off-by: Charlie Sharpsteen <source@sharpsteen.net>
7b95cb5

@snakeyroc3 snakeyroc3 pushed a commit to snakeyroc3/homebrew that referenced this issue Dec 17, 2012

@Sharpie Sharpie ENV.rb: Set GCC-style CPU flags for GFortran
GFortran chokes when it is passed CPU flags specific to Clang. This change
ensures the environment variables `FCFLAGS` and `FFLAGS` contain the same CPU
flags that would be set for the GCC compiler.

Fixes #10424.
Fixes #10744.

Closes #10774.

Signed-off-by: Charlie Sharpsteen <source@sharpsteen.net>
c90a938

xu-cheng locked and limited conversation to collaborators Feb 16, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.