Skip to content

Commit 2f41395

Browse files
committed
gem5: fix submodule fetch
Only shallow clone the Linux kernel for now Saner defaults for ./configure: * ./configure only gets gem5 * ./configure -g only gets gem5 * ./configure -qg both
1 parent d96baeb commit 2f41395

File tree

2 files changed

+48
-24
lines changed

2 files changed

+48
-24
lines changed

README.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ See <<gem5-vs-qemu,like QEMU>> for a more thorough comparison.
330330
For the most part, if you just add the `--gem5` option or `-gem5` suffix to all commands and everything should magically work:
331331

332332
....
333-
./configure --gem5 && \
333+
./configure -g && \
334334
./build-gem5 --arch aarch64 && \
335335
./build-buildroot --arch aarch64 --gem5 && \
336336
./run --arch aarch64 --gem5 &&\
@@ -8210,7 +8210,7 @@ There are two ways to run PARSEC with this repo:
82108210
====== PARSEC benchmark without parsecmgmt
82118211

82128212
....
8213-
./configure -gpq && \
8213+
./configure -gp && \
82148214
./build-buildroot --arch arm --buildroot-config 'BR2_PACKAGE_PARSEC_BENCHMARK=y' --gem5 && \
82158215
./run --arch arm --gem5 && \
82168216
:;

configure

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,22 @@
22
set -eu
33
interactive_pkgs=libsdl2-dev
44
gem5=false
5+
gem5_given=false
56
qemu=true
6-
submodules='buildroot linux'
7+
qemu_given=false
8+
submodules_dir=submodules
9+
submodules=buildroot
710
y=
811
while getopts gpqt OPT; do
912
case "$OPT" in
1013
g)
11-
gem5=true
14+
gem5_given=true
1215
;;
1316
p)
1417
submodules="${submodules} parsec-benchmark"
1518
;;
1619
q)
17-
qemu=false
20+
qemu_given=true
1821
;;
1922
t)
2023
interactive_pkgs=
@@ -23,6 +26,12 @@ while getopts gpqt OPT; do
2326
esac
2427
done
2528
shift $(($OPTIND - 1))
29+
if "$gem5_given" && ! "$qemu_given"; then
30+
qemu=false
31+
fi
32+
if "$gem5_given"; then
33+
gem5=true
34+
fi
2635

2736
## apt-get
2837

@@ -69,14 +78,11 @@ pkgs="$pkgs libelf-dev"
6978

7079
# https://stackoverflow.com/questions/20010199/determining-if-a-process-runs-inside-lxc-docker
7180
if [ -f /.dockerenv ]; then
72-
# --jobs is not available in git 2.7.4 from Ubuntu 16.04.
73-
gitjobs=
7481
mysudo=
7582
# https://askubuntu.com/questions/496549/error-you-must-put-some-source-uris-in-your-sources-list
7683
sed -Ei 's/^# deb-src/deb-src/' /etc/apt/sources.list
7784
y=-y
7885
else
79-
gitjobs="--jobs $(nproc)"
8086
mysudo=sudo
8187
fi
8288
$mysudo apt-get update $y
@@ -105,19 +111,37 @@ fi
105111
if "$gem5"; then
106112
submodules="${submodules} gem5"
107113
fi
108-
submodules="$(for submodule in ${submodules}; do printf "submodules/${submodule} "; done)"
109-
(
110-
set -e
111-
# Shallow cloning saves a considerable amount of time, specially because of the linux kernel.
112-
# However, git submodules are buggy as usual, and this is the best way I've found to get it done:
113-
# https://stackoverflow.com/questions/2144406/git-shallow-submodules/47374702#47374702
114-
# In particular:
115-
# - `shallow = true` on the submodule has no effect for the non default educational branches of our submodules
116-
# - QEMU's submodules point to commits that are neither under branches nor tags, and so `--shallow-submodules` fails
117-
git submodule update --depth 1 $gitjobs --init -- ${submodules}
118-
if "$qemu"; then
119-
git -C submodules/qemu submodule update --init --recursive
120-
fi
121-
) &
122-
# https://unix.stackexchange.com/questions/65532/why-does-set-e-not-work-inside-subshells-with-parenthesis-followed-by-an-or
123-
wait $! || git submodule update --init --recursive -- $submodules
114+
submodules="$(for submodule in ${submodules}; do printf "${submodules_dir}/${submodule} "; done)"
115+
116+
# == Shallow cloning.
117+
#
118+
# TODO Ideally we should shallow clone --depth 1 all of them.
119+
#
120+
# However, most git servers out there are crap or craply configured
121+
# and don't allow shallow cloning except for branches.
122+
#
123+
# So for now, let's shallow clone only the Linux kernel, which has by far
124+
# the largest .git repo history, and full clone the others.
125+
#
126+
# Then we will maintain a GitHub Linux kernel mirror / fork that always has a
127+
# lkmc branch, and point to it, so that it will always succeed.
128+
#
129+
# See also:
130+
#
131+
# * https://stackoverflow.com/questions/3489173/how-to-clone-git-repository-with-specific-revision-changeset
132+
# * https://stackoverflow.com/questions/2144406/git-shallow-submodules/47374702#47374702
133+
# * https://unix.stackexchange.com/questions/338578/why-is-the-git-clone-of-the-linux-kernel-source-code-much-larger-than-the-extrac
134+
#
135+
# == Other nice git options for when distros move to newer Git
136+
#
137+
# Currently not on Ubuntu 16.04:
138+
#
139+
# `--progress`: added on Git 2.10:
140+
#
141+
# * https://stackoverflow.com/questions/32944468/how-to-show-progress-for-submodule-fetching
142+
# * https://stackoverflow.com/questions/4640020/progress-indicator-for-git-clone
143+
#
144+
# `--jobs"`: https://stackoverflow.com/questions/26957237/how-to-make-git-clone-faster-with-multiple-threads/52327638#52327638
145+
#
146+
git submodule update --init --recursive -- ${submodules}
147+
git submodule update --depth 1 --init --recursive -- "${submodules_dir}/linux"

0 commit comments

Comments
 (0)