IBMLLVMFlang: Add support for this compiler

Add support for the `ibm-flang` compiler tool, a variant of LLVMFlang.

Closes: #27863
This commit is contained in:
Kelvin Li
2026-05-25 22:34:52 -04:00
committed by Brad King
parent 5636aa7740
commit ee76398d23
6 changed files with 41 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
ibm-flang
---------
* The ``ibm-flang`` compiler is now supported with
:variable:`compiler id <CMAKE_<LANG>_COMPILER_ID>` ``IBMLLVMFlang``.

View File

@@ -54,6 +54,7 @@ Value Name
``XL``, ``VisualAge``, ``zOS`` IBM XL
``XLClang`` IBM Clang-based XL
``IBMClang`` IBM LLVM-based Compiler
``IBMLLVMFlang`` IBM LLVM/Flang-based Fortran Compiler
=============================== ===============================================
This variable is not guaranteed to be defined for all compilers or

View File

@@ -72,6 +72,17 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
endforeach()
endif()
# Check if there is any vendor specific LLVMFlang
if(lang STREQUAL "Fortran" AND CMAKE_${lang}_COMPILER_ID STREQUAL "LLVMFlang")
set(_orig_compiler_id "${CMAKE_${lang}_COMPILER_ID}")
foreach(userflags "${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST}" "")
CMAKE_DETERMINE_COMPILER_ID_VENDOR(${lang} "${userflags}")
if(NOT CMAKE_${lang}_COMPILER_ID STREQUAL _orig_compiler_id)
break()
endif()
endforeach()
endif()
# Check if compiler id detection gave us the compiler tool.
if(CMAKE_${lang}_COMPILER_ID_TOOL)
set(CMAKE_${lang}_COMPILER "${CMAKE_${lang}_COMPILER_ID_TOOL}")
@@ -237,6 +248,22 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
endif()
endif()
# The IBM LLVM Flang compiler version is extracted from --version output
if(CMAKE_${lang}_COMPILER_ID STREQUAL "IBMLLVMFlang")
execute_process(
COMMAND "${CMAKE_${lang}_COMPILER}" --version
OUTPUT_VARIABLE output
ERROR_VARIABLE output
RESULT_VARIABLE result
TIMEOUT 10
)
if(result EQUAL 0)
if(output MATCHES [[version ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)]])
set(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_MATCH_1}")
endif()
endif()
endif()
# if the format is unknown after all files have been checked, put "Unknown" in the cache
if(NOT CMAKE_EXECUTABLE_FORMAT)
set(CMAKE_EXECUTABLE_FORMAT "Unknown" CACHE INTERNAL "Executable file format")

View File

@@ -134,6 +134,9 @@ if(NOT CMAKE_Fortran_COMPILER_ID_RUN)
list(APPEND CMAKE_Fortran_COMPILER_ID_VENDORS NAG) # Numerical Algorithms Group
set(CMAKE_Fortran_COMPILER_ID_VENDOR_FLAGS_NAG "-V")
set(CMAKE_Fortran_COMPILER_ID_VENDOR_REGEX_NAG "NAG Fortran Compiler")
list(APPEND CMAKE_Fortran_COMPILER_ID_VENDORS IBMLLVMFlang)
set(CMAKE_Fortran_COMPILER_ID_VENDOR_FLAGS_IBMLLVMFlang "--version")
set(CMAKE_Fortran_COMPILER_ID_VENDOR_REGEX_IBMLLVMFlang "IBM Open XL Fortran")
# Match the link line from xcodebuild output of the form
# Ld ...

View File

@@ -0,0 +1,3 @@
# IBM LLVM Flang Compiler
include(Compiler/LLVMFlang-Fortran)

View File

@@ -0,0 +1,2 @@
include(Platform/AIX-GNU)
__aix_compiler_gnu(Fortran)