• Mohamed Bassem's avatar
    Update the CheckAtomic CMake module to check for __atomic_fetch_add_4 instead... · 99c5b866
    Mohamed Bassem authored
    Update the CheckAtomic CMake module to check for __atomic_fetch_add_4 instead of __atomic_is_lock_free
    
    Summary:
    When building with clang, the build fails with:
    
    ```
    -- Looking for __atomic_is_lock_free in atomic
    -- Looking for __atomic_is_lock_free in atomic - not found
    CMake Error at cmake/CheckAtomic.cmake:90 (message):
      Host compiler appears to require libatomic, but cannot find it.
    Call Stack (most recent call first):
      CMakeLists.txt:75 (include)
    ```
    
    And the error is:
    
    ```
    /usr/share/cmake-3.10/Modules/CheckFunctionExists.c:7:3: error: conflicting types for '__atomic_is_lock_free'
      CHECK_FUNCTION_EXISTS(void);
      ^
    <command line>:1:31: note: expanded from here
    #define CHECK_FUNCTION_EXISTS __atomic_is_lock_free
                                  ^
    /usr/share/cmake-3.10/Modules/CheckFunctionExists.c:7:3: note: '__atomic_is_lock_free' is a builtin with type 'int (unsigned long, const volatile void *)'
    <command line>:1:31: note: expanded from here
    #define CHECK_FUNCTION_EXISTS __atomic_is_lock_free
                                  ^
    /usr/share/cmake-3.10/Modules/CheckFunctionExists.c:17:25: error: too few arguments to function call, expected 2, have 0
      CHECK_FUNCTION_EXISTS();
      ~~~~~~~~~~~~~~~~~~~~~ ^
    ```
    
    LLVM's CheckAtomic (https://fburl.com/bk14shjt) uses `__atomic_fetch_add_4` so I'm modifying the configs to use it as well to check for the existence of the library.
    
    Reviewed By: yfeldblum
    
    Differential Revision: D19497168
    
    fbshipit-source-id: 64f77487efd16dba49055f6c4cb1cdd0fc4ae6da
    99c5b866
CheckAtomic.cmake 3.64 KB