1 /* Copyright 2022-2024 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 #if defined (__NVCOMPILER_MAJOR__)
28 set compiler_info [join {nvfortran __NVCOMPILER_MAJOR__ __NVCOMPILER_MINOR__ __NVCOMPILER_PATCHLEVEL__} -]
31 /* Classic flang and LLVM flang emit their respective macros differently. */
33 /* LLVM flang complains about non Fortran tokens so we do not use "{" here. */
34 #if defined (__flang__)
35 set major __flang_major__
36 set minor __flang_minor__
37 set patch __flang_patchlevel__
38 set compiler_info [join "flang-llvm $major $minor $patch" -]
43 set compiler_info [join {flang-classic __FLANG_MAJOR__ __FLANG_MINOR__ __FLANG_PATCHLEVEL__} -]
46 /* Intel LLVM emits a string like 20220100 with version 2021.2.0 and higher. */
47 #if defined (__INTEL_LLVM_COMPILER)
48 set major [string range __INTEL_LLVM_COMPILER 0 3]
49 set minor [string range __INTEL_LLVM_COMPILER 4 5]
50 set patch [string range __INTEL_LLVM_COMPILER 6 7]
51 set compiler_info [join "ifx $major $minor $patch" -]
52 #elif defined (__INTEL_COMPILER)
53 /* Starting with 2021 the ifort versioning scheme changed. Before, Intel ifort
54 would define its version as e.g. 19.0.0 or rather __INTEL_COMPILER would be
55 emitted as 1900. With 2021 the versioning became e.g. 2021.1 defined in
56 __INTEL_COMPILER.__INTEL_COMPILER_UPDATE. No patch is emitted since the
57 change. This compiler identification might not work with ifort versions
59 #if (__INTEL_COMPILER < 2021)
60 set major [string range __INTEL_COMPILER 0 1]
61 set minor [string range __INTEL_COMPILER 2 2]
62 #if defined (__INTEL_COMPILER_UPDATE)
63 set patch __INTEL_COMPILER_UPDATE
65 set patch [string range __INTEL_COMPILER 3 3]
68 set major __INTEL_COMPILER
69 set minor __INTEL_COMPILER_UPDATE
72 set compiler_info [join "ifort $major $minor $patch" -]