Compiling fails on 32-bit systems #22889

issue hebasto openend 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:

    0bench/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]
    1    const size_t addrman_count{bench.epochs() * bench.epochIterations()};
    2                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    3bench/addrman.cpp:113:32: note: insert an explicit cast to silence this issue
    4    const size_t addrman_count{bench.epochs() * bench.epochIterations()};
    5                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    6                               static_cast<size_t>(                    )
    71 error generated.
    8make[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:

     0$ CONFIG_SITE="$PWD/depends/i686-pc-linux-gnu/share/config.site" ./configure CC="clang -m32" CXX="clang++ -m32"
     1$ make V=1
     2Making all in src
     3make[1]: Entering directory '/bitcoin-core/src'
     4make[2]: Entering directory '/bitcoin-core/src'
     5make[3]: Entering directory '/bitcoin-core'
     6make[3]: Leaving directory '/bitcoin-core'
     7/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
     8bench/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]
     9    const size_t addrman_count{bench.epochs() * bench.epochIterations()};
    10                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    11bench/addrman.cpp:113:32: note: insert an explicit cast to silence this issue
    12    const size_t addrman_count{bench.epochs() * bench.epochIterations()};
    13                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    14                               static_cast<size_t>(                    )
    151 error generated.
    
  8. MarcoFalke commented at 1:21 pm on September 8, 2021: member

    The following diff fixes it:

     0diff --git a/src/bench/addrman.cpp b/src/bench/addrman.cpp
     1index 8fbb68c04..17f54428e 100644
     2--- a/src/bench/addrman.cpp
     3+++ b/src/bench/addrman.cpp
     4@@ -6,6 +6,7 @@
     5 #include <bench/bench.h>
     6 #include <random.h>
     7 #include <util/time.h>
     8+#include <util/check.h>
     9 
    10 #include <optional>
    11 #include <vector>
    12@@ -110,7 +111,8 @@ static void AddrManGood(benchmark::Bench& bench)
    13      * we want to do the same amount of work in every loop iteration. */
    14 
    15     bench.epochs(5).epochIterations(1);
    16-    const size_t addrman_count{bench.epochs() * bench.epochIterations()};
    17+    const uint64_t addrman_count{bench.epochs() * bench.epochIterations()};
    18+    Assert(addrman_count==5);
    19 
    20     std::vector<std::unique_ptr<CAddrMan>> addrmans(addrman_count);
    21     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: 2025-01-21 12:12 UTC

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