OILS / build / common.sh View on Github | oils.pub

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