#!/bin/bash

set -e

if [ -z "$ABC_BUILD_NAME" ]; then
  echo "Error: Environment variable ABC_BUILD_NAME must be set"
  exit 1
fi

echo "Running build configuration '${ABC_BUILD_NAME}'..."

TOPLEVEL=`git rev-parse --show-toplevel`
cd "${TOPLEVEL}/contrib/teamcity"

case "$ABC_BUILD_NAME" in
  build-asan)
    export CONFIGURE_FLAGS="--enable-debug --with-sanitizers=address --disable-ccache"
    ./build.sh
    ;;

  build-default)
    ./build.sh
    ./build-secp256k1.sh
    ;;

  build-without-wallet)
    export DISABLE_WALLET=1
    ./build.sh
    ;;

  *)
    echo "Error: Invalid build name '${ABC_BUILD_NAME}'"
    exit 2
    ;;
esac

#!/bin/bash

set -e

if [ -z "$ABC_BUILD_NAME" ]; then
  echo "Error: Environment variable ABC_BUILD_NAME must be set"
  exit 1
fi

echo "Running build configuration '${ABC_BUILD_NAME}'..."

TOPLEVEL=`git rev-parse --show-toplevel`
cd "${TOPLEVEL}/contrib/teamcity"

case "$ABC_BUILD_NAME" in
  build-asan)
    export CONFIGURE_FLAGS="--enable-debug --with-sanitizers=address --disable-ccache"
    ./build.sh
    ;;

  build-ubsan)
    export CONFIGURE_FLAGS="--enable-debug --with-sanitizers=undefined --disable-ccache CC=clang CXX=clang++"
    ./build.sh
    ;;

  build-default)
    ./build.sh
    ./build-secp256k1.sh
    ;;

  build-without-wallet)
    export DISABLE_WALLET=1
    ./build.sh
    ;;

  *)
    echo "Error: Invalid build name '${ABC_BUILD_NAME}'"
    exit 2
    ;;
esac

Enable the undefined behaviour sanitizer
[CI] Enable the undefined behaviour sanitizer

Summary:
This diff enables UBSAN build.
It requires running with clang as UBSAN support in gcc is very poor (at
least until most recent versions ; in particular it won't run on Debian
9 which is our current CI target).

Test Plan: Run the CI build-ubsan config.

Reviewers: #bitcoin_abc, deadalnix, jasonbcox

Reviewed By: #bitcoin_abc, jasonbcox

Subscribers: jasonbcox

Differential Revision: https://reviews.bitcoinabc.org/D3749
