forked from qemu/qemu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·81 lines (74 loc) · 1.96 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env bash
set -euo pipefail
x64="x86_64-linux-user,x86_64-softmmu"
i386="i386-linux-user,i386-softmmu"
aarch64="aarch64-linux-user,aarch64-softmmu"
type=debug
if [ $# -eq 1 ]; then
type=$1
fi
mkdir -p build
touch build/.build_type
previous_type="$(cat build/.build_type)"
if [ "$previous_type" != "$type" ]; then
echo "build type is different ($previous_type -> $type)"
rm -rf build || true
mkdir -p build
echo "$type" > build/.build_type
fi
if [ $type == tsan ]; then
echo "Build with TSAN: use export LD_LIBRARY_PATH=$(pwd)/build/glib_tsan"
fi
pushd build
if [ ! -f .configured ]; then
export CC="ccache cc"
export CXX="ccache cxx"
configure_flags=
target="--target-list=$x64,$i386,$aarch64"
case $type in
opt)
configure_flags=""
export CFLAGS="-O2 -g -fno-omit-frame-pointer"
;;
opt-gcov)
configure_flags=""
export CFLAGS="-O2 -g -fno-omit-frame-pointer --coverage"
export LDFLAGS="--coverage"
;;
debug)
configure_flags="--enable-debug -Dasan=true -Dubsan=true"
;;
tsan)
if [ ! -d glib_tsan ]; then
rm -rf glib
git clone --depth=1 --branch=2.81.0 https://github.com/GNOME/glib.git
pushd glib
CFLAGS="-O2 -g -fsanitize=thread" meson setup \
--prefix=$(pwd)/out \
build -Dtests=false
ninja -C build install
popd
mkdir -p glib_tsan
rsync -av glib/out/lib/*/* glib_tsan/
rm -rf glib/
fi
configure_flags="--enable-debug -Dtsan=true"
;;
all)
target=
;;
all-clang)
target=
export CC="ccache clang"
export CXX="ccache clang++"
;;
*)
echo "Unknown build type $type (choices: opt, debug, tsan, all, all-clang)"
exit 1
;;
esac
../configure $target $configure_flags
touch .configured
fi
ninja -k0
popd