MantisBT - CMake
View Issue Details
0011627CMakeCMakepublic2010-12-18 10:572011-01-18 11:39
Christian Convey 
Brad King 
highblockalways
closedno change required 
Apple MacOS X10.5
CMake 2.8.3 
 
0011627: Wrong target-architecture flags for stock version of gfortran on OS X
I set CMAKE_OSX_ARCHITECTURES to "x86_64", because I want to produce a 64-bit executable.

When I do this, gfortran ends up being invoked with "-arch x86_64", which isn't valid for the compiler.

There are some OS X fortran compilers for which "-arch" *is* appropriate. Apparently Apple used to maintain a port of gfortran for which that flag was valid, but they seem to not do that any longer. "-arch" is also valid for the Intel fortran compiler on OS X.

The problem is that the stock GCC fortran compiler does not support "-arch".

Here's what a gfortran developer told me: "The GCC option for specifying an architecture is of the form '-march=XYZ' where you can a complete list of XYZ in the GCC manual. http://gcc.gnu.org/onlinedocs/gcc-4.5.1/gcc/ [^] "
No tags attached.
Issue History
2010-12-18 10:57Christian ConveyNew Issue
2010-12-20 08:48Brad KingNote Added: 0024278
2010-12-20 08:49Brad KingNote Edited: 0024278bug_revision_view_page.php?bugnote_id=24278#r59
2010-12-20 08:50Brad KingAssigned To => Brad King
2010-12-20 08:50Brad KingStatusnew => feedback
2011-01-18 11:27David ColeNote Added: 0024867
2011-01-18 11:39Brad KingNote Added: 0024870
2011-01-18 11:39Brad KingStatusfeedback => closed
2011-01-18 11:39Brad KingResolutionopen => no change required

Notes
(0024278)
Brad King   
2010-12-20 08:48   
(edited on: 2010-12-20 08:49)
CMAKE_OSX_ARCHITECTURES is meant for building universal binaries, typically with multiple architectures listed. The "-arch" flag is documented by Apple's port of GCC. Most importantly the "-arch" flag can be repeated multiple times on the same command line and the compiler target all the specified architectures to build a universal binary.

AFAIK Apple has halted work on GCC and ports of it in favor of their new llvm/clang effort. How does the GNU upstream gcc build universal binaries?

The solution to your original problem is to set

  CFLAGS=-m64
  CXXFLAGS=-m64
  FFLAGS=-m64

in your environment before running CMake. Don't use CMAKE_OSX_ARCHITECTURES unless you want universal binaries and have a toolchain capable of building them.

(0024867)
David Cole   
2011-01-18 11:27   
So, then... based on the report and the note 0011627:0024278 is this an issue at all? Seems like this one should be resolved as "no change required" because this is the expected behavior here.

Any problems with that resolution?
(0024870)
Brad King   
2011-01-18 11:39   
This is not a CMake issue.

Christian, if you have further questions please post to the mailing list for help:

  http://www.cmake.org/mailman/listinfo/cmake [^]

Thanks.