[Openmp-commits] [openmp] Use `try_compile` in LibompGetArchitecture (PR #152153)
Alexander Grund via Openmp-commits
openmp-commits at lists.llvm.org
Tue Aug 5 08:02:05 PDT 2025
https://github.com/Flamefire created https://github.com/llvm/llvm-project/pull/152153
Running is never intended nor possible so just compile
>From 1b9a9507727f1af301312ae5acc4a04e3ad458cd Mon Sep 17 00:00:00 2001
From: Alexander Grund <alexander.grund at tu-dresden.de>
Date: Wed, 30 Jul 2025 13:38:24 +0200
Subject: [PATCH 1/2] Use `try_compile` in LibompGetArchitecture
Running is never intended nor possible so just compile
---
openmp/runtime/cmake/LibompGetArchitecture.cmake | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/openmp/runtime/cmake/LibompGetArchitecture.cmake b/openmp/runtime/cmake/LibompGetArchitecture.cmake
index 81aa700e3b6db..a74cfeb76edb0 100644
--- a/openmp/runtime/cmake/LibompGetArchitecture.cmake
+++ b/openmp/runtime/cmake/LibompGetArchitecture.cmake
@@ -71,7 +71,7 @@ function(libomp_get_architecture return_arch)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/libomp_detect_arch.c" ${detect_arch_src_txt})
# Try to compile using the C Compiler. It will always error out with an #error directive, so store error output to ${local_architecture}
- try_run(run_dummy compile_dummy "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/libomp_detect_arch.c" COMPILE_OUTPUT_VARIABLE local_architecture)
+ try_compile(compile_dummy "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/libomp_detect_arch.c" OUTPUT_VARIABLE local_architecture)
# Match the important architecture line and store only that matching string in ${local_architecture}
string(REGEX MATCH "ARCHITECTURE=([a-zA-Z0-9_]+)" local_architecture "${local_architecture}")
>From baced84847b37aea1aeb833d1c941fb7fdf394f7 Mon Sep 17 00:00:00 2001
From: Alexander Grund <alexander.grund at tu-dresden.de>
Date: Wed, 30 Jul 2025 14:08:03 +0200
Subject: [PATCH 2/2] Avoid compatitiblity issues with CMake 3.25+
---
openmp/runtime/cmake/LibompGetArchitecture.cmake | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/openmp/runtime/cmake/LibompGetArchitecture.cmake b/openmp/runtime/cmake/LibompGetArchitecture.cmake
index a74cfeb76edb0..f2395e24da810 100644
--- a/openmp/runtime/cmake/LibompGetArchitecture.cmake
+++ b/openmp/runtime/cmake/LibompGetArchitecture.cmake
@@ -71,7 +71,7 @@ function(libomp_get_architecture return_arch)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/libomp_detect_arch.c" ${detect_arch_src_txt})
# Try to compile using the C Compiler. It will always error out with an #error directive, so store error output to ${local_architecture}
- try_compile(compile_dummy "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/libomp_detect_arch.c" OUTPUT_VARIABLE local_architecture)
+ try_compile(compile_dummy "${CMAKE_CURRENT_BINARY_DIR}" SOURCES "${CMAKE_CURRENT_BINARY_DIR}/libomp_detect_arch.c" OUTPUT_VARIABLE local_architecture)
# Match the important architecture line and store only that matching string in ${local_architecture}
string(REGEX MATCH "ARCHITECTURE=([a-zA-Z0-9_]+)" local_architecture "${local_architecture}")
More information about the Openmp-commits
mailing list