[Openmp-commits] [openmp] [Flang][OpenMP] Install `omp_lib*.{mod, h}` into correct resource directory for standalone Flang builds (PR #90888)
Michael Klemm via Openmp-commits
openmp-commits at lists.llvm.org
Thu May 2 11:46:41 PDT 2024
https://github.com/mjklemm created https://github.com/llvm/llvm-project/pull/90888
Fixes https://github.com/llvm/llvm-project/issues/90543. Depends PR https://github.com/llvm/llvm-project/pull/90886 as it relies on `-print-resource-dir`.
>From 8ad003db0970b3eac375f80636725ea023cd2be0 Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Thu, 2 May 2024 11:58:13 +0200
Subject: [PATCH] Recognize Flang as a compiler and ask for resource dir
---
openmp/CMakeLists.txt | 24 ++++++++++++++++++++++--
openmp/runtime/CMakeLists.txt | 4 ----
2 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt
index 95f2425db3ee6b..a11350c7150b62 100644
--- a/openmp/CMakeLists.txt
+++ b/openmp/CMakeLists.txt
@@ -85,6 +85,11 @@ else()
set(CMAKE_CXX_EXTENSIONS NO)
endif()
+# Enabling Fortran if it is needed
+if(${LIBOMP_FORTRAN_MODULES})
+ enable_language(Fortran)
+endif()
+
# Check and set up common compiler flags.
include(config-ix)
include(HandleOpenMPOptions)
@@ -118,12 +123,27 @@ if(${OPENMP_STANDALONE_BUILD})
OUTPUT_STRIP_TRAILING_WHITESPACE
COMMAND ${CMAKE_CXX_COMPILER} --print-resource-dir
RESULT_VARIABLE COMMAND_RETURN_CODE
- OUTPUT_VARIABLE COMPILER_RESOURCE_DIR
+ OUTPUT_VARIABLE CXX_COMPILER_RESOURCE_DIR
)
- set(LIBOMP_HEADERS_INSTALL_PATH "${COMPILER_RESOURCE_DIR}/include")
+ set(LIBOMP_HEADERS_INSTALL_PATH "${CXX_COMPILER_RESOURCE_DIR}/include")
else()
set(LIBOMP_HEADERS_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}")
endif()
+ message("MK: CMAKE_Fortran_COMPILER_ID=${CMAKE_Fortran_COMPILER_ID}")
+ if(CMAKE_Fortran_COMPILER_ID MATCHES "Flang")
+ execute_process(
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ COMMAND ${CMAKE_Fortran_COMPILER} --print-resource-dir
+ RESULT_VARIABLE COMMAND_RETURN_CODE
+ OUTPUT_VARIABLE FORTRAN_COMPILER_RESOURCE_DIR
+ )
+ # TODO: This must not be hard-coded, but needs to come from Flang!
+ set(LIBOMP_MODULES_INSTALL_PATH "${FORTRAN_COMPILER_RESOURCE_DIR}")
+ message("MK: 1 LIBOMP_MODULES_INSTALL_PATH=${LIBOMP_MODULES_INSTALL_PATH}")
+ else()
+ set(LIBOMP_MODULES_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}")
+ message("MK: 2 LIBOMP_MODULES_INSTALL_PATH=${CMAKE_INSTALL_INCLUDEDIR}")
+ endif()
else()
include(GetClangResourceDir)
get_clang_resource_dir(LIBOMP_HEADERS_INSTALL_PATH SUBDIR include)
diff --git a/openmp/runtime/CMakeLists.txt b/openmp/runtime/CMakeLists.txt
index 57ed54bcdc7bbe..261a6fb8582041 100644
--- a/openmp/runtime/CMakeLists.txt
+++ b/openmp/runtime/CMakeLists.txt
@@ -259,10 +259,6 @@ set(LIBOMP_TOOLS_DIR ${LIBOMP_BASE_DIR}/tools)
set(LIBOMP_INC_DIR ${LIBOMP_SRC_DIR}/include)
set(LIBOMP_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
-# Enabling Fortran if it is needed
-if(${LIBOMP_FORTRAN_MODULES})
- enable_language(Fortran)
-endif()
# Enable MASM Compiler if it is needed (Windows only)
if(WIN32)
enable_language(ASM_MASM)
More information about the Openmp-commits
mailing list