[MacPorts] #37732: fortran compilers don't accept -arch flags
MacPorts
noreply at macports.org
Mon Jan 21 23:44:01 PST 2013
#37732: fortran compilers don't accept -arch flags
----------------------+--------------------------------
Reporter: mojca@… | Owner: macports-tickets@…
Type: defect | Status: closed
Priority: Normal | Milestone:
Component: base | Version: 2.1.2
Resolution: invalid | Keywords:
Port: |
----------------------+--------------------------------
Comment (by mojca@…):
Replying to [comment:2 ryandesign@…]:
> Correct: none of the compilers in FSF GCC, including gfortran, support
-arch flags; -arch flags are an Apple extension. If you would like FSF GCC
to adopt this Apple extension you'll have to talk to the developers of FSF
GCC about that.
No, no. I'm not requesting from any compiler to support that flag.
> The cmake 1.0 portgroup makes no mention of FFLAGS, or any other *FLAGS
variables. MacPorts base should be smart enough to not add -arch flags if
the compiler does not support it; we maintain a list in MacPorts base of
which compilers do and do not support -arch flags.
I checked the cmake portgroup and it doesn't seem to have anything to do
with FFLAGS either. So it must be MacPorts base.
> If this is not working correctly please provide a reproduction recipe.
No, it's not working. I can provide two examples (for a minimal example I
would need to create a hello world project). For the first one see
https://trac.macports.org/browser/trunk/dports/science/plplot/Portfile?rev=99965
{{{
# Adhoc fix
# cmake passes -arch to Fortran compiler
# g95 ignores -arch but gfortran fails with it
...
# Fortran notes:
# * In build/language_tests/Fortran, FC and LDFLAGS are used.
# * CMAKE_Fortran_COMPILER is used later in build.
# * To avoid -arch ${build_arch} to be passed configure.ld_archflags is
unset.
...
variant gcc47 conflicts g95 gcc43 gcc44 gcc45 gcc46 universal description
{Add support for fortran using gfortran-mp-4.7} {
depends_lib-append port:gcc47
configure.fc ${prefix}/bin/gfortran-mp-4.7
configure.ld_archflags ""
configure.args-delete -DENABLE_f77=OFF \
-DENABLE_f95=OFF
configure.args-append -DCMAKE_Fortran_COMPILER=\"${configure.fc}\" \
-DCMAKE_Fortran_FLAGS=\"${configure.fflags}\"
}
variant g95 conflicts gcc43 gcc44 gcc45 gcc46 gcc47 universal description
{Add support for fortran using g95} {
depends_lib-append port:g95
configure.fc ${prefix}/bin/g95
configure.ld_archflags ""
configure.args-delete -DENABLE_f77=OFF \
-DENABLE_f95=OFF
configure.args-append -DCMAKE_Fortran_COMPILER=\"${configure.fc}\" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=\"\" \
-DCMAKE_Fortran_FLAGS=\"${configure.fflags}
-fno-second-underscore\"
}
}}}
For the second example see my CMake-based Root Portfile in #37688 and try
it out with {{{+gcc45}}} or one of those flags (but it might take a long
time to compile it). It breaks with
{{{
Building Fortran object misc/minicern/CMakeFiles/minicern.dir/src/hbook.o
cd /Users/me/.macports/opt/local/var/macports/build
/_Users_me_app_macports_science_root-devel/root-
devel/work/build/misc/minicern && /opt/local/bin/gfortran-mp-4.5
-Dminicern_EXPORTS -m64 -std=legacy -O3 -arch x86_64 -fPIC
-I/Users/me/.macports/opt/local/var/macports/build
/_Users_me_app_macports_science_root-devel/root-devel/work/build/include
-I/Users/me/.macports/opt/local/var/macports/build
/_Users_me_app_macports_science_root-devel/root-
devel/work/trunk/misc/minicern/inc -c
/Users/me/.macports/opt/local/var/macports/build
/_Users_me_app_macports_science_root-devel/root-
devel/work/trunk/misc/minicern/src/hbook.f -o
CMakeFiles/minicern.dir/src/hbook.o
f951: error: unrecognized command line option "-arch"
make[2]: *** [misc/minicern/CMakeFiles/minicern.dir/src/hbook.o] Error 1
make[2]: Leaving directory
`/Users/me/.macports/opt/local/var/macports/build
/_Users_me_app_macports_science_root-devel/root-devel/work/build'
make[1]: *** [misc/minicern/CMakeFiles/minicern.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
}}}
Replying to [comment:7 sean@…]:
> Ah, you're right, I remember now. This issue comes up for me when a port
uses one of the FSF compilers *only for fortran*. When the
configure.compiler is checked and, let's say, "clang" is returned, then
all flags get the "-arch" switch which will then break any fortran
compile.
I believe that's exactly what happens: the fortran compiler is set
separately from the rest. I used clang/clang++ and only tried to set
gfortran-mp-4.X. (Since there aren't that many ports using fortran, it's
probably orders of magnitude less tested as all the C compilers. I didn't
yet try to set the gcc compiler for C/C++ since the port author claims
that it failed to work for him. A compilation takes about one hour, so I
didn't try to force something that's know to fail until I get it working
with clang.)
--
Ticket URL: <https://trac.macports.org/ticket/37732#comment:8>
MacPorts <http://www.macports.org/>
Ports system for Mac OS
More information about the macports-tickets
mailing list