build runs, lots of uncommented and lots of untested though

Refactor everything. Create nice submodules/ and packages/ folders.
This commit is contained in:
Ciro Santilli
2018-09-07 10:08:59 +01:00
parent 5796f1ee1d
commit 66fe5f6647
123 changed files with 262 additions and 233 deletions

1
packages/gem5/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/system

7
packages/gem5/Config.in Normal file
View File

@@ -0,0 +1,7 @@
config BR2_PACKAGE_GEM5
bool "gem5"
help
gem5 system simulator. Only builds the m5 guest instrumentation
tool for now, not the simulator itself.
http://gem5.org

View File

@@ -0,0 +1 @@
https://github.com/cirosantilli/linux-kernel-module-cheat#gem5-directory

61
packages/gem5/build Executable file
View File

@@ -0,0 +1,61 @@
#!/usr/bin/env bash
set -eux
arch=x86_64
build_type=opt
cross_compile=
j=
outdir="$(pwd)"
while getopts a:c:j:o:t: OPT; do
case "$OPT" in
a)
arch="$OPTARG"
;;
c)
cross_compile="CROSS_COMPILE=$OPTARG"
;;
j)
j="$OPTARG"
;;
o)
outdir="$OPTARG"
;;
t)
build_type="$OPTARG"
;;
?)
exit 2
;;
esac
done
shift "$(($OPTIND - 1))"
if [ -z "$j" ]; then
j="$(nproc)"
fi
system_dir="${outdir}/system"
binaries_dir="${system_dir}/binaries"
disks_dir="${system_dir}/disks"
mkdir -p "$binaries_dir" "$disks_dir"
export PATH="/usr/lib/ccache:${PATH}"
if [ "$arch" = x86_64 ]; then
scons -j "$j" --ignore-style "${outdir}/build/X86/gem5.${build_type}"
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
scons -j "$j" --ignore-style "${outdir}/build/ARM/gem5.${build_type}"
make -C ./system/arm/dt/
mkdir -p "${system_dir}/arm/dt"
# || true in case they are the same directory.
cp ./system/arm/dt/*.dtb "${system_dir}/arm/dt" || true
# TODO use the buildroot cross compiler here, and remove the dependencies from configure.
make -C ./system/arm/simple_bootloader/ $cross_compile
cp ./system/arm/simple_bootloader/boot_emm.arm "$binaries_dir"
# TODO cross_compile is ignored because the make does not use CC...
make -C ./system/arm/aarch64_bootloader/ $cross_compile
cp ./system/arm/aarch64_bootloader/boot_emm.arm64 "$binaries_dir"
fi
make -C util/term
cp util/term/m5term "${outdir}"

View File

@@ -0,0 +1 @@
name: GEM5

30
packages/gem5/external.mk Normal file
View File

@@ -0,0 +1,30 @@
################################################################################
#
# GEM5
#
################################################################################
GEM5_VERSION = 1.0
GEM5_SITE = $(BR2_EXTERNAL_GEM5_PATH)
GEM5_SITE_METHOD = local
ifeq ($(ARCH),x86_64)
ARCH_MAKE = x86
else
ARCH_MAKE = $(ARCH)
endif
define GEM5_BUILD_CMDS
# TODO cannot pass "-c '$(TARGET_CROSS)'" here because the ARM build uses aarch64 for the bootloader...
cd '$(GEM5_LKMC_SRCDIR)' && '$(GEM5_SITE)/build' -a '$(ARCH)' -j '$(BR2_JLEVEL)' -o '$(GEM5_LKMC_OUTDIR)' -t '$(GEM5_LKMC_GEM5_BUILD_TYPE)'
# TODO cannot use TARGET_CONFIGURE_OPTS here because it overrides the CFLAGS on m5,
# which have an include. We should patch gem5 to add a += instead of = there.
cd '$(@D)/gem5/util/m5' && $(MAKE) -f 'Makefile.$(ARCH_MAKE)' CC='$(TARGET_CC)' LD='$(TARGET_LD)'
endef
define GEM5_INSTALL_TARGET_CMDS
$(INSTALL) -D -m 0755 '$(@D)/gem5/util/m5/m5' '$(TARGET_DIR)/usr/bin'
endef
$(eval $(generic-package))