Cannot figure out how to use std::atomic error for MacOS Sequoia 15.2 #31579

issue kelvinator07 openend this issue on December 30, 2024
  1. kelvinator07 commented at 0:19 am on December 30, 2024: none

    Fails to compile when running cmake -B build -DWITH_BDB=ON Attempted the build process on two different laptops with identical specifications and encountered the same error.

    Build Output:

    0-- Performing Test STD_ATOMIC_LINKS_WITHOUT_LIBATOMIC
    1-- Performing Test STD_ATOMIC_LINKS_WITHOUT_LIBATOMIC - Failed
    2-- Performing Test STD_ATOMIC_NEEDS_LINK_TO_LIBATOMIC
    3-- Performing Test STD_ATOMIC_NEEDS_LINK_TO_LIBATOMIC - Failed
    4CMake Error at cmake/module/TestAppendRequiredLibraries.cmake:90 (message):
    5  Cannot figure out how to use std::atomic.
    6Call Stack (most recent call first):
    7  cmake/introspection.cmake:29 (test_append_atomic_library)
    8  CMakeLists.txt:391 (include)
    

    Laptop Specifications

    • OS: macOS Sequoia 15.2
    • Compiler: Apple Clang version 16.0.0 (clang-1600.0.26.6) – Target: arm64-apple-darwin24.2.0 – Thread model: posix – InstalledDir: /Library/Developer/CommandLineTools/usr/bin
  2. adyshimony commented at 11:40 pm on December 31, 2024: none

    Try this to solve the issue:

    1. brew install llvm
    2. Clean build / delete dir to clean cache
    3. cmake -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++ -B build
  3. maflcko added the label macOS on Jan 1, 2025
  4. maflcko added the label Build system on Jan 1, 2025
  5. maflcko added this to the milestone 29.0 on Jan 1, 2025
  6. maflcko removed this from the milestone 29.0 on Jan 1, 2025
  7. maflcko commented at 6:06 pm on January 1, 2025: member
  8. hebasto commented at 9:50 am on January 2, 2025: member

    @kelvinator07

    Could you provide please the CMakeFiles/CMakeConfigureLog.yaml file from your build directory?

  9. fanquake added this to the milestone 29.0 on Jan 2, 2025
  10. kelvinator07 commented at 10:38 am on January 2, 2025: none

    @adyshimony, thank you for your helpful response! I was able to resolve the issue using the following steps:

    1. Installed LLVM via Homebrew brew install llvm
    2. Clean build / delete dir to clean cache via git clean -fxd
    3. Updated the build command to use the Homebrew-installed LLVM path, and also adding the LLVM library path:
    0cmake -DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang \
    1      -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++ \
    2      -DCMAKE_EXE_LINKER_FLAGS=-L/opt/homebrew/opt/llvm/lib -B build
    

    @maflcko, for reference, my Xcode version is 16:

    0-% pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version
    1version: 16.2.0.0.1.1733547573
    

    @hebasto, thanks as well for your comment!

  11. maflcko commented at 12:05 pm on January 2, 2025: member

    version: 16.2

    Thanks. Though, I can’t reproduce in GHA (run: https://github.com/maflcko/bitcoin-core-with-ci/actions/runs/12582079644/job/35067062801#step:3:14 ). Though, I also get a different output for the clang installed dir:

    0  sudo xcode-select --switch /Applications/Xcode_16.2.app
    1  clang --version
    2
    3Apple clang version 16.0.0 (clang-1600.0.26.6)
    4Target: arm64-apple-darwin24.2.0
    5Thread model: posix
    6InstalledDir: /Applications/Xcode_16.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
    
  12. richieoscar commented at 1:57 pm on January 3, 2025: none

    @adyshimony, @kelvinator07 this solution also worked for me

       Installed LLVM via homebrew brew install llvm
       Clean build / delete dir to clean cache via git clean -fxd
       Updated the build command to use the Homebrew-installed LLVM path, and also adding the LLVM library path:
    
                cmake -DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang \
               -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++ \
               -DCMAKE_EXE_LINKER_FLAGS=-L/opt/homebrew/opt/llvm/lib -B build
    

    xcode version

    pkgutil –pkg-info=com.apple.pkg.CLTools_Executables | grep version version: 16.2.0.0.1.1733547573

    MacOs Sequoia 15.2

    gcc –version Apple clang version 14.0.0 (clang-1400.0.29.202) Target: arm64-apple-darwin24.2.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

    clang –version Homebrew clang version 19.1.6 Target: arm64-apple-darwin24.2.0 Thread model: posix InstalledDir: /opt/homebrew/Cellar/llvm/19.1.6/bin Configuration file: /opt/homebrew/etc/clang/arm64-apple-darwin24.cfg

  13. hebasto commented at 1:52 pm on February 4, 2025: member

    I cannot reproduce the issue on my MacOS Sequoia 15.2 (24C101):

    0% clang --version                             
    1Apple clang version 16.0.0 (clang-1600.0.26.6)
    2Target: arm64-apple-darwin24.2.0
    3Thread model: posix
    4InstalledDir: /Library/Developer/CommandLineTools/usr/bin
    5% cmake -B build -DWITH_BDB=ON
    6<snip>
    7-- Performing Test STD_ATOMIC_LINKS_WITHOUT_LIBATOMIC
    8-- Performing Test STD_ATOMIC_LINKS_WITHOUT_LIBATOMIC - Success
    9<snip>
    

    Can anyone else provide the exact steps to reproduce the issue along with the CMakeFiles/CMakeConfigureLog.yaml log file?

  14. egruper commented at 10:17 am on February 5, 2025: none

    I cannot reproduce the issue on my MacOS Sequoia 15.2 (24C101):

    0% clang --version                             
    1Apple clang version 16.0.0 (clang-1600.0.26.6)
    2Target: arm64-apple-darwin24.2.0
    3Thread model: posix
    4InstalledDir: /Library/Developer/CommandLineTools/usr/bin
    5% cmake -B build -DWITH_BDB=ON
    6<snip>
    7-- Performing Test STD_ATOMIC_LINKS_WITHOUT_LIBATOMIC
    8-- Performing Test STD_ATOMIC_LINKS_WITHOUT_LIBATOMIC - Success
    9<snip>
    

    Can anyone else provide the exact steps to reproduce the issue along with the CMakeFiles/CMakeConfigureLog.yaml log file?

    I can reproduce, attaching also build/CMakeFiles/CMakeConfigureLog.yaml.

    Attached file: CMakeConfigureLog.txt Note that I changed it to .txt since uploading .yaml is restricted.

    Background: I had the same issue as @kelvinator07 and solved like @adyshimony mentioned.

    Reproduced output: % cmake -B build -DWITH_BDB=ON CMake Error at cmake/module/TestAppendRequiredLibraries.cmake:90 (message): Cannot figure out how to use std::atomic. Call Stack (most recent call first): cmake/introspection.cmake:29 (test_append_atomic_library) CMakeLists.txt:391 (include)

    Reproduce steps

    1. Cloned the repo: “git clone git@github.com:bitcoin/bitcoin.git”
    2. cd to the cloned bitcoin folder.
    3. Run ‘cmake -B build -DWITH_BDB=O’ (note that it reproduced also only with ‘cmake -B build’)

    My environment % clang –version Apple clang version 16.0.0 (clang-1600.0.26.6) Target: x86_64-apple-darwin24.2.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin

    It is reproduced on my env since CMAKE_C_COMPILER and CMAKE_CXX_COMPILER flags are not persistent, and I didn’t use a persistent solution yet.

  15. hebasto commented at 12:13 pm on February 5, 2025: member

    @egruper

    I can reproduce, attaching also build/CMakeFiles/CMakeConfigureLog.yaml.

    Thank you for details provided!

    The error message in the log file states: 'atomic' file not found.

    On your system, with the command-line tools installed, the atomic header should be located in the /Library/Developer/CommandLineTools/usr/include/c++/v1 directory. If it is not, please try reinstalling the command-line tools.

    UPD. … or in /Library/Developer/CommandLineTools/SDKs/MacOSX15.2.sdk/usr/include/include/c++/v1

  16. egruper commented at 12:38 pm on February 5, 2025: none

    @hebasto

    Nice catch. I indeed didn’t have atomic under /Library/Developer/CommandLineTools/usr/include/c++/v1

    I went on to ‘rm -rf /Library/Developer/CommandLineTools’ and re-install it with ‘xcode-select –install’ (didn’t see your update so I didn’t search under SDKs…)

    Now I find atomic under: /Library/Developer/CommandLineTools/SDKs/MacOSX15.2.sdk/usr/include/c++/v1/atomic /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/include/c++/v1/atomic /Library/Developer/CommandLineTools/SDKs/MacOSX14.4.sdk/usr/include/c++/v1/atomic /Library/Developer/CommandLineTools/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/atomic

    And building with ‘cmake -B build’ works fine.

    Is this going to be logged somewhere?

  17. hebasto commented at 12:41 pm on February 5, 2025: member

    And building with ‘cmake -B build’ works fine.

    Is this going to be logged somewhere?

    In the configuration output, you can see:

    0-- Performing Test STD_ATOMIC_LINKS_WITHOUT_LIBATOMIC
    1-- Performing Test STD_ATOMIC_LINKS_WITHOUT_LIBATOMIC - Success
    

    Also you could grep for ATOMIC in the CMakeFiles/CMakeConfigureLog.yaml log file.

  18. hebasto commented at 12:43 pm on February 5, 2025: member
    I assume this issue can now be closed.
  19. maflcko added the label Upstream on Feb 5, 2025
  20. maflcko commented at 12:55 pm on February 5, 2025: member
    Closing for now, as this seemed to be an upstream issue that was fixed by a re-install.
  21. maflcko closed this on Feb 5, 2025


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-02-22 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me