mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
Build gem5 through buildroot
Oh, btw, also make it work, since the build was completely broken since the recent -K refactoring :0)
This commit is contained in:
2
gem5/.gitignore
vendored
2
gem5/.gitignore
vendored
@@ -1 +1 @@
|
||||
/gem5-system
|
||||
/system
|
||||
|
||||
10
gem5/README.adoc
Normal file
10
gem5/README.adoc
Normal file
@@ -0,0 +1,10 @@
|
||||
= gem5
|
||||
|
||||
We Build gem5 as a Buildroot package for the following reasons:
|
||||
|
||||
* if we build in tree without Buildroot, we still want to build the `m5` tool through Buildroot. But then Buildroot rsyncs the build for all archs into `output/build`, which takes quite some disk space. There seems to be no way to exclude some packages from the sync.
|
||||
* it allows us to reuse Buildroot's:
|
||||
** configuration system, which reduces duplication: set the gem5 package option, everything just gets built
|
||||
** timestamping system, which could save a few seconds on rebuilds, since we then don't ever run `scons` when gem5 is not modified
|
||||
|
||||
What is preventing upstreaming to Buildroot: a minimal kernel config like the ones QEMU has.
|
||||
45
gem5/build
Executable file
45
gem5/build
Executable file
@@ -0,0 +1,45 @@
|
||||
#/usr/bin/env bash
|
||||
set -eu
|
||||
arch=x86_64
|
||||
j=''
|
||||
while getopts a:j: OPT; do
|
||||
case "$OPT" in
|
||||
a)
|
||||
arch="$OPTARG"
|
||||
;;
|
||||
j)
|
||||
j="$OPTARG"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift "$(($OPTIND - 1))"
|
||||
if [ -z "$j" ]; then
|
||||
j="$(nproc)"
|
||||
fi
|
||||
top="$(dirname "$0")"
|
||||
system_dir="${top}/system"
|
||||
binaries_dir="${system_dir}/binaries"
|
||||
disks_dir="${system_dir}/disks"
|
||||
mkdir -p "$binaries_dir" "$disks_dir"
|
||||
cd "${top}/gem5"
|
||||
if [ "$arch" = x86_64 ]; then
|
||||
CC=gcc-6 CXX=g++-6 scons -j"$j" --ignore-style build/X86/gem5.opt
|
||||
f="${disks_dir}/linux-bigswap2.img"
|
||||
dd if=/dev/zero of="$f" bs=1024 count=65536
|
||||
mkswap "$f"
|
||||
# This file must always be present, despite --kernel overriding that default and selecting the kernel.
|
||||
# I'm not even joking. No one has ever built x86 gem5 without the magic dist dir present.
|
||||
touch "${binaries_dir}/x86_64-vmlinux-2.6.22.9"
|
||||
elif [ "$arch" = arm ] || [ "$arch" = aarch64 ]; then
|
||||
# Compilation fails with gcc 7 on that commit.
|
||||
# There were some recent portability patches, so it will likely get there soon.
|
||||
CC=gcc-6 CXX=g++-6 scons -j"$j" --ignore-style build/ARM/gem5.opt
|
||||
make -C ./system/arm/dt
|
||||
# TODO use the buildroot cross compiler here, and remove the dependencies from configure.
|
||||
make -C ./system/arm/simple_bootloader
|
||||
make -C ./system/arm/aarch64_bootloader/
|
||||
cp ./system/arm/simple_bootloader/boot_emm.arm "$binaries_dir"
|
||||
cp ./system/arm/aarch64_bootloader/boot_emm.arm64 "$binaries_dir"
|
||||
fi
|
||||
# TODO vs telnet?
|
||||
make -C util/term
|
||||
@@ -15,6 +15,7 @@ ARCH_MAKE = $(ARCH)
|
||||
endif
|
||||
|
||||
define GEM5_BUILD_CMDS
|
||||
cd '$(@D)' && ./build -a '$(ARCH)' -j '$(BR2_JLEVEL)'
|
||||
cd '$(@D)/gem5/util/m5' && $(MAKE) -f 'Makefile.$(ARCH_MAKE)' CC='$(TARGET_CC)' LD='$(TARGET_LD)'
|
||||
endef
|
||||
|
||||
|
||||
Reference in New Issue
Block a user