llvm.org GIT mirror llvm / 6215c62
Implement cmake LLVM_MULTITHREADED gcc atomic builtin checks. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76221 91177308-0d34-0410-b5e6-96231b3b80d8 Xerxes Ranby 10 years ago
3 changed file(s) with 24 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
7474 if( LLVM_USING_GLIBC )
7575 add_llvm_definitions( -D_GNU_SOURCE )
7676 endif()
77
78 # Define LLVM_MULTITHREADED if gcc atomic builtins exists.
79 include(CheckAtomic)
7780
7881 include(CheckCXXCompilerFlag)
7982 check_cxx_compiler_flag("-fPIC" SUPPORTS_FPIC_FLAG)
0 # atomic builtins are required for threading support.
1
2 INCLUDE(CheckCXXSourceCompiles)
3
4 CHECK_CXX_SOURCE_COMPILES("
5 int main() {
6 volatile unsigned long val = 1;
7 __sync_synchronize();
8 __sync_val_compare_and_swap(&val, 1, 0);
9 __sync_add_and_fetch(&val, 1);
10 __sync_sub_and_fetch(&val, 1);
11 return 0;
12 }
13 " LLVM_MULTITHREADED)
14
15 if( NOT LLVM_MULTITHREADED )
16 message(STATUS "Warning: LLVM will be built thread-unsafe because atomic builtins are missing")
17 endif()
465465
466466 /* Installation directory for man pages */
467467 #undef LLVM_MANDIR
468
469 /* Build multithreading support into LLVM */
470 #cmakedefine LLVM_MULTITHREADED ${LLVM_MULTITHREADED}
468471
469472 /* Define if this is Unixish platform */
470473 #cmakedefine LLVM_ON_UNIX ${LLVM_ON_UNIX}