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

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