[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
Tue May 14 02:01:52 PDT 2024
https://github.com/mjklemm updated https://github.com/llvm/llvm-project/pull/90888
>From ce780620b303f185fa13a9cc424db0f540901c6d 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 1/2] Recognize Flang as a compiler and ask for resource dir
---
openmp/CMakeLists.txt | 20 ++++++++++++++++++++
openmp/runtime/CMakeLists.txt | 4 ----
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt
index 9097ca5623000..3f827ee002c5d 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)
@@ -114,6 +119,21 @@ option(OPENMP_ENABLE_LIBOMP_PROFILING "Enable time profiling for libomp." OFF)
# Header install location
if(${OPENMP_STANDALONE_BUILD})
set(LIBOMP_HEADERS_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}")
+ 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 bcae02eba6a59..24036a08a9647 100644
--- a/openmp/runtime/CMakeLists.txt
+++ b/openmp/runtime/CMakeLists.txt
@@ -262,10 +262,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)
>From cb345c626819802a8565ba34d09b02cac7cb1733 Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Thu, 2 May 2024 20:47:40 +0200
Subject: [PATCH 2/2] Cleanup debugging code
---
openmp/CMakeLists.txt | 3 ---
1 file changed, 3 deletions(-)
diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt
index 3f827ee002c5d..d2041ca49a4ed 100644
--- a/openmp/CMakeLists.txt
+++ b/openmp/CMakeLists.txt
@@ -127,12 +127,9 @@ if(${OPENMP_STANDALONE_BUILD})
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)
More information about the Openmp-commits
mailing list