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

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