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
This commit is contained in:
Ciro Santilli
2018-09-14 09:26:51 +01:00
parent d96baebe7a
commit 2f413958b0
2 changed files with 48 additions and 24 deletions

View File

@@ -330,7 +330,7 @@ See <<gem5-vs-qemu,like QEMU>> for a more thorough comparison.
For the most part, if you just add the `--gem5` option or `-gem5` suffix to all commands and everything should magically work: For the most part, if you just add the `--gem5` option or `-gem5` suffix to all commands and everything should magically work:
.... ....
./configure --gem5 && \ ./configure -g && \
./build-gem5 --arch aarch64 && \ ./build-gem5 --arch aarch64 && \
./build-buildroot --arch aarch64 --gem5 && \ ./build-buildroot --arch aarch64 --gem5 && \
./run --arch aarch64 --gem5 &&\ ./run --arch aarch64 --gem5 &&\
@@ -8210,7 +8210,7 @@ There are two ways to run PARSEC with this repo:
====== PARSEC benchmark without parsecmgmt ====== PARSEC benchmark without parsecmgmt
.... ....
./configure -gpq && \ ./configure -gp && \
./build-buildroot --arch arm --buildroot-config 'BR2_PACKAGE_PARSEC_BENCHMARK=y' --gem5 && \ ./build-buildroot --arch arm --buildroot-config 'BR2_PACKAGE_PARSEC_BENCHMARK=y' --gem5 && \
./run --arch arm --gem5 && \ ./run --arch arm --gem5 && \
:; :;

68
configure vendored
View File

@@ -2,19 +2,22 @@
set -eu set -eu
interactive_pkgs=libsdl2-dev interactive_pkgs=libsdl2-dev
gem5=false gem5=false
gem5_given=false
qemu=true qemu=true
submodules='buildroot linux' qemu_given=false
submodules_dir=submodules
submodules=buildroot
y= y=
while getopts gpqt OPT; do while getopts gpqt OPT; do
case "$OPT" in case "$OPT" in
g) g)
gem5=true gem5_given=true
;; ;;
p) p)
submodules="${submodules} parsec-benchmark" submodules="${submodules} parsec-benchmark"
;; ;;
q) q)
qemu=false qemu_given=true
;; ;;
t) t)
interactive_pkgs= interactive_pkgs=
@@ -23,6 +26,12 @@ while getopts gpqt OPT; do
esac esac
done done
shift $(($OPTIND - 1)) shift $(($OPTIND - 1))
if "$gem5_given" && ! "$qemu_given"; then
qemu=false
fi
if "$gem5_given"; then
gem5=true
fi
## apt-get ## apt-get
@@ -69,14 +78,11 @@ pkgs="$pkgs libelf-dev"
# https://stackoverflow.com/questions/20010199/determining-if-a-process-runs-inside-lxc-docker # https://stackoverflow.com/questions/20010199/determining-if-a-process-runs-inside-lxc-docker
if [ -f /.dockerenv ]; then if [ -f /.dockerenv ]; then
# --jobs is not available in git 2.7.4 from Ubuntu 16.04.
gitjobs=
mysudo= mysudo=
# https://askubuntu.com/questions/496549/error-you-must-put-some-source-uris-in-your-sources-list # https://askubuntu.com/questions/496549/error-you-must-put-some-source-uris-in-your-sources-list
sed -Ei 's/^# deb-src/deb-src/' /etc/apt/sources.list sed -Ei 's/^# deb-src/deb-src/' /etc/apt/sources.list
y=-y y=-y
else else
gitjobs="--jobs $(nproc)"
mysudo=sudo mysudo=sudo
fi fi
$mysudo apt-get update $y $mysudo apt-get update $y
@@ -105,19 +111,37 @@ fi
if "$gem5"; then if "$gem5"; then
submodules="${submodules} gem5" submodules="${submodules} gem5"
fi fi
submodules="$(for submodule in ${submodules}; do printf "submodules/${submodule} "; done)" submodules="$(for submodule in ${submodules}; do printf "${submodules_dir}/${submodule} "; done)"
(
set -e # == Shallow cloning.
# Shallow cloning saves a considerable amount of time, specially because of the linux kernel. #
# However, git submodules are buggy as usual, and this is the best way I've found to get it done: # TODO Ideally we should shallow clone --depth 1 all of them.
# https://stackoverflow.com/questions/2144406/git-shallow-submodules/47374702#47374702 #
# In particular: # However, most git servers out there are crap or craply configured
# - `shallow = true` on the submodule has no effect for the non default educational branches of our submodules # and don't allow shallow cloning except for branches.
# - QEMU's submodules point to commits that are neither under branches nor tags, and so `--shallow-submodules` fails #
git submodule update --depth 1 $gitjobs --init -- ${submodules} # So for now, let's shallow clone only the Linux kernel, which has by far
if "$qemu"; then # the largest .git repo history, and full clone the others.
git -C submodules/qemu submodule update --init --recursive #
fi # Then we will maintain a GitHub Linux kernel mirror / fork that always has a
) & # lkmc branch, and point to it, so that it will always succeed.
# https://unix.stackexchange.com/questions/65532/why-does-set-e-not-work-inside-subshells-with-parenthesis-followed-by-an-or #
wait $! || git submodule update --init --recursive -- $submodules # See also:
#
# * https://stackoverflow.com/questions/3489173/how-to-clone-git-repository-with-specific-revision-changeset
# * https://stackoverflow.com/questions/2144406/git-shallow-submodules/47374702#47374702
# * https://unix.stackexchange.com/questions/338578/why-is-the-git-clone-of-the-linux-kernel-source-code-much-larger-than-the-extrac
#
# == Other nice git options for when distros move to newer Git
#
# Currently not on Ubuntu 16.04:
#
# `--progress`: added on Git 2.10:
#
# * https://stackoverflow.com/questions/32944468/how-to-show-progress-for-submodule-fetching
# * https://stackoverflow.com/questions/4640020/progress-indicator-for-git-clone
#
# `--jobs"`: https://stackoverflow.com/questions/26957237/how-to-make-git-clone-faster-with-multiple-threads/52327638#52327638
#
git submodule update --init --recursive -- ${submodules}
git submodule update --depth 1 --init --recursive -- "${submodules_dir}/linux"