build: improve __builtin_clz* detection #19403

pull fanquake wants to merge 1 commits into bitcoin:master from fanquake:improve_builtin_clz_detection changing 3 files +17 −15
  1. fanquake commented at 3:44 AM on June 29, 2020: member

    Fixes #19402.

    The way we currently test for __builtin_clz* support with AC_CHECK_DECLS does not work with Clang:

    configure:21492: clang++-10 -std=c++11 -c -g -O2  -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS conftest.cpp >&5
    conftest.cpp:100:10: error: builtin functions must be directly called
      (void) __builtin_clz;
             ^
    1 error generated.
    

    This also removes the __builtin_clz() check, as we don't actually use it anywhere, and it's trvial to re-add detection if we do start using it at some point. If this is controversial then I'll add a test for it as well.

  2. build: improve builtin_clz* detection
    The way we currently test with AC_CHECK_DECLS do not work with Clang:
    ```bash
    configure:21492: clang++-10 -std=c++11 -c -g -O2  -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS conftest.cpp >&5
    conftest.cpp:100:10: error: builtin functions must be directly called
      (void) __builtin_clz;
             ^
    1 error generated.
    ```
    
    This also removes the __builtin_clz() check, as we don't actually use
    it anywhere, and it's trvial to re-add detection if we do start using
    it at some point.
    9952242c03
  3. fanquake added the label Build system on Jun 29, 2020
  4. in build_msvc/bitcoin_config.h:142 in 9952242c03
     136 | @@ -137,18 +137,6 @@
     137 |     don't. */
     138 |  #define HAVE_DECL_STRNLEN 1
     139 |  
     140 | -/* Define to 1 if you have the declaration of `__builtin_clz', and to 0 if you
     141 | -   don't. */
     142 | -//#define HAVE_DECL___BUILTIN_CLZ 1
    


    sipa commented at 3:59 AM on June 29, 2020:

    These were 1; should they be replaced with the corresponding true define? I'm a bit surprised MSVC has the exact same builtins though.


    fanquake commented at 4:02 AM on June 29, 2020:

    They were 1, but commented out. I think they were only in here because build_msvc/bitcoin_config.h began as a copy-paste job from src/config/bitcoin-config.h. MSVC doesn't have any of these builtins.


    sipa commented at 5:59 AM on June 29, 2020:

    That makes more sense, thanks.

  5. sipa commented at 5:59 AM on June 29, 2020: member

    ACK 9952242c03fe587b5dff46a9f770e319146103bf

  6. laanwj commented at 1:45 PM on June 29, 2020: member

    ACK 9952242c03fe587b5dff46a9f770e319146103bf

  7. laanwj merged this on Jun 29, 2020
  8. laanwj closed this on Jun 29, 2020

  9. fanquake deleted the branch on Jun 29, 2020
  10. luke-jr referenced this in commit ea7821cf39 on Aug 15, 2020
  11. PastaPastaPasta referenced this in commit bebd4fd58c on Jun 27, 2021
  12. PastaPastaPasta referenced this in commit afa2a6a543 on Jun 28, 2021
  13. PastaPastaPasta referenced this in commit 0415ad7ab0 on Jun 29, 2021
  14. DrahtBot locked this on Feb 15, 2022

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 12:14 UTC

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