build-gem5 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #/usr/bin/env bash
  2. set -eu
  3. arch='arm-gem5'
  4. while getopts 'a:' OPT; do
  5. case "$OPT" in
  6. a)
  7. arch="$OPTARG"
  8. ;;
  9. esac
  10. done
  11. shift "$(($OPTIND - 1))"
  12. if [ ! -d 'gem5' ]; then
  13. git clone https://gem5.googlesource.com/public/gem5
  14. fi
  15. cd gem5
  16. git checkout da79d6c6cde0fbe5473ce868c9be4771160a003b
  17. system_dir='../gem5-system'
  18. binaries_dir="${system_dir}/binaries"
  19. disks_dir="${system_dir}/disks"
  20. mkdir -p "$binaries_dir" "$disks_dir"
  21. if [ "$arch" = 'x86_64-gem5' ]; then
  22. CC=gcc-6 CXX=g++-6 scons -j"$(nproc)" --ignore-style build/X86/gem5.opt
  23. f="${disks_dir}/linux-bigswap2.img"
  24. dd if=/dev/zero of="$f" bs=1024 count=65536
  25. mkswap "$f"
  26. # This file must always be present, despite --kernel overriding that default and selecting the kernel.
  27. # I'm not even joking. No one has ever built x86 gem5 without the magic dist dir present.
  28. touch "${binaries_dir}/x86_64-vmlinux-2.6.22.9"
  29. elif [ "$arch" = 'arm-gem5' ]; then
  30. # Compilation fails with gcc 7 on that commit.
  31. # There were some recent portability patches, so it will likely get there soon.
  32. CC=gcc-6 CXX=g++-6 scons -j"$(nproc)" --ignore-style build/ARM/gem5.opt
  33. make -C system/arm/dt
  34. make -C system/arm/simple_bootloader
  35. make -C system/arm/aarch64_bootloader/
  36. cp ./system/arm/simple_bootloader/boot_emm.arm "$binaries_dir"
  37. cp ./system/arm/aarch64_bootloader/boot_emm.arm64 "$binaries_dir"
  38. fi