# LibAtomic fails to safely land after failing to detect

**URL:** https://discourse.cmake.org/t/libatomic-fails-to-safely-land-after-failing-to-detect/4927
**Category:** Usage
**Tags:** gen:ninja
**Created:** [January 28, 2022, 8:28pm UTC](https://discourse.cmake.org/t/libatomic-fails-to-safely-land-after-failing-to-detect/4927 "2022-01-28T20:28:31Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![SamuraiCrow](https://discourse.cmake.org/user_avatar/discourse.cmake.org/samuraicrow/32/2774_2.png) [@SamuraiCrow](https://discourse.cmake.org/u/SamuraiCrow)
#### Post date: [January 28, 2022, 8:28pm UTC](https://discourse.cmake.org/t/libatomic-fails-to-safely-land-after-failing-to-detect/4927/1 "2022-01-28T20:28:31Z")

</div>

I get cmake/modules/CheckAtomic.cmake:59  
Host compiler appears to require libatomic, but cannot find it.

I think this is either a bug in CMake or LLVM’s Linker. I’m using the WASI-SDK from [here](https://github.com/WebAssembly/wasi-sdk).

This is while trying to cross-compile LLVM 13 for WASI using the following command line:

`cmake ../../../3rdParty/llvm-project/llvm -G "Ninja" -DWASI_SDK_PREFIX=/opt/wasi-sdk --toolchain=/opt/wasi-sdk/share/cmake/wasi-sdk.cmake -DCMAKE_C_FLAGS="--sysroot=/opt/wasi-sdk/share/wasi-sysroot -mno-atomics" -DLLVM_TARGETS_TO_BUILD= -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="WebAssembly" -DLLVM_USE_HOST_TOOLS:BOOL=ON -DCMAKE_HOST_SYSTEM_NAME="Linux" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=../../../3rdParty/llvm-wasi/debug -DCMAKE_CROSSCOMPILING_EMULATOR="wasmer" -DLLVM_INSTALL_UTILS=ON -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_PLUGINS=ON -DLLVM_ENABLE_PROJECTS="mlir" -DLLVM_ENABLE_EH=ON -DLLVM_ENABLE_RTTI=ON -DLLVM_REQUIRES_RTTI=ON -DLLVM_ENABLE_PIC=ON -DLLVM_ENABLE_THREADS=OFF `

## Edit

Cross-posted to [the LLVM Discourse](https://llvm.discourse.group/t/when-trying-to-detect-libatomic-lld-fails-to-respect-cmakes-request-to-check-existence/6126).

---

<div class="post-metadata">

### Author: ![SamuraiCrow](https://discourse.cmake.org/user_avatar/discourse.cmake.org/samuraicrow/32/2774_2.png) [@SamuraiCrow](https://discourse.cmake.org/u/SamuraiCrow)
#### Post date: [February 3, 2022, 4:05am UTC](https://discourse.cmake.org/t/libatomic-fails-to-safely-land-after-failing-to-detect/4927/2 "2022-02-03T04:05:27Z")

</div>

## Update

CMake is testing for a working libAtomic.a on a single-threaded environment using Clang. Namely target wasm32-wasi. Can someone tell me how to update the detection script to report no functioning libAtomic.a if libAtomic.a is completely absent on the architecture in question? Currently trying to test using Clang isn’t working when it links against a non-existant file.

## Edit

This is not a usage problem. I’ll make a new thread in the proper category.
