[cmake-developers] [CMake 0014252]: Unsupported "-arch x86_64" mysteriously ends up in Fortran_FLAGS

Mantis Bug Tracker mantis at public.kitware.com
Fri Jun 28 09:13:56 EDT 2013


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=14252 
====================================================================== 
Reported By:                Mojca Miklavec
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   14252
Category:                   (No Category)
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2013-06-28 09:13 EDT
Last Modified:              2013-06-28 09:13 EDT
====================================================================== 
Summary:                    Unsupported "-arch x86_64" mysteriously ends up in
Fortran_FLAGS
Description: 
http://public.kitware.com/pipermail/cmake-developers/2013-January/006230.html

An unsupported compiler flag "-arch x86_64" mysteriously sneaks into
Fortran_FLAGS when
    -DCMAKE_OSX_ARCHITECTURES="x86_64"
is passed to cmake. That flag CMAKE_OSX_ARCHITECTURES is added automatically to
all projects in MacPorts (third-party package manager for Mac OS X) even when
cross-compiling or compilation of fat binaries (like i386+x86_64) is not needed,
so no project that needs Fortran and CMake can be compiled (luckily there are
not many such projects, but it's still a showstopper to switch to CMake).


The g95 compiler ignores "-arch <...>" flag, but GCC's gfortran 4.x throws an
error and breaks compilation. I could probably try to prevent
DCMAKE_OSX_ARCHITECTURES from being passed to cmake (via some tricks in MacPorts
or by modifying MacPorts sources), but I still believe that passing "-arch
x86_64" to Fortran_FLAGS is a bug in CMake.


Steps to Reproduce: 
Compiled Root (root.cern.ch) or any minimal project which needs Fortran with

cmake \
-DCMAKE_Fortran_COMPILER=/opt/local/bin/gfortran-mp-4.5 \
-DCMAKE_C_COMPILER=/usr/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
-DCMAKE_INSTALL_PREFIX=/path/to/install \
-DCMAKE_OSX_ARCHITECTURES="x86_64" ../path/to/sources

In that particular project the generated file
    misc/minicern/CMakeFiles/minicern.dir/flags.make
ends up containing the following variables (among others):
    C_FLAGS =  -m64 -pipe -W -Wall -fsigned-char -fno-common -O2 -g-arch x86_64
-fPIC -I<path/to/some/include/dirs>
    Fortran_FLAGS =  -m64 -std=legacy -arch x86_64 -fPIC
-I<path/to/some/include/dirs>

The flag "-arch x86_64" shouldn't be there.

Additional Information: 
Citing
http://public.kitware.com/pipermail/cmake-developers/2013-January/006230.html:

The "-arch" flag is hard-coded here:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmLocalGenerator.cxx;hb=v2.8.10.2#l1826

It was added to CMake way back when universal binary support was
first added to OS X under the assumption that all compilers that
would be used in combination with CMAKE_OSX_ARCHITECTURES would
support the flag.  Obviously the assumption is wrong.

The hard-coded flag needs to be replaced with a lookup of a new
per-language platform information variable, perhaps called

 CMAKE_<LANG>_OSX_ARCHITECTURE_FLAG

-Brad


Some more links:
- https://trac.macports.org/ticket/37732 (about the -arch flag in Fortran)
- https://trac.macports.org/ticket/37688 ([also] about development of a package
for Root using CMake)
- https://sft.its.cern.ch/jira/browse/ROOT-4874 (not strictly related)

====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2013-06-28 09:13 Mojca Miklavec New Issue                                    
======================================================================




More information about the cmake-developers mailing list