btcinfo  

Hic inserere motto

Yet another musl trb build instructional

April 30, 2020 — shinohai

A recent post by DC University alumni1jfw proposed significant changes to the trb build system amongst them one that does away with the `makefile.unix` file in trb source directory. This build takes a different tack and changes next to nothing of the original structure, while still getting a statically linked bitcoind.

I started by adding a profile for my toolchain at `/etc/env.d/gcc/` and named it "x86_64-pc-linux-gnu-musl-4.9.4". Now one can switch to it any time you please using gcc-config.

# gcc-config -l
 [1] x86_64-pc-linux-gnu-7.3.0
 [2] x86_64-pc-linux-gnu-9.2.0
 [3] x86_64-pc-linux-gnu-musl-4.9.4 *
<~snip~>

I choose profile 3, ensuring we use the correct toolchain.

# gcc -v
gcc version 4.9.4 20160426 (for GNAT GPL 2016 20160515) (GCC)

Press trb in the same way as described on existing foundation "how-to" page, then proceed to the build directory:

v press mod6_whogaveblox trb054`
`cd trb054/bitcoin/build`

Build the 3 main trb dependencies (listed as #Turds! in rotor ), much as Jacob described in his article, and installed them to the `./ourlibs` directory. I also host my own mirror the dependency artifacts on deebot here so I grabbed the necessary items:

boost_1_52_0.tar.bz2

openssl-1.0.1g.tar.gz

db-4.8.30.tar.gz

In this directory I also put a modified version of the "rotor_bitcoin_only" script called `build.sh` that absolutely, positively *does not remove* makefile.unix. It contains:

#!/bin/sh

######################################
#Turds!
OPENSSL=openssl-1.0.1g
BDB=db-4.8.30
BOOST=boost_1_52_0
######################################
TOOLCHAIN="/usr/local/x86_64-linux-musl/"
DIST=$(readlink -f ./distfiles)
OURLIBS=$(readlink -f ./ourlibs)

#TOOLCHAIN
export CC=$(readlink -f $TOOLCHAIN/bin/x86_64-linux-musl-gcc)
export CXX=$(readlink -f $TOOLCHAIN/bin/x86_64-linux-musl-g++)
export LD=$(readlink -f $TOOLCHAIN/bin/x86_64-linux-musl-ld)

export CFLAGS=-I$(readlink -f $TOOLCHAIN/usr/include)
export LDFLAGS=-L$(readlink -f .$TOOLCHAIN/usr/lib)
export PATH=$PATH:$(readlink -f $TOOLCHAIN/usr/bin)

#LIBS
export OPENSSL_INCLUDE_PATH=$OURLIBS/include
export OPENSSL_LIB_PATH=$OURLIBS/lib

export BDB_INCLUDE_PATH=$OURLIBS/include
export BDB_LIB_PATH=$OURLIBS/lib

export BOOST_INCLUDE_PATH=$OURLIBS/include
export BOOST_LIB_PATH=$OURLIBS/lib

cd ../src;
make STATIC=all -f makefile.unix bitcoind
strip bitcoind
mv bitcoind ../bin

Now run `./build.sh The output for me is a 5M statically linked trb. It took about ten minutes for me to build.

bitcoin/bin # file bitcoind
bitcoind: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped

bitcoin/bin # echo "Size: $(du -h bitcoind)-$(ldd bitcoind)"
Size: 5.0M	bitcoind-	not a dynamic executable

I am pleased with the results as they are on this one. Aside from the benefit of losing the tedious buildroot process, I'm choosing not to change much right now here and leave trb the fuck alone.2


1. Or inmate of the штрафбат, depending on whether you choose to interpret the initials "DC" as "Department of Corrections" or not.

2. Though experiments with jfw's other trb patches have been useful.

Tags: News, Bitcoin, Gentoo, UNIX