diff options
author | rgommers <ralf.gommers@googlemail.com> | 2010-10-19 21:45:27 +0800 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2010-11-07 11:28:39 -0700 |
commit | 435c7262592e94c8519f4288a19035de054758fd (patch) | |
tree | 5bc71e684ae601900d22417e801adee44e1d08ae /numpy/distutils/fcompiler | |
parent | 6e5590ff95219c5323f33159034930de2d248448 (diff) | |
download | numpy-435c7262592e94c8519f4288a19035de054758fd.tar.gz |
BUG: fix issue with incorrect Fortran arch flags. Closes #1399.
The basic idea here is to compare arch flags the Fortran compiler supports with
the ones the C compiler receives, and throw out any superfluous ones.
Diffstat (limited to 'numpy/distutils/fcompiler')
-rw-r--r-- | numpy/distutils/fcompiler/gnu.py | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/numpy/distutils/fcompiler/gnu.py b/numpy/distutils/fcompiler/gnu.py index 2a221a78d..49df885b6 100644 --- a/numpy/distutils/fcompiler/gnu.py +++ b/numpy/distutils/fcompiler/gnu.py @@ -216,7 +216,7 @@ class GnuFCompiler(FCompiler): return arch_flags def get_flags_arch(self): - return self._c_arch_flags() + return [] class Gnu95FCompiler(GnuFCompiler): compiler_type = 'gnu95' @@ -266,6 +266,36 @@ class Gnu95FCompiler(GnuFCompiler): g2c = 'gfortran' + def _universal_flags(self, cmd): + """Return a list of -arch flags for every supported architecture.""" + if not sys.platform == 'darwin': + return [] + arch_flags = [] + # get arches the C compiler gets. + c_archs = self._c_arch_flags() + if "i386" in c_archs: + c_archs[c_archs.index("i386")] = "i686" + # check the arches the Fortran compiler supports, and compare with + # arch flags from C compiler + for arch in ["ppc", "i686", "x86_64", "ppc64"]: + if _can_target(cmd, arch) and arch in c_archs: + arch_flags.extend(["-arch", arch]) + return arch_flags + + def get_flags(self): + flags = GnuFCompiler.get_flags(self) + arch_flags = self._universal_flags(self.compiler_f90) + if arch_flags: + flags[:0] = arch_flags + return flags + + def get_flags_linker_so(self): + flags = GnuFCompiler.get_flags_linker_so(self) + arch_flags = self._universal_flags(self.linker_so) + if arch_flags: + flags[:0] = arch_flags + return flags + def get_library_dirs(self): opt = GnuFCompiler.get_library_dirs(self) if sys.platform == 'win32': |