Skip to content
This repository has been archived by the owner on Feb 1, 2021. It is now read-only.

Commit

Permalink
gitian build on docker in ubuntu18 container
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg-Griffith committed Apr 26, 2019
1 parent 5ac724a commit 7efc357
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 136 deletions.
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,9 @@ if test x$use_glibc_compat != xno; then
[ fdelt_type="long int"])
AC_MSG_RESULT($fdelt_type)
AC_DEFINE_UNQUOTED(FDELT_TYPE, $fdelt_type,[parameter and return value type for __fdelt_chk])
AX_CHECK_LINK_FLAG([[-Wl,--wrap=__divmoddi4]], [COMPAT_LDFLAGS="$COMPAT_LDFLAGS -Wl,--wrap=__divmoddi4"])
AX_CHECK_LINK_FLAG([[-Wl,--wrap=log2f]], [COMPAT_LDFLAGS="$COMPAT_LDFLAGS -Wl,--wrap=log2f"])
AX_CHECK_LINK_FLAG([[-Wl,--wrap=logf]], [COMPAT_LDFLAGS="$COMPAT_LDFLAGS -Wl,--wrap=logf"])
else
AC_SEARCH_LIBS([clock_gettime],[rt])
fi
Expand Down
14 changes: 7 additions & 7 deletions contrib/gitian-descriptors/gitian-arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
name: "eccoin-linux-0.2.5.12"
enable_cache: true
suites:
- "trusty"
- "bionic"
architectures:
- "amd64"
packages:
- "curl"
- "g++-aarch64-linux-gnu"
- "g++-4.8-aarch64-linux-gnu"
- "gcc-4.8-aarch64-linux-gnu"
- "g++-7-aarch64-linux-gnu"
- "gcc-7-aarch64-linux-gnu"
- "binutils-aarch64-linux-gnu"
- "g++-arm-linux-gnueabihf"
- "g++-4.8-arm-linux-gnueabihf"
- "gcc-4.8-arm-linux-gnueabihf"
- "g++-7-arm-linux-gnueabihf"
- "gcc-7-arm-linux-gnueabihf"
- "binutils-arm-linux-gnueabihf"
- "g++-4.8-multilib"
- "gcc-4.8-multilib"
- "g++-7-multilib"
- "gcc-7-multilib"
- "binutils-gold"
- "git-core"
- "pkg-config"
Expand Down
8 changes: 4 additions & 4 deletions contrib/gitian-descriptors/gitian-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
name: "eccoin-linux-0.2.5.12"
enable_cache: true
suites:
- "trusty"
- "bionic"
architectures:
- "amd64"
packages:
- "curl"
- "binutils"
- "g++-4.8-multilib"
- "gcc-4.8-multilib"
- "g++-7-multilib"
- "gcc-7-multilib"
- "binutils-gold"
- "git-core"
- "git"
- "pkg-config"
- "autoconf"
- "libtool"
Expand Down
4 changes: 2 additions & 2 deletions contrib/gitian-descriptors/gitian-osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
name: "eccoin-osx-0.2.5.12"
enable_cache: true
suites:
- "trusty"
- "bionic"
architectures:
- "amd64"
packages:
- "curl"
- "g++"
- "git-core"
- "git"
- "pkg-config"
- "autoconf"
- "librsvg2-bin"
Expand Down
11 changes: 6 additions & 5 deletions contrib/gitian-descriptors/gitian-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
name: "eccoin-win-0.2.5.12"
enable_cache: true
suites:
- "trusty"
- "bionic"
architectures:
- "amd64"
packages:
- "curl"
- "g++"
- "git-core"
- "git"
- "pkg-config"
- "autoconf"
- "libtool"
Expand All @@ -21,6 +21,7 @@ packages:
- "zip"
- "ca-certificates"
- "python"
- "rename"
reference_datetime: "2018-10-12 00:00:00"
remotes:
- "url": "https://github.com/project-ecc/eccoin.git"
Expand All @@ -29,8 +30,8 @@ files: []
script: |
WRAP_DIR=$HOME/wrapped
HOSTS="x86_64-w64-mingw32 i686-w64-mingw32"
CONFIGFLAGS="--enable-reduce-exports --disable-gui-tests"
FAKETIME_HOST_PROGS="g++ ar ranlib nm windres strip"
CONFIGFLAGS="--enable-reduce-exports --disable-bench --disable-gui-tests"
FAKETIME_HOST_PROGS="ar ranlib nm windres strip"
FAKETIME_PROGS="date makensis zip"
export QT_RCC_TEST=1
Expand Down Expand Up @@ -81,7 +82,7 @@ script: |
done
for prog in gcc g++; do
echo '#!/bin/bash' > ${WRAP_DIR}/${i}-${prog}
echo "REAL=\`which -a ${i}-${prog} | grep -v ${WRAP_DIR}/${i}-${prog} | head -1\`" >> ${WRAP_DIR}/${i}-${prog}
echo "REAL=\`which -a ${i}-${prog}-posix | grep -v ${WRAP_DIR}/${i}-${prog} | head -1\`" >> ${WRAP_DIR}/${i}-${prog}
echo 'export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1' >> ${WRAP_DIR}/${i}-${prog}
echo "export FAKETIME=\"${REFERENCE_DATETIME}\"" >> ${WRAP_DIR}/${i}-${prog}
echo "export COMPILER_PATH=${WRAP_DIR}/${i}" >> ${WRAP_DIR}/${i}-${prog}
Expand Down
2 changes: 1 addition & 1 deletion depends/packages/bdb.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ define $(package)_set_vars
$(package)_config_opts=--disable-shared --enable-cxx --disable-replication
$(package)_config_opts_mingw32=--enable-mingw
$(package)_config_opts_linux=--with-pic
$(package)_cxxflags=-std=c++11
$(package)_cxxflags=-std=c++14
endef

define $(package)_preprocess_cmds
Expand Down
2 changes: 1 addition & 1 deletion depends/packages/boost.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $(package)_archiver_$(host_os)=$($(package)_ar)
$(package)_toolset_darwin=darwin
$(package)_archiver_darwin=$($(package)_libtool)
$(package)_config_libraries=chrono,filesystem,program_options,system,thread,test
$(package)_cxxflags=-std=c++11 -fvisibility=hidden
$(package)_cxxflags=-std=c++14 -fvisibility=hidden
$(package)_cxxflags_linux=-fPIC
endef

Expand Down
120 changes: 23 additions & 97 deletions doc/gitian-building.md
Original file line number Diff line number Diff line change
@@ -1,109 +1,35 @@
# Building Eccoin with Gitian
Gitian build
============

Note: These instructions were created on a machine that natively ran Ubuntu 16.04.5 (Xenial). No virtualization was used.
This is guide take for granted that you are using Ubuntu bionic 18.04 as host OS. the aim of the document is to be able to produce deterministic binaries using gitian-tools and docker containers.

## Verify hardware compatability
Verify that your machine has the hardware virtualizations extensions to build

#### For intel the following command should give you a list of flags
Prerequisite
-------------

`grep -e 'vmx' /proc/cpuinfo`
These are steps that as to be executed once and that don't need to be repeated for every new gitian build process.

#### For amd the following command should give you a list of flags

`grep -e 'svm' /proc/cpuinfo`

If there is no output make sure that virtualization extensions is enabled in BIOS.
Verify that KVM modules are loaded in the kernel.
It should be loaded by default. Verify this using
`lsmod | grep kvm`. You should get some output.

Running `modprobe kvm` might also help

## Install dependencies

`apt-get install software-properties-common`

`add-apt-repository ppa:bitcoin/bitcoin`

`apt-get update`

```
apt-get install git ruby sudo apt-cacher-ng qemu-utils debootstrap lxc python-cheetah parted kpartx bridge-utils make curl build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils python3 libboost-all-dev libdb4.8-dev libdb4.8++-dev libminiupnpc-dev libzmq3-dev python-vm-builder apache2 apt-cacher-ng python-vm-builder qemu
```

git clone https://github.com/project-ecc/eccoin ~/eccoin

checkout the branch of eccoin you plan on building

git clone https://github.com/project-ecc/ecc-gitian-builder ~/ecc-gitian-builder

mkdir ~/ecc-releases
mkdir ~/gitian.sigs

## Setup Gitian and build

#### Setup Gitian descriptors

```
export SIGNER=(your Gitian key, ie bluematt, sipa, etc)
export VERSION=(version)
export TAG=(tag or commit hash you want to build)
export ECC_PATH=~/eccoin
export RELEASE_DIR=~/ecc-releases/${VERSION}
```

#### Make the base gitian image

Eccoin builds on an Ubuntu trusty VM, create that base vm image by doing the following:
```
cd ecc-gitian-builder
./bin/make-base-vm --arch amd64 --suite trusty
```bash
sudo apt install git apt-cacher-ng ruby docker.io
sudo usermod -a -G docker $USER
exec su -l $USER #make effective the usermod command
cd ~/src
git clone https://github.com/BitcoinUnlimited/BitcoinUnlimited.git
git clone https://github.com/devrandom/gitian-builder.git
cd gitian-builder
bin/make-base-vm --suite bionic --arch amd64 --docker
```

If you get an error code here it is due to an issue with python. To fix it find the file
Build the binaries
------------------

`/usr/lib/python2.7/dist-packages/VMBuilder/plugins/ubuntu/dapper.py`
These are the commands to actually roduce the executable:

Find the line:
```
self.run_in_target('apt-get', '-y', '--force-yes', 'dist-upgrade',
```
and replace it with:
```
self.run_in_target('apt-get', '-y', '--force-yes', '--option=Dpkg::Options::=--force-confnew', 'dist-upgrade',
```

The full explaination of the fix can be found here: https://bugs.launchpad.net/vmbuilder/+bug/1659952

#### Perform the Build

The formula for making a build is
```
./bin/gbuild --url eccoin=${ECC_PATH} --commit eccoin=${TAG} ${ECC_PATH}/contrib/gitian-descriptors/(descriptor file)
```

For example if I wanted to build windows binaries:
```
./bin/gbuild --url eccoin=${ECC_PATH} --commit eccoin=${TAG} ${ECC_PATH}/contrib/gitian-descriptors/gitian-win.yml
```bash
cd ~/src/gitian-builder
export USE_DOCKER=1
bin/gbuild -j 4 -m 10000 --url bitcoin=https://github.com/BitcoinUnlimited/BitcoinUnlimited.git --commit bitcoin=dev ../BitcoinUnlimited/contrib/gitian-descriptors/gitian-linux.yml
```

#### Signing
Your binaries will be ready to be used in `build/out/` folder.

Linux Signing

```
./bin/gsign --signer $SIGNER --release ${VERSION}-linux --destination ~/gitian.sigs/ ${ECC_PATH}/contrib/gitian-descriptors/gitian-linux.yml
```

Windows Signing

```
./bin/gsign --signer $SIGNER --release ${VERSION}-win-unsigned --destination ~/gitian.sigs/ ${ECC_PATH}/contrib/gitian-descriptors/gitian-win.yml
```

MacOS Signing

```
./bin/gsign --signer $SIGNER --release ${VERSION}-osx-unsigned --destination ~/gitian.sigs/ ${ECC_PATH}/contrib/gitian-descriptors/gitian-osx.yml
```
76 changes: 57 additions & 19 deletions src/compat/glibc_compat.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
/*
* This file is part of the Eccoin project
* Copyright (c) 2009-2010 Satoshi Nakamoto
* Copyright (c) 2009-2016 The Bitcoin Core developers
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Copyright (c) 2015-2018 The Bitcoin Unlimited developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#if defined(HAVE_CONFIG_H)
#include "config/bitcoin-config.h"
#endif

#include <cstddef>
#include <cstdint>

#if defined(HAVE_SYS_SELECT_H)
#include <sys/select.h>
Expand All @@ -26,7 +17,6 @@
// Prior to GLIBC_2.14, memcpy was aliased to memmove.
extern "C" void *memmove(void *a, const void *b, size_t c);
extern "C" void *memcpy(void *a, const void *b, size_t c) { return memmove(a, b, c); }
#if defined(HAVE_SYS_SELECT_H)
extern "C" void __chk_fail(void) __attribute__((__noreturn__));
extern "C" FDELT_TYPE __fdelt_warn(FDELT_TYPE a)
{
Expand All @@ -35,4 +25,52 @@ extern "C" FDELT_TYPE __fdelt_warn(FDELT_TYPE a)
return a / __NFDBITS;
}
extern "C" FDELT_TYPE __fdelt_chk(FDELT_TYPE) __attribute__((weak, alias("__fdelt_warn")));

#if defined(__i386__) || defined(__arm__)

extern "C" int64_t __udivmoddi4(uint64_t u, uint64_t v, uint64_t *rp);

extern "C" int64_t __wrap___divmoddi4(int64_t u, int64_t v, int64_t *rp)
{
int32_t c1 = 0, c2 = 0;
int64_t uu = u, vv = v;
int64_t w;
int64_t r;

if (uu < 0)
{
c1 = ~c1, c2 = ~c2, uu = -uu;
}
if (vv < 0)
{
c1 = ~c1, vv = -vv;
}

w = __udivmoddi4(uu, vv, (uint64_t *)&r);
if (c1)
w = -w;
if (c2)
r = -r;

*rp = r;
return w;
}
#endif

extern "C" float logf_old(float x);
extern "C" float log2f_old(float x);
#ifdef __i386__
__asm(".symver logf_old,logf@GLIBC_2.0");
__asm(".symver log2f_old,log2f@GLIBC_2.1");
#elif defined(__amd64__)
__asm(".symver logf_old,logf@GLIBC_2.2.5");
__asm(".symver log2f_old,log2f@GLIBC_2.2.5");
#elif defined(__arm__)
__asm(".symver logf_old,logf@GLIBC_2.4");
__asm(".symver log2f_old,log2f@GLIBC_2.4");
#elif defined(__aarch64__)
__asm(".symver logf_old,logf@GLIBC_2.17");
__asm(".symver log2f_old,log2f@GLIBC_2.17");
#endif
extern "C" float __wrap_logf(float x) { return logf_old(x); }
extern "C" float __wrap_log2f(float x) { return log2f_old(x); }

0 comments on commit 7efc357

Please sign in to comment.