Bitcoin Forum
November 15, 2024, 04:05:48 AM *
News: Check out the artwork 1Dq created to commemorate this forum's 15th anniversary
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: When compiling bitcoind the binary doubles in size between 26.2 and 27.0  (Read 123 times)
reverse-hash (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 5


View Profile
August 09, 2024, 10:37:33 PM
Merited by ABCbits (1)
 #1

Hello, people,

I am asking for your help in case any of you could give me some suggestions. I have my own node working with docker and I try to keep the daemon as light as possible.

The compilation process is exactly the same for both versions, I just change the bitcoin repository version tag.

Do you know what could be the reason? You can find a link to the complete dockerfile at the end of the post.

Thanks a lot

Code:
  make HOST=$(gcc -dumpmachine) NO_QT=1 NO_ZMQ=1 NO_WALLET=1 NO_BDB=1 NO_SQLITE=1 \
  && ./autogen.sh \
  && ./configure \
    --prefix=$PWD/depends/$(gcc -dumpmachine) LDFLAGS="-static-libstdc++" \
    --disable-bench \
    --disable-cli \
    --disable-debug \
    --disable-man \
    --disable-tests \
    --disable-upnp \
    --disable-wallet \
    --disable-zmq \
    --with-qrencode=no \
    --enable-fuzz-binary=no \
    --enable-strip \
    --without-gui \
    --without-bdb \
    --with-sqlite=no \   
  && make \

Code:
REPOSITORY       TAG           IMAGE ID       CREATED         SIZE
bitcoind         27.1          7a14ec692f8c   2 days ago      149MB
bitcoind         26.2          6fc0c7867196   4 days ago      80.1MB


https://raw.githubusercontent.com/reverse-hash/bitcoin-full-node-with-docker/main/bitcoind/Dockerfile
reverse-hash (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 5


View Profile
August 14, 2024, 11:16:06 PM
Merited by ABCbits (3), nc50lc (1)
 #2

I found the solution. I share it just in case it can be useful for someone.

In the LDFLAGS , just add the option "-s" or "--strip-all". Example: LDFLAGS="-static-libstdc++ -s"

According to GNU linker (ld) documentation:

Code:
-s
--strip-all
    Omit all symbol information from the output file.

In summary, symbol information is essential during development and debugging, but for a final product, especially if we're looking to optimize size, it can be removed without affecting the functionality of the executable.
NotATether
Legendary
*
Offline Offline

Activity: 1792
Merit: 7382


Top Crypto Casino


View Profile WWW
August 15, 2024, 08:42:03 AM
 #3

In summary, symbol information is essential during development and debugging, but for a final product, especially if we're looking to optimize size, it can be removed without affecting the functionality of the executable.

That makes sense, since the symbols are the only way I can think of that make a binary with otherwise a few changes grow really large in size.

Is it possible that the build steps are running with the -g flag somewhere inside the configure script or the automake file? Because Bitcoin Core3 is not supposed to be including debug info by default.

███████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████

███████████████████████
.
BC.GAME
▄▄▀▀▀▀▀▀▀▄▄
▄▀▀░▄██▀░▀██▄░▀▀▄
▄▀░▐▀▄░▀░░▀░░▀░▄▀▌░▀▄
▄▀▄█▐░▀▄▀▀▀▀▀▄▀░▌█▄▀▄
▄▀░▀░░█░▄███████▄░█░░▀░▀▄
█░█░▀░█████████████░▀░█░█
█░██░▀█▀▀█▄▄█▀▀█▀░██░█
█░█▀██░█▀▀██▀▀█░██▀█░█
▀▄▀██░░░▀▀▄▌▐▄▀▀░░░██▀▄▀
▀▄▀██░░▄░▀▄█▄▀░▄░░██▀▄▀
▀▄░▀█░▄▄▄░▀░▄▄▄░█▀░▄▀
▀▄▄▀▀███▄███▀▀▄▄▀
██████▄▄▄▄▄▄▄██████
.
..CASINO....SPORTS....RACING..


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
reverse-hash (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 5


View Profile
August 16, 2024, 06:48:39 PM
 #4

In summary, symbol information is essential during development and debugging, but for a final product, especially if we're looking to optimize size, it can be removed without affecting the functionality of the executable.

That makes sense, since the symbols are the only way I can think of that make a binary with otherwise a few changes grow really large in size.

Is it possible that the build steps are running with the -g flag somewhere inside the configure script or the automake file? Because Bitcoin Core3 is not supposed to be including debug info by default.

Thank you. After reviewing again the documentation I found the key:

Code:
Alternatively, or in addition, debugging information can be skipped for compilation. The default compile flags are -g -O2, and can be changed with: ./configure CXXFLAGS="-g0"
Doc: https://github.com/bitcoin/bitcoin/blob/43740f4971f45cd5499470b6a085b3ecd8b96d28/doc/build-unix.md

Not sure why, but -g is there by default :/.
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3542
Merit: 6886


Just writing some code


View Profile WWW
August 17, 2024, 04:46:45 PM
Merited by ABCbits (2)
 #5

--disable-debug is slightly misleading. It doesn't disable the inclusion of the debug symbols; rather it disables optimizations that make debugging very difficult.

Unless you override CFLAGS and/or CXXFLAGS, the debug symbols will always be included. For releases, we run strip on the result to produce a release binary with no debug symbols, and a separate file containing the debug symbols.

This is all likely to change very soon anyways as we switch to using cmake.

reverse-hash (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 5


View Profile
August 25, 2024, 04:13:54 PM
 #6

--disable-debug is slightly misleading. It doesn't disable the inclusion of the debug symbols; rather it disables optimizations that make debugging very difficult.

Unless you override CFLAGS and/or CXXFLAGS, the debug symbols will always be included. For releases, we run strip on the result to produce a release binary with no debug symbols, and a separate file containing the debug symbols.

This is all likely to change very soon anyways as we switch to using cmake.

Thanks a lot achow101. All clear now.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!