summaryrefslogtreecommitdiffstats
path: root/openmp/runtime/cmake/LibompGetArchitecture.cmake
diff options
context:
space:
mode:
authorJonathan Peyton <jonathan.l.peyton@intel.com>2015-07-15 16:05:30 +0000
committerJonathan Peyton <jonathan.l.peyton@intel.com>2015-07-15 16:05:30 +0000
commit2e0133526e85e53ff67a25511b9789d2e10f17d2 (patch)
tree773e372c749314de37743dd3fc45b62f133d2f9a /openmp/runtime/cmake/LibompGetArchitecture.cmake
parent8da737a18a7b543e0c5b54e3e609d1a5eda8dddc (diff)
downloadbcm5719-llvm-2e0133526e85e53ff67a25511b9789d2e10f17d2.tar.gz
bcm5719-llvm-2e0133526e85e53ff67a25511b9789d2e10f17d2.zip
Large Refactor of CMake build system
This commit improves numerous functionalities of the OpenMP CMake build system to be more conducive with LLVM's build system and build philosophies. The CMake build system, as it was before this commit, was not up to LLVM's standards and did not implement the configuration stage like most CMake based build systems offer (check for compiler flags, libraries, etc.) In order to improve it dramatically in a short period of time, a large refactoring had to be done. The main changes done with this commit are as follows: * Compiler flag checks - The flags are no longer grabbed from compiler specific directories. They are checked for availability in config-ix.cmake and added accordingly inside LibompHandleFlags.cmake. * Feature checks were added in config-ix.cmake. For example, the standard CMake module FindThreads is probed for the threading model to use inside the OpenMP library. * OS detection - There is no longer a LIBOMP_OS variable, OS-specifc build logic is wrapped around the WIN32 and APPLE macros with !(WIN32 OR APPLE) meaning a Unix flavor of some sort. * Got rid of vestigial functions/macros/variables * Added new libomp_append() function which is used everywhere to conditionally or undconditionally append to a list * All targets have the libomp prefix so as not to interfere with any other project * LibompCheckLinkerFlag.cmake module was added which checks for linker flags specifically for building shared libraries. * LibompCheckFortranFlag.cmake module was added which checks for fortran flag availability. * Removed most of the cruft from the translation between the perl+Makefile based build system and this one. The remaining components that they share are perl scripts which I'm in the process of removing. There is still more left to do. The perl scripts still need to be removed, and a config.h.in file (or similarly named) needs to be added with #cmakedefine lines in it. But this is a much better first step than the previous system. Differential Revision: http://reviews.llvm.org/D10656 llvm-svn: 242298
Diffstat (limited to 'openmp/runtime/cmake/LibompGetArchitecture.cmake')
-rw-r--r--openmp/runtime/cmake/LibompGetArchitecture.cmake67
1 files changed, 67 insertions, 0 deletions
diff --git a/openmp/runtime/cmake/LibompGetArchitecture.cmake b/openmp/runtime/cmake/LibompGetArchitecture.cmake
new file mode 100644
index 00000000000..1773330de4c
--- /dev/null
+++ b/openmp/runtime/cmake/LibompGetArchitecture.cmake
@@ -0,0 +1,67 @@
+#
+#//===----------------------------------------------------------------------===//
+#//
+#// The LLVM Compiler Infrastructure
+#//
+#// This file is dual licensed under the MIT and the University of Illinois Open
+#// Source Licenses. See LICENSE.txt for details.
+#//
+#//===----------------------------------------------------------------------===//
+#
+
+# Determine the architecture from predefined compiler macros
+# The architecture name can only contain alphanumeric characters and underscores (i.e., C identifier)
+
+# void get_architecture(string* return_arch)
+# - Returns the architecture in return_arch
+function(libomp_get_architecture return_arch)
+ set(detect_arch_src_txt "
+ #if defined(__KNC__)
+ #error ARCHITECTURE=mic
+ #elif defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)
+ #error ARCHITECTURE=x86_64
+ #elif defined(__i386) || defined(__i386__) || defined(__IA32__) || defined(_M_I86) || defined(_M_IX86) || defined(__X86__) || defined(_X86_)
+ #error ARCHITECTURE=i386
+ #elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__)
+ #error ARCHITECTURE=arm
+ #elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6ZK__)
+ #error ARCHITECTURE=arm
+ #elif defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) || defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__)
+ #error ARCHITECTURE=arm
+ #elif defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__)
+ #error ARCHITECTURE=arm
+ #elif defined(__ARM_ARCH_3__) || defined(__ARM_ARCH_3M__)
+ #error ARCHITECTURE=arm
+ #elif defined(__ARM_ARCH_2__)
+ #error ARCHITECTURE=arm
+ #elif defined(__arm__) || defined(_M_ARM) || defined(_ARM)
+ #error ARCHITECTURE=arm
+ #elif defined(__aarch64__)
+ #error ARCHITECTURE=aarch64
+ #elif defined(__powerpc64__) && defined(__LITTLE_ENDIAN__)
+ #error ARCHITECTURE=ppc64le
+ #elif defined(__powerpc64__)
+ #error ARCHITECTURE=ppc64
+ #else
+ #error ARCHITECTURE=UnknownArchitecture
+ #endif
+ "
+ )
+ # Write out ${detect_arch_src_txt} to a file within the cmake/ subdirectory
+ 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)
+
+ # 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}")
+
+ # Get rid of the ARCHITECTURE= part of the string
+ string(REPLACE "ARCHITECTURE=" "" local_architecture "${local_architecture}")
+
+ # set the return value to the architecture detected (e.g., 32e, 32, arm, ppc64, etc.)
+ set(${return_arch} "${local_architecture}" PARENT_SCOPE)
+
+ # Remove ${detect_arch_src_txt} from cmake/ subdirectory
+ file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/libomp_detect_arch.c")
+endfunction()
OpenPOWER on IntegriCloud