From 2f3a07a981edfbc325f19ea252003e9da59dbcf5 Mon Sep 17 00:00:00 2001 From: Tin Huynh Date: Fri, 4 Aug 2017 17:50:09 -0700 Subject: Flang: Add support for flang Fortran compiler flang is a Fortran compiler built on top of clang [1]. Because flang shares a lot of commonalities with clang, the flang module piggybacks off the clang module and overrides certain options. Add flang to Fortran compiler auto find list. Update flang preprocessor macros to differentiate from PGI. Add Flang-FindBinUtils. [1] https://github.com/flang-compiler/flang --- Help/release/dev/flang.rst | 6 ++++++ Help/variable/CMAKE_LANG_COMPILER_ID.rst | 1 + Modules/CMakeDetermineFortranCompiler.cmake | 6 ++++-- Modules/CMakeFortranCompilerId.F.in | 7 +++++++ Modules/Compiler/Flang-FindBinUtils.cmake | 1 + Modules/Compiler/Flang-Fortran.cmake | 12 ++++++++++++ 6 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 Help/release/dev/flang.rst create mode 100644 Modules/Compiler/Flang-FindBinUtils.cmake create mode 100644 Modules/Compiler/Flang-Fortran.cmake diff --git a/Help/release/dev/flang.rst b/Help/release/dev/flang.rst new file mode 100644 index 0000000..9849f14 --- /dev/null +++ b/Help/release/dev/flang.rst @@ -0,0 +1,6 @@ +flang +----- + +* The `flang`_ Fortran compiler is now supported, with compiler id ``Flang``. + +.. _`flang`: https://github.com/flang-compiler/flang diff --git a/Help/variable/CMAKE_LANG_COMPILER_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ID.rst index 5204044..2264269 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_ID.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_ID.rst @@ -27,6 +27,7 @@ include: NVIDIA = NVIDIA CUDA Compiler (nvidia.com) OpenWatcom = Open Watcom (openwatcom.org) PGI = The Portland Group (pgroup.com) + Flang = Flang Fortran Compiler PathScale = PathScale (pathscale.com) SDCC = Small Device C Compiler (sdcc.sourceforge.net) SunPro = Oracle Solaris Studio (oracle.com) diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 5559640..2549c22 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -52,6 +52,7 @@ else() # frt: Fujitsu F77 compiler # pathf90/pathf95/pathf2003: PathScale Fortran compiler # pgf77/pgf90/pgf95/pgfortran: Portland Group F77/F90/F95 compilers + # flang: Flang Fortran compiler # xlf/xlf90/xlf95: IBM (AIX) F77/F90/F95 compilers # lf95: Lahey-Fujitsu F95 compiler # fl32: Microsoft Fortran 77 "PowerStation" compiler @@ -68,7 +69,7 @@ else() set(CMAKE_Fortran_COMPILER_LIST ftn ifort ifc af95 af90 efc f95 pathf2003 pathf95 pgf95 pgfortran lf95 xlf95 - fort gfortran gfortran-4 g95 f90 pathf90 pgf90 xlf90 epcf90 fort77 + fort flang gfortran gfortran-4 g95 f90 pathf90 pgf90 xlf90 epcf90 fort77 frt pgf77 xlf fl32 af77 g77 f77 nag ) @@ -77,10 +78,11 @@ else() set(_Fortran_COMPILER_NAMES_Intel ifort ifc efc) set(_Fortran_COMPILER_NAMES_Absoft af95 af90 af77) set(_Fortran_COMPILER_NAMES_PGI pgf95 pgfortran pgf90 pgf77) + set(_Fortran_COMPILER_NAMES_Flang flang) set(_Fortran_COMPILER_NAMES_PathScale pathf2003 pathf95 pathf90) set(_Fortran_COMPILER_NAMES_XL xlf) set(_Fortran_COMPILER_NAMES_VisualAge xlf95 xlf90 xlf) - set(_Fortran_COMPILER_NAMES_NAG nagfor) + set(_Fortran_COMPILER_NAMES_NAG nagfor) endif() _cmake_find_compiler(Fortran) diff --git a/Modules/CMakeFortranCompilerId.F.in b/Modules/CMakeFortranCompilerId.F.in index 26b2ed6..49789f1 100644 --- a/Modules/CMakeFortranCompilerId.F.in +++ b/Modules/CMakeFortranCompilerId.F.in @@ -90,6 +90,13 @@ # if defined(__PGIC_PATCHLEVEL__) # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__) # endif +#elif defined(__FLANG) + PRINT *, 'INFO:compiler[Flang]' +# define COMPILER_VERSION_MAJOR DEC(__FLANG_MAJOR__) +# define COMPILER_VERSION_MINOR DEC(__FLANG_MINOR__) +# if defined(__FLANG_PATCHLEVEL__) +# define COMPILER_VERSION_PATCH DEC(__FLANG_PATCHLEVEL__) +# endif #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION) PRINT *, 'INFO:compiler[MIPSpro]' # if 0 diff --git a/Modules/Compiler/Flang-FindBinUtils.cmake b/Modules/Compiler/Flang-FindBinUtils.cmake new file mode 100644 index 0000000..e721c87 --- /dev/null +++ b/Modules/Compiler/Flang-FindBinUtils.cmake @@ -0,0 +1 @@ +include(Compiler/Clang-FindBinUtils) diff --git a/Modules/Compiler/Flang-Fortran.cmake b/Modules/Compiler/Flang-Fortran.cmake new file mode 100644 index 0000000..f17dec7 --- /dev/null +++ b/Modules/Compiler/Flang-Fortran.cmake @@ -0,0 +1,12 @@ +include(Compiler/Clang) +__compiler_clang(Fortran) + +set(CMAKE_Fortran_PREPROCESS_SOURCE + " -cpp -E -o ") + +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form") + +string(APPEND CMAKE_Fortran_FLAGS_DEBUG_INIT " -fbounds-check") + +set(CMAKE_Fortran_MODDIR_FLAG "-J") -- cgit v0.12 From d8e03e9ba6f5ad948839ba9b291caa014813d9da Mon Sep 17 00:00:00 2001 From: Tin Huynh Date: Thu, 31 Aug 2017 09:50:31 -0700 Subject: FindOpenMP: Add Flang flag. --- Modules/FindOpenMP.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index 1093be0..7566e4a 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -95,6 +95,7 @@ function(_OPENMP_FLAG_CANDIDATES LANG) set(OMP_FLAG_NAG "-openmp") set(OMP_FLAG_Absoft "-openmp") set(OMP_FLAG_PGI "-mp") + set(OMP_FLAG_Flang "-fopenmp") set(OMP_FLAG_SunPro "-xopenmp") set(OMP_FLAG_XL "-qsmp=omp") # Cray compiles with OpenMP automatically -- cgit v0.12