Skip to content

Commit dc30727

Browse files
authored
Merge pull request #5916 from nmanthey/linux-ci
Linux ci - Compile KVM with goto-cc
2 parents afd8a60 + 1fbfd5e commit dc30727

File tree

2 files changed

+139
-0
lines changed

2 files changed

+139
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build Linux partially with CPROVER tools
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- '**'
7+
8+
jobs:
9+
CompileLinux:
10+
runs-on: ubuntu-20.04
11+
steps:
12+
- uses: actions/checkout@v2
13+
with:
14+
submodules: true
15+
- name: Install Packages
16+
env:
17+
# This is needed in addition to -yq to prevent apt-get from asking for
18+
# user input
19+
DEBIAN_FRONTEND: noninteractive
20+
run: |
21+
sudo apt-get update
22+
sudo apt-get install --no-install-recommends -y g++ flex bison cmake ninja-build maven jq libxml2-utils dpkg-dev ccache
23+
sudo apt-get install --no-install-recommends -y libssl-dev libelf-dev libudev-dev libpci-dev libiberty-dev autoconf
24+
sudo apt-get install --no-install-recommends -y gawk jq
25+
26+
- name: Prepare ccache
27+
uses: actions/cache@v2
28+
with:
29+
path: .ccache
30+
key: ${{ runner.os }}-20.04-make-${{ github.ref }}-${{ github.sha }}-KERNEL
31+
restore-keys: |
32+
${{ runner.os }}-20.04-make-${{ github.ref }}
33+
${{ runner.os }}-20.04-make
34+
- name: ccache environment
35+
run: |
36+
echo "CCACHE_BASEDIR=$PWD" >> $GITHUB_ENV
37+
echo "CCACHE_DIR=$PWD/.ccache" >> $GITHUB_ENV
38+
- name: Zero ccache stats and limit in size
39+
run: ccache -z --max-size=500M
40+
- name: Build CBMC tools
41+
run: |
42+
make -C src minisat2-download
43+
make -C src CXX='ccache /usr/bin/g++' cbmc.dir goto-cc.dir goto-diff.dir -j2
44+
- name: Print ccache stats
45+
run: ccache -s
46+
47+
- name: Run (Docker Based) Linux Build test
48+
run: integration/linux/compile_linux.sh
49+
50+
- uses: actions/upload-artifact@v2
51+
with:
52+
name: CPROVER-faultyInput
53+
path: CPROVER/faultyInput/*

integration/linux/compile_linux.sh

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/bin/bash
2+
3+
# Fail on errors
4+
# set -e # not for now
5+
6+
# Show steps we execute
7+
set -x
8+
9+
# This script needs to operate in the root directory of the CBMC repository
10+
SCRIPT=$(readlink -e "$0")
11+
readonly SCRIPT
12+
SCRIPTDIR=$(dirname "$SCRIPT")
13+
readonly SCRIPTDIR
14+
cd "$SCRIPTDIR/../.."
15+
16+
# Build CBMC tools
17+
make -C src minisat2-download
18+
make -C src CXX='ccache /usr/bin/g++' cbmc.dir goto-cc.dir goto-diff.dir -j$(nproc)
19+
20+
# Get one-line-scan, if we do not have it already
21+
[ -d one-line-scan ] || git clone https://github.com/awslabs/one-line-scan.git one-line-scan
22+
23+
# Get Linux v5.10, if we do not have it already
24+
[ -d linux_5_10 ] || git clone -b v5.10 --depth=1 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux_5_10
25+
26+
# Prepare compile a part of the kernel with CBMC via one-line-scan
27+
ln -s goto-cc src/goto-cc/goto-ld
28+
ln -s goto-cc src/goto-cc/goto-as
29+
ln -s goto-cc src/goto-cc/goto-g++
30+
31+
32+
configure_linux ()
33+
{
34+
pushd linux_5_10
35+
36+
cat > kvm-config <<EOF
37+
CONFIG_64BIT=y
38+
CONFIG_X86_64=y
39+
CONFIG_HIGH_RES_TIMERS=y
40+
CONFIG_MULTIUSER=y
41+
CONFIG_NET=y
42+
CONFIG_VIRTUALIZATION=y
43+
CONFIG_HYPERVISOR_GUEST=y
44+
CONFIG_PARAVIRT=y
45+
CONFIG_KVM_GUEST=y
46+
CONFIG_KVM=y
47+
CONFIG_KVM_INTEL=y
48+
CONFIG_KVM_AMD=y
49+
EOF
50+
# use the configuration from the generated file
51+
export KCONFIG_ALLCONFIG=kvm-config
52+
53+
# ... and use it during configuration
54+
make allnoconfig
55+
popd
56+
}
57+
58+
# Configure kernel, and compile all of it
59+
configure_linux
60+
make -C linux_5_10 bzImage -j $(nproc)
61+
62+
# Clean files we want to be able to re-compile
63+
find linux_5_10/arch/x86/kvm/ -name "*.o" -delete
64+
65+
# Compile Linux with CBMC via one-line-scan, and check for goto-cc section
66+
# Re-Compile with goto-cc, and measure disk space
67+
declare -i STATUS=0
68+
du -h --max-depth=1
69+
one-line-scan/one-line-scan \
70+
--add-to-path $(pwd)/src/cbmc --add-to-path $(pwd)/src/goto-diff --add-to-path $(pwd)/src/goto-cc \
71+
--cbmc \
72+
--no-analysis \
73+
--trunc-existing \
74+
--extra-cflags -Wno-error \
75+
-o CPROVER -j 5 -- \
76+
make -C linux_5_10 bzImage -j $(nproc) || STATUS=$?
77+
du -h --max-depth=1
78+
79+
# Check for faulty input
80+
ls CPROVER/faultyInput/* || true
81+
82+
# Check for produced output in the files we deleted above
83+
objdump -h linux_5_10/arch/x86/kvm/x86.o | grep "goto-cc" || STATUS=$?
84+
85+
# Propagate failures
86+
exit "$STATUS"

0 commit comments

Comments
 (0)