[Openmp-commits] [openmp] f855751 - Fix openmp CMake build on non-Linux AArch64 systems.

Chandler Carruth via Openmp-commits openmp-commits at lists.llvm.org
Sun Jan 17 16:18:43 PST 2021


Author: Chandler Carruth
Date: 2021-01-17T16:18:31-08:00
New Revision: f855751c1284c82c1c46b98f6d1b3ca2021d6cb9

URL: https://github.com/llvm/llvm-project/commit/f855751c1284c82c1c46b98f6d1b3ca2021d6cb9
DIFF: https://github.com/llvm/llvm-project/commit/f855751c1284c82c1c46b98f6d1b3ca2021d6cb9.diff

LOG: Fix openmp CMake build on non-Linux AArch64 systems.

This just checks for `/proc/cpuinfo` existing before reading it.

Tested on an ARM macOS machine.

Added: 
    

Modified: 
    openmp/runtime/cmake/LibompGetArchitecture.cmake

Removed: 
    


################################################################################
diff  --git a/openmp/runtime/cmake/LibompGetArchitecture.cmake b/openmp/runtime/cmake/LibompGetArchitecture.cmake
index 45c2f279a7d1..dd60a2d347b1 100644
--- a/openmp/runtime/cmake/LibompGetArchitecture.cmake
+++ b/openmp/runtime/cmake/LibompGetArchitecture.cmake
@@ -71,13 +71,15 @@ function(libomp_get_architecture return_arch)
 endfunction()
 
 function(libomp_is_aarch64_a64fx return_is_aarch64_a64fx)
-  file(READ "/proc/cpuinfo" cpu_info_content)
-  string(REGEX MATCH "CPU implementer[ \t]*: 0x46\n" cpu_implementer ${cpu_info_content})
-  string(REGEX MATCH "CPU architecture[ \t]*: 8\n" cpu_architecture ${cpu_info_content})
-
   set(is_aarch64_a64fx FALSE)
-  if (cpu_architecture AND cpu_implementer)
-    set(is_aarch64_a64fx TRUE)
+  if (EXISTS "/proc/cpuinfo")
+    file(READ "/proc/cpuinfo" cpu_info_content)
+    string(REGEX MATCH "CPU implementer[ \t]*: 0x46\n" cpu_implementer ${cpu_info_content})
+    string(REGEX MATCH "CPU architecture[ \t]*: 8\n" cpu_architecture ${cpu_info_content})
+
+    if (cpu_architecture AND cpu_implementer)
+      set(is_aarch64_a64fx TRUE)
+    endif()
   endif()
 
   set(${return_is_aarch64_a64fx} "${is_aarch64_a64fx}" PARENT_SCOPE)


        


More information about the Openmp-commits mailing list