forked from linux-riscv/linux
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build_rv64_clang_allmodconfig.sh
108 lines (79 loc) · 3.41 KB
/
build_rv64_clang_allmodconfig.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
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (C) 2019 Netronome Systems, Inc.
# Modified tests/patch/build_defconfig_warn.sh for RISC-V builds
tmpfile_e=$(mktemp)
tmpfile_o=$(mktemp)
tmpfile_n=$(mktemp)
tmpdir_b=build_llvm
tmpdir_o=output
rc=0
echo "Redirect to $tmpfile_o and $tmpfile_n"
HEAD=$(git rev-parse HEAD)
echo "Tree base:"
git log -1 --pretty='%h ("%s")' HEAD~
echo "Building the whole tree with the patch"
tuxmake --wrapper ccache --target-arch riscv -e PATH=$PATH --directory . \
--environment=KBUILD_BUILD_TIMESTAMP=@1621270510 \
--environment=KBUILD_BUILD_USER=tuxmake --environment=KBUILD_BUILD_HOST=tuxmake \
-o $tmpdir_o -b $tmpdir_b --toolchain llvm -z none --kconfig allmodconfig \
-K CONFIG_WERROR=n -K CONFIG_RANDSTRUCT_NONE=y -K CONFIG_SAMPLES=n W=1 \
CROSS_COMPILE=riscv64-linux- \
config default \
>$tmpfile_e 2>/dev/null || rc=1
if [ $rc -eq 1 ]; then
grep "\(error\):" $tmpfile_e
rm -rf $tmpdir_o $tmpfile_o $tmpfile_n $tmpdir_b $tmpfile_e
exit $rc
fi
current=$(grep -c "\(warning\|error\):" $tmpfile_n)
git checkout -q HEAD~
echo "Building the tree before the patch"
tuxmake --wrapper ccache --target-arch riscv -e PATH=$PATH --directory . \
--environment=KBUILD_BUILD_TIMESTAMP=@1621270510 \
--environment=KBUILD_BUILD_USER=tuxmake --environment=KBUILD_BUILD_HOST=tuxmake \
-o $tmpdir_o -b $tmpdir_b --toolchain llvm -z none --kconfig allmodconfig \
-K CONFIG_WERROR=n -K CONFIG_RANDSTRUCT_NONE=y W=1 \
CROSS_COMPILE=riscv64-linux- \
config default \
>$tmpfile_o 2>/dev/null
incumbent=$(grep -c "\(warning\|error\):" $tmpfile_o)
git checkout -q $HEAD
echo "Building the tree with the patch"
tuxmake --wrapper ccache --target-arch riscv -e PATH=$PATH --directory . \
--environment=KBUILD_BUILD_TIMESTAMP=@1621270510 \
--environment=KBUILD_BUILD_USER=tuxmake --environment=KBUILD_BUILD_HOST=tuxmake \
-o $tmpdir_o -b $tmpdir_b --toolchain llvm -z none --kconfig allmodconfig \
-K CONFIG_WERROR=n -K CONFIG_RANDSTRUCT_NONE=y W=1 \
CROSS_COMPILE=riscv64-linux- \
config default \
>$tmpfile_n 2>/dev/null || rc=1
if [ $rc -eq 1 ]; then
grep "\(warning\|error\):" $tmpfile_n
rm -rf $tmpdir_o $tmpfile_o $tmpfile_n $tmpdir_b
exit $rc
fi
current=$(grep -c "\(warning\|error\):" $tmpfile_n)
if [ $current -gt $incumbent ]; then
echo "New errors added:"
tmpfile_errors_before=$(mktemp)
tmpfile_errors_now=$(mktemp)
grep "\(warning\|error\):" $tmpfile_o | sort | uniq -c > $tmpfile_errors_before
grep "\(warning\|error\):" $tmpfile_n | sort | uniq -c > $tmpfile_errors_now
diff -U 0 $tmpfile_errors_before $tmpfile_errors_now
rm $tmpfile_errors_before $tmpfile_errors_now
echo "Per-file breakdown"
tmpfile_fo=$(mktemp)
tmpfile_fn=$(mktemp)
grep "\(warning\|error\):" $tmpfile_o | sed -n 's@\(^\.\./[/a-zA-Z0-9_.-]*.[ch]\):.*@\1@p' | sort | uniq -c \
> $tmpfile_fo
grep "\(warning\|error\):" $tmpfile_n | sed -n 's@\(^\.\./[/a-zA-Z0-9_.-]*.[ch]\):.*@\1@p' | sort | uniq -c \
> $tmpfile_fn
diff -U 0 $tmpfile_fo $tmpfile_fn
rm $tmpfile_fo $tmpfile_fn
echo "pre: $incumbent post: $current"
rc=1
fi
rm -rf $tmpdir_o $tmpfile_o $tmpfile_n $tmpdir_b $tmpfile_e
exit $rc