[llvm-commits] [patch] implement cmake LLVM_MULTITHREADED gcc atomic builtin checks.
Chris Lattner
clattner at apple.com
Fri Jul 17 08:54:54 PDT 2009
On Jul 17, 2009, at 1:55 AM, Xerxes RĂ„nby wrote:
> cmake builds where missing checks for the GCC atomic builtins and thus
> could not define LLVM_MULTITHREADED.
> This in turn made llvm_start_multithreaded() fail when using cmake.
>
> Ok to commit?
Seems reasonable to me, but I'm not a cmake expert :). Go for it, if
it causes problems we can back it out. Thanks!
-Chris
>
> Cheers
> Xerxes
> Index: llvm/include/llvm/Config/config.h.cmake
> ===================================================================
> --- llvm.orig/include/llvm/Config/config.h.cmake 2009-07-15
> 10:57:56.000000000 +0200
> +++ llvm/include/llvm/Config/config.h.cmake 2009-07-17
> 10:15:27.000000000 +0200
> @@ -467,6 +467,9 @@
> /* Installation directory for man pages */
> #undef LLVM_MANDIR
>
> +/* Build multithreading support into LLVM */
> +#cmakedefine LLVM_MULTITHREADED ${LLVM_MULTITHREADED}
> +
> /* Define if this is Unixish platform */
> #cmakedefine LLVM_ON_UNIX ${LLVM_ON_UNIX}
>
> Index: llvm/cmake/config-ix.cmake
> ===================================================================
> --- llvm.orig/cmake/config-ix.cmake 2009-07-02 09:43:43.000000000
> +0200
> +++ llvm/cmake/config-ix.cmake 2009-07-17 10:47:26.000000000 +0200
> @@ -76,6 +76,9 @@
> add_llvm_definitions( -D_GNU_SOURCE )
> endif()
>
> +# Define LLVM_MULTITHREADED if gcc atomic builtins exists.
> +include(CheckAtomic)
> +
> include(CheckCXXCompilerFlag)
> check_cxx_compiler_flag("-fPIC" SUPPORTS_FPIC_FLAG)
>
> Index: llvm/cmake/modules/CheckAtomic.cmake
> ===================================================================
> --- /dev/null 1970-01-01 00:00:00.000000000 +0000
> +++ llvm/cmake/modules/CheckAtomic.cmake 2009-07-17
> 10:40:28.000000000 +0200
> @@ -0,0 +1,18 @@
> +# atomic builtins are required for threading support.
> +
> +INCLUDE(CheckCXXSourceCompiles)
> +
> +CHECK_CXX_SOURCE_COMPILES("
> +int main() {
> + volatile unsigned long val = 1;
> + __sync_synchronize();
> + __sync_val_compare_and_swap(&val, 1, 0);
> + __sync_add_and_fetch(&val, 1);
> + __sync_sub_and_fetch(&val, 1);
> + return 0;
> + }
> +" LLVM_MULTITHREADED)
> +
> +if( NOT LLVM_MULTITHREADED )
> + message(STATUS "Warning: LLVM will be built thread-unsafe because
> atomic builtins are missing")
> +endif()
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list