arm.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import sys
  2. from numpy.distutils.fcompiler import FCompiler, dummy_fortran_file
  3. from sys import platform
  4. from os.path import join, dirname, normpath
  5. compilers = ['ArmFlangCompiler']
  6. import functools
  7. class ArmFlangCompiler(FCompiler):
  8. compiler_type = 'arm'
  9. description = 'Arm Compiler'
  10. version_pattern = r'\s*Arm.*version (?P<version>[\d.-]+).*'
  11. ar_exe = 'lib.exe'
  12. possible_executables = ['armflang']
  13. executables = {
  14. 'version_cmd': ["", "--version"],
  15. 'compiler_f77': ["armflang", "-fPIC"],
  16. 'compiler_fix': ["armflang", "-fPIC", "-ffixed-form"],
  17. 'compiler_f90': ["armflang", "-fPIC"],
  18. 'linker_so': ["armflang", "-fPIC", "-shared"],
  19. 'archiver': ["ar", "-cr"],
  20. 'ranlib': None
  21. }
  22. pic_flags = ["-fPIC", "-DPIC"]
  23. c_compiler = 'arm'
  24. module_dir_switch = '-module ' # Don't remove ending space!
  25. def get_libraries(self):
  26. opt = FCompiler.get_libraries(self)
  27. opt.extend(['flang', 'flangrti', 'ompstub'])
  28. return opt
  29. @functools.lru_cache(maxsize=128)
  30. def get_library_dirs(self):
  31. """List of compiler library directories."""
  32. opt = FCompiler.get_library_dirs(self)
  33. flang_dir = dirname(self.executables['compiler_f77'][0])
  34. opt.append(normpath(join(flang_dir, '..', 'lib')))
  35. return opt
  36. def get_flags(self):
  37. return []
  38. def get_flags_free(self):
  39. return []
  40. def get_flags_debug(self):
  41. return ['-g']
  42. def get_flags_opt(self):
  43. return ['-O3']
  44. def get_flags_arch(self):
  45. return []
  46. def runtime_library_dir_option(self, dir):
  47. return '-Wl,-rpath=%s' % dir
  48. if __name__ == '__main__':
  49. from distutils import log
  50. log.set_verbosity(2)
  51. from numpy.distutils import customized_fcompiler
  52. print(customized_fcompiler(compiler='armflang').get_version())