forked from qemu/qemu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·97 lines (88 loc) · 2.49 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env bash
set -euo pipefail
type=
if [ $# -ge 1 ]; then
type=$1; shift
fi
mkdir -p build
touch build/.build_type
previous_type="$(cat build/.build_type)"
if [ "$type" == "" ]; then
type=$previous_type
fi
if [ "$type" == "" ]; then
type=dev
fi
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
echo "build: $type"
if [ $type == tsan ]; then
echo "Build with TSAN: use export LD_LIBRARY_PATH=$(pwd)/build/glib_tsan"
fi
target="--target-list aarch64-linux-user,x86_64-linux-user"
target=$target,aarch64-softmmu,x86_64-softmmu,arm-softmmu
pushd build > /dev/null
if [ ! -f .configured ]; then
export CC="ccache gcc"
export CXX="ccache g++"
configure_flags=
case $type in
dev)
configure_flags="--enable-debug-tcg --enable-debug-graph-lock \
--enable-debug-mutex --enable-asan --enable-ubsan"
export CFLAGS="-fno-omit-frame-pointer"
;;
debug)
configure_flags="--enable-debug"
export CFLAGS="-fno-omit-frame-pointer"
;;
opt)
configure_flags=""
export CFLAGS="-fno-omit-frame-pointer"
;;
uftrace)
configure_flags=""
export CFLAGS="-fno-omit-frame-pointer -pg -fno-inline"
# -pg is faster than -finstrument-functions (x2)
# we need to disable inlining or we skip inlined func.
;;
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-tsan"
;;
clang)
export CC="ccache clang"
export CXX="ccache clang++"
;;
all)
configure_flags="--enable-debug"
target= # build all targets
;;
*)
choices="dev, debug, opt, uftrace, tsan, clang, all"
echo "Unknown build type $type (choices: $choices)"
exit 1
;;
esac
../configure $target $configure_flags
touch .configured
fi
ninja "$@" | sed -e "s#^\.\./#$(readlink -f ../)/#"
popd > /dev/null