Make Boost use std::atomic internally #10239

pull sipa wants to merge 1 commits into bitcoin:master from sipa:boost_std_atomic changing 1 files +4 −0
  1. sipa commented at 1:46 PM on April 20, 2017: member

    Boost has its own implementation of a spinlock and atomic counters inside its shared_ptr implementation, which is used by (at least) the signals2 implementation. By default, it prefers its own implementations over C++11 atomics.

    Add two macro definitions to make it choose the std::atomics based implementations instead.

    These macros are supported since Boost 1.56, and the behaviour is default since Boost 1.63.

  2. in configure.ac:239 in 03ea2f0194 outdated
     235 | @@ -236,7 +236,7 @@ if test "x$CXXFLAGS_overridden" = "xno"; then
     236 |    AX_CHECK_COMPILE_FLAG([-Wunused-local-typedef],[CXXFLAGS="$CXXFLAGS -Wno-unused-local-typedef"],,[[$CXXFLAG_WERROR]])
     237 |    AX_CHECK_COMPILE_FLAG([-Wdeprecated-register],[CXXFLAGS="$CXXFLAGS -Wno-deprecated-register"],,[[$CXXFLAG_WERROR]])
     238 |  fi
     239 | -CPPFLAGS="$CPPFLAGS -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS"
     240 | +CPPFLAGS="$CPPFLAGS -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS -DBOOST_SP_USE_STD_ATOMIC -DBOOST_\A\C_USE_STD_ATOMIC"
    


    laanwj commented at 1:55 PM on April 20, 2017:

    -DBOOST_\A\C_USE_STD_ATOMIC that looks strange


    sipa commented at 2:09 PM on April 20, 2017:

    Very much so, but I don't know how else to prevent autoconf from interpreting it as a macro.


    laanwj commented at 2:11 PM on April 20, 2017:

    @theuni any idea ^^?


    theuni commented at 2:34 PM on April 20, 2017:

    I think wrapping the whole line in [ ] might shut it up?


    sipa commented at 2:39 PM on April 20, 2017:

    I had tried that already:

    CPPFLAGS=["$CPPFLAGS -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS -DBOOST_SP_USE_STD_ATOMIC -DBOOST_AC_USE_STD_ATOMIC"]
    

    does not work.


    sipa commented at 2:41 PM on April 20, 2017:

    The error is:

    configure.ac:239: error: possibly undefined macro: DBOOST_AC_USE_STD_ATOMIC
          If this token and others are legitimate, please use m4_pattern_allow.
          See the Autoconf documentation.
    autoreconf: /usr/bin/autoconf failed with exit status: 1
    

    theuni commented at 3:04 PM on April 20, 2017:

    Ok, the recommended m4_pattern_allow hack works. Seems reasonable, there's no way that will ever become a macro.

    Also, please stick this in BOOST_CPPFLAGS (after the AX_BOOST_* checks) rather than in the global one:

    m4_pattern_allow(DBOOST_AC_USE_STD_ATOMIC) dnl otherwise it's treated like a macro
    BOOST_CPPFLAGS="-DBOOST_SP_USE_STD_ATOMIC -DBOOST_AC_USE_STD_ATOMIC $BOOST_CPPFLAGS"
    
  3. laanwj commented at 2:12 PM on April 20, 2017: member

    Concept ACK, I think using the same atomics everywhere (those of the compiler) is a good thing.

  4. sipa commented at 2:34 PM on April 20, 2017: member

    Apparently Boost will use std::atomic by default since 1.63 (verified by looking at the code, nothing in release notes).

  5. theuni commented at 2:36 PM on April 20, 2017: member

    Concept ACK. Are you sure these are the only two necessary?

  6. sipa commented at 2:38 PM on April 20, 2017: member

    I grepped the source code for other BOOST_*_USE things, but nothing seems relevant.

  7. Make Boost use std::atomic internally 394ccf76ad
  8. sipa force-pushed on Apr 20, 2017
  9. sipa commented at 3:10 PM on April 20, 2017: member

    Incorporated @theuni's suggestions.

  10. theuni commented at 5:25 PM on April 20, 2017: member

    Thanks. utACK 394ccf76adb016b48908cd9a0fa08a1663a7ddba

    I cloned the boost smart_ptr repo and verified that these are the only defines needed, and that there are no uses of them in any cpp files (duh, it's a header-only lib).

  11. gmaxwell approved
  12. gmaxwell commented at 7:17 PM on April 20, 2017: contributor

    utACK

  13. jonasschnelli added the label Build system on Apr 20, 2017
  14. laanwj merged this on Apr 21, 2017
  15. laanwj closed this on Apr 21, 2017

  16. laanwj referenced this in commit 0416ea9f74 on Apr 21, 2017
  17. sipa deleted the branch on Jun 23, 2017
  18. PastaPastaPasta referenced this in commit 226900b5d7 on May 21, 2019
  19. PastaPastaPasta referenced this in commit 54f5c04e7c on May 22, 2019
  20. PastaPastaPasta referenced this in commit 595e9b70b0 on May 22, 2019
  21. PastaPastaPasta referenced this in commit 05038fcde6 on May 22, 2019
  22. PastaPastaPasta referenced this in commit e9b6d919e8 on May 23, 2019
  23. PastaPastaPasta referenced this in commit 3723d8496e on May 23, 2019
  24. PastaPastaPasta referenced this in commit 257c9e5a3e on May 28, 2019
  25. PastaPastaPasta referenced this in commit 2f6079992c on May 28, 2019
  26. PastaPastaPasta referenced this in commit 3c9ecc2f33 on Jun 7, 2019
  27. PastaPastaPasta referenced this in commit 7cf74ddbc4 on Jun 8, 2019
  28. PastaPastaPasta referenced this in commit 58b1a93b73 on Jun 10, 2019
  29. barrystyle referenced this in commit 47d476066f on Jan 22, 2020
  30. DrahtBot locked this on Sep 8, 2021

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: 2026-04-19 09:15 UTC

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