Skip to content

Commit 12db091

Browse files
committed
Avoid concurrency issues in LibompGetArchitecture
Especially during `make check-all -j <n>` this CMake code might be run in parallel. So one process could remove the file another process has just written and tries to compile. So do not delete the file. Additionally use just `try_compile` as running is never intended nor possible anyway.
1 parent b7bfbc0 commit 12db091

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

openmp/runtime/cmake/LibompGetArchitecture.cmake

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function(libomp_get_architecture return_arch)
7171
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/libomp_detect_arch.c" ${detect_arch_src_txt})
7272

7373
# Try to compile using the C Compiler. It will always error out with an #error directive, so store error output to ${local_architecture}
74-
try_run(run_dummy compile_dummy "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/libomp_detect_arch.c" COMPILE_OUTPUT_VARIABLE local_architecture)
74+
try_compile(compile_dummy "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/libomp_detect_arch.c" OUTPUT_VARIABLE local_architecture)
7575

7676
# Match the important architecture line and store only that matching string in ${local_architecture}
7777
string(REGEX MATCH "ARCHITECTURE=([a-zA-Z0-9_]+)" local_architecture "${local_architecture}")
@@ -81,9 +81,6 @@ function(libomp_get_architecture return_arch)
8181

8282
# set the return value to the architecture detected (e.g., 32e, 32, arm, ppc64, etc.)
8383
set(${return_arch} "${local_architecture}" PARENT_SCOPE)
84-
85-
# Remove ${detect_arch_src_txt} from cmake/ subdirectory
86-
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/libomp_detect_arch.c")
8784
endfunction()
8885

8986
function(libomp_is_aarch64_a64fx return_is_aarch64_a64fx)

0 commit comments

Comments
 (0)