Skip to content

Commit 4e177d3

Browse files
matthew-brettrgommers
authored andcommitted
BUG: get fortran arch flags from C arch flags if available. Closes #1399.
1 parent c8e1315 commit 4e177d3

1 file changed

Lines changed: 11 additions & 25 deletions

File tree

  • numpy/distutils/fcompiler

‎numpy/distutils/fcompiler/gnu.py‎

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,18 @@ def get_flags_opt(self):
202202
opt.append('-funroll-loops')
203203
return opt
204204

205+
def _c_arch_flags(self):
206+
""" Return detected arch flags from CFLAGS """
207+
from distutils import sysconfig
208+
cflags = sysconfig.get_config_vars()['CFLAGS']
209+
arch_re = re.compile(r"-arch\s+(\w+)")
210+
arch_flags = []
211+
for arch in arch_re.findall(cflags):
212+
arch_flags += ['-arch', arch]
213+
return arch_flags
214+
205215
def get_flags_arch(self):
206-
return []
216+
return self._c_arch_flags()
207217

208218
class Gnu95FCompiler(GnuFCompiler):
209219
compiler_type = 'gnu95'
@@ -249,30 +259,6 @@ def version_match(self, version_string):
249259

250260
g2c = 'gfortran'
251261

252-
def _universal_flags(self, cmd):
253-
"""Return a list of -arch flags for every supported architecture."""
254-
if not sys.platform == 'darwin':
255-
return []
256-
arch_flags = []
257-
for arch in ["ppc", "i686", "x86_64", "ppc64"]:
258-
if _can_target(cmd, arch):
259-
arch_flags.extend(["-arch", arch])
260-
return arch_flags
261-
262-
def get_flags(self):
263-
flags = GnuFCompiler.get_flags(self)
264-
arch_flags = self._universal_flags(self.compiler_f90)
265-
if arch_flags:
266-
flags[:0] = arch_flags
267-
return flags
268-
269-
def get_flags_linker_so(self):
270-
flags = GnuFCompiler.get_flags_linker_so(self)
271-
arch_flags = self._universal_flags(self.linker_so)
272-
if arch_flags:
273-
flags[:0] = arch_flags
274-
return flags
275-
276262
def get_library_dirs(self):
277263
opt = GnuFCompiler.get_library_dirs(self)
278264
if sys.platform == 'win32':

0 commit comments

Comments
 (0)