1 /* Copyright 2022 Free Software Foundation, Inc.
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2 of the License, or
6 (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16 set compiler_info "unknown"
18 #if defined (__GFORTRAN__)
19 set compiler_info [join {gfortran __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__} -]
22 /* ARM seems to not define a patch version. */
23 #if defined (__ARM_LINUX_COMPILER__)
24 set compiler_info [join {armflang __armclang_major__ __armclang_minor__ 0} -]
27 /* Classic flang and LLVM flang emit their respective macros differently. */
29 /* LLVM flang complains about non Fortran tokens so we do not use "{" here. */
30 #if defined (__flang__)
31 set major __flang_major__
32 set minor __flang_minor__
33 set patch __flang_patchlevel__
34 set compiler_info [join "flang-llvm $major $minor $patch" -]
39 set compiler_info [join {flang-classic __FLANG_MAJOR__ __FLANG_MINOR__ __FLANG_PATCHLEVEL__} -]
42 /* Intel LLVM emits a string like 20220100 with version 2021.2.0 and higher. */
43 #if defined (__INTEL_LLVM_COMPILER)
44 set major [string range __INTEL_LLVM_COMPILER 0 3]
45 set minor [string range __INTEL_LLVM_COMPILER 4 5]
46 set patch [string range __INTEL_LLVM_COMPILER 6 7]
47 set compiler_info [join "ifx $major $minor $patch" -]
48 #elif defined (__INTEL_COMPILER)
49 /* Starting with 2021 the ifort versioning scheme changed. Before, Intel ifort
50 would define its version as e.g. 19.0.0 or rather __INTEL_COMPILER would be
51 emitted as 1900. With 2021 the versioning became e.g. 2021.1 defined in
52 __INTEL_COMPILER.__INTEL_COMPILER_UPDATE. No patch is emitted since the
53 change. This compiler identification might not work with ifort versions
55 #if (__INTEL_COMPILER < 2021)
56 set major [string range __INTEL_COMPILER 0 1]
57 set minor [string range __INTEL_COMPILER 2 2]
58 #if defined (__INTEL_COMPILER_UPDATE)
59 set patch __INTEL_COMPILER_UPDATE
61 set patch [string range __INTEL_COMPILER 3 3]
64 set major __INTEL_COMPILER
65 set minor __INTEL_COMPILER_UPDATE
68 set compiler_info [join "ifort $major $minor $patch" -]