Compiling fails on 32-bit systems #22889

issue hebasto opened this issue on September 4, 2021
  1. hebasto commented at 1:31 PM on September 4, 2021: member

    Since #20233 compiling with clang 10.0 fails:

    bench/addrman.cpp:113:32: error: non-constant-expression cannot be narrowed from type 'unsigned long long' to 'size_t' (aka 'unsigned int') in initializer list [-Wc++11-narrowing]
        const size_t addrman_count{bench.epochs() * bench.epochIterations()};
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    bench/addrman.cpp:113:32: note: insert an explicit cast to silence this issue
        const size_t addrman_count{bench.epochs() * bench.epochIterations()};
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                   static_cast<size_t>(                    )
    1 error generated.
    make[2]: *** [Makefile:12508: bench/bench_bitcoin-addrman.o] Error 1
    
  2. hebasto added the label Bug on Sep 4, 2021
  3. hebasto commented at 1:32 PM on September 4, 2021: member
  4. MarcoFalke commented at 12:44 PM on September 8, 2021: member

    @hebasto What are the steps to reproduce?

  5. hebasto commented at 12:46 PM on September 8, 2021: member

    Just to compile with all defaults on 32-bit hardware.

    On Wed, 8 Sep 2021 at 15:44, MarcoFalke @.***> wrote:

    @hebasto https://github.com/hebasto What are the steps to reproduce?

    — You are receiving this because you were mentioned.

    Reply to this email directly, view it on GitHub https://github.com/bitcoin/bitcoin/issues/22889#issuecomment-915206135, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH3PXPSHIRNOON4Q2LQELA3UA5LDLANCNFSM5DNJRTHQ .

    --

    -- Hennadii Stepanov

  6. kristapsk commented at 12:58 PM on September 8, 2021: contributor

    I think the Bitcoin software can safely drop support for 32-bit systems.

    A lot of people run nodes on Raspberry Pi's, which are nowadays 64-bit boards, but default OS (Raspbian) is still 32-bit.

  7. MarcoFalke commented at 1:13 PM on September 8, 2021: member

    I can reproduce on 64-bit via:

    $ CONFIG_SITE="$PWD/depends/i686-pc-linux-gnu/share/config.site" ./configure CC="clang -m32" CXX="clang++ -m32"
    $ make V=1
    Making all in src
    make[1]: Entering directory '/bitcoin-core/src'
    make[2]: Entering directory '/bitcoin-core/src'
    make[3]: Entering directory '/bitcoin-core'
    make[3]: Leaving directory '/bitcoin-core'
    /usr/bin/ccache clang++ -m32 -std=c++17 -DHAVE_CONFIG_H -I. -I../src/config  -fmacro-prefix-map=/bitcoin-core/src=. -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -I. -I./secp256k1/include  -I/bitcoin-core/depends/i686-pc-linux-gnu/include -I./leveldb/include -I./leveldb/helpers/memenv -I./univalue/include -I/bitcoin-core/depends/i686-pc-linux-gnu/include -pthread -I/bitcoin-core/depends/i686-pc-linux-gnu/include -I./bench/ -I/bitcoin-core/depends/i686-pc-linux-gnu/include/  -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS -D_FILE_OFFSET_BITS=64 -DPROVIDE_FUZZ_MAIN_FUNCTION -fdebug-prefix-map=/bitcoin-core/src=. -Wstack-protector -fstack-protector-all -fcf-protection=full      -fPIE -pipe -O2  -MT bench/bench_bitcoin-addrman.o -MD -MP -MF bench/.deps/bench_bitcoin-addrman.Tpo -c -o bench/bench_bitcoin-addrman.o `test -f 'bench/addrman.cpp' || echo './'`bench/addrman.cpp
    bench/addrman.cpp:113:32: error: non-constant-expression cannot be narrowed from type 'unsigned long long' to 'size_t' (aka 'unsigned int') in initializer list [-Wc++11-narrowing]
        const size_t addrman_count{bench.epochs() * bench.epochIterations()};
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    bench/addrman.cpp:113:32: note: insert an explicit cast to silence this issue
        const size_t addrman_count{bench.epochs() * bench.epochIterations()};
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                   static_cast<size_t>(                    )
    1 error generated.
    
  8. MarcoFalke commented at 1:21 PM on September 8, 2021: member

    The following diff fixes it:

    diff --git a/src/bench/addrman.cpp b/src/bench/addrman.cpp
    index 8fbb68c04..17f54428e 100644
    --- a/src/bench/addrman.cpp
    +++ b/src/bench/addrman.cpp
    @@ -6,6 +6,7 @@
     #include <bench/bench.h>
     #include <random.h>
     #include <util/time.h>
    +#include <util/check.h>
     
     #include <optional>
     #include <vector>
    @@ -110,7 +111,8 @@ static void AddrManGood(benchmark::Bench& bench)
          * we want to do the same amount of work in every loop iteration. */
     
         bench.epochs(5).epochIterations(1);
    -    const size_t addrman_count{bench.epochs() * bench.epochIterations()};
    +    const uint64_t addrman_count{bench.epochs() * bench.epochIterations()};
    +    Assert(addrman_count==5);
     
         std::vector<std::unique_ptr<CAddrMan>> addrmans(addrman_count);
         for (size_t i{0}; i < addrman_count; ++i) {
    
  9. hebasto commented at 1:22 PM on September 8, 2021: member

    @bitcoin-public-domain

    I wonder on what device you trying to compile the Bitcoin software.

    ODROID-HC1

  10. jonatack commented at 1:25 PM on September 8, 2021: member

    Seems similar to #22464?

  11. hebasto commented at 1:52 PM on September 8, 2021: member

    Seems similar to #22464?

    My concerns are about the "32-bit + dash [gui] [CentOS 8]" task on Cirrus CI which fails to catch both #22459 and this one.

  12. MarcoFalke commented at 1:55 PM on September 8, 2021: member

    That one isn't using clang

  13. hebasto commented at 1:57 PM on September 8, 2021: member

    That one isn't using clang

    #22459 was caught with GCC 8.3.0.

  14. MarcoFalke commented at 5:09 PM on September 8, 2021: member
  15. laanwj closed this on Sep 9, 2021

  16. DrahtBot locked this on Oct 30, 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-24 21:14 UTC

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