| 1 | # Usage:
|
| 2 | # source build/common.sh
|
| 3 |
|
| 4 | # Include guard.
|
| 5 | test -n "${__BUILD_COMMON_SH:-}" && return
|
| 6 | readonly __BUILD_COMMON_SH=1
|
| 7 |
|
| 8 | if test -z "${REPO_ROOT:-}"; then
|
| 9 | echo 'build/common.sh: $REPO_ROOT should be set before sourcing'
|
| 10 | exit 1
|
| 11 | fi
|
| 12 |
|
| 13 | set -o nounset
|
| 14 | set -o errexit
|
| 15 | #eval 'set -o pipefail'
|
| 16 |
|
| 17 | #LLVM_VERSION=18.1.8
|
| 18 | LLVM_VERSION=14.0.0
|
| 19 |
|
| 20 | # New version is slightly slower -- 13 seconds vs. 11.6 seconds on oils-for-unix
|
| 21 | readonly CLANG_DIR_RELATIVE="../oil_DEPS/clang+llvm-$LLVM_VERSION-x86_64-linux-gnu-ubuntu-18.04"
|
| 22 |
|
| 23 | CLANG_DIR_1=$REPO_ROOT/$CLANG_DIR_RELATIVE
|
| 24 | CLANG_DIR_FALLBACK=~/git/oilshell/oil/$CLANG_DIR_RELATIVE
|
| 25 | if test -d $CLANG_DIR_1; then
|
| 26 | CLANG_DIR=$CLANG_DIR_1
|
| 27 | CLANG_IS_MISSING=''
|
| 28 | else
|
| 29 | # BUG FIX: What if we're building _deps/ovm-build or ../benchmark-data/src?
|
| 30 | # Just hard-code an absolute path. (We used to use $PWD, but I think that
|
| 31 | # was too fragile.)
|
| 32 | CLANG_DIR=$CLANG_DIR_FALLBACK
|
| 33 | CLANG_IS_MISSING='T'
|
| 34 | fi
|
| 35 | readonly CLANG_DIR
|
| 36 |
|
| 37 | readonly CLANG=$CLANG_DIR/bin/clang # used by benchmarks/{id,ovm-build}.sh
|
| 38 | readonly CLANGXX=$CLANG_DIR/bin/clang++
|
| 39 |
|
| 40 | # I'm not sure if there's a GCC version of this?
|
| 41 | export ASAN_SYMBOLIZER_PATH=$CLANG_DIR_RELATIVE/bin/llvm-symbolizer
|
| 42 |
|
| 43 | # ThreadSanitizer doesn't always give us all locations, but this doesn't help
|
| 44 | # export TSAN_SYMBOLIZER_PATH=$ASAN_SYMBOLIZER_PATH
|
| 45 |
|
| 46 | # equivalent of 'cc' for C++ language
|
| 47 | # https://stackoverflow.com/questions/172587/what-is-the-difference-between-g-and-gcc
|
| 48 | CXX=${CXX:-'c++'}
|
| 49 |
|
| 50 | # Compiler flags we want everywhere.
|
| 51 | # - -Weverything is more than -Wall, but too many errors now.
|
| 52 | # - -fno-omit-frame-pointer is what Brendan Gregg says should always be on.
|
| 53 | # Omitting the frame pointer might be neglibly faster, but reduces
|
| 54 | # observability. It's required for the 'perf' tool and other kinds of tracing.
|
| 55 | # Anecdotally the speed difference was in the noise on parsing
|
| 56 | # configure-coreutils.
|
| 57 | # - TODO(6/22): Disabled invalid-offsetof for now, but we should enable it after
|
| 58 | # progress on the garbage collector. It could catch bugs.
|
| 59 |
|
| 60 | # Allow user to override both BASE_CXXFLAGS and CXXFLAGS
|
| 61 | # There doesn't seem to be a well-known convention for this. Similar to this
|
| 62 | # question:
|
| 63 | # - https://stackoverflow.com/questions/51606653/allowing-users-to-override-cflags-cxxflags-and-friends
|
| 64 |
|
| 65 | default_cxx_flags='-std=c++11 -Wall -Wno-invalid-offsetof -fno-omit-frame-pointer'
|
| 66 |
|
| 67 | # note: Use - and not :- so that BASE_CXXFLAGS= works
|
| 68 | BASE_CXXFLAGS=${BASE_CXXFLAGS-$default_cxx_flags}
|
| 69 |
|
| 70 | readonly PY27=Python-2.7.13
|
| 71 |
|
| 72 | readonly PREPARE_DIR=$REPO_ROOT/../oil_DEPS/cpython-full
|
| 73 |
|
| 74 | log() {
|
| 75 | echo "$@" >&2
|
| 76 | }
|
| 77 |
|
| 78 | die() {
|
| 79 | log "$0: fatal: $@"
|
| 80 | exit 1
|
| 81 | }
|