Decent multiarch with make O=

This commit is contained in:
Ciro Santilli
2017-06-30 15:41:33 +01:00
parent edc6e14c8c
commit 3e0b03fc75
4 changed files with 15 additions and 26 deletions

16
run
View File

@@ -3,41 +3,39 @@ set -e
arch='x86_64'
while getopts a: OPT > /dev/null 2>&1; do
case "$OPT" in
a)
'a')
arch=$OPTARG
;;
esac
done
case "$arch" in
x86_64)
'x86_64')
defconfig=qemu_x86_64_defconfig
;;
arm)
'arm')
# qemu_arm_vexpress_defconfig required a newer QEMU than 2.0.0 on a Ubuntu host.
# so let's stick to versatile for now.
defconfig=qemu_arm_versatile_defconfig
;;
esac
./setoutarch "$arch"
cd buildroot
for p in $(find '../buildroot_patches/' -maxdepth 1 -name '*.patch' -print); do
patch -N -r - -p 1 <"$p" || :
done
make BR2_EXTERNAL="$(pwd)/../kernel_module" "$defconfig"
outdir="output.${arch}~"
make O="$outdir" BR2_EXTERNAL="$(pwd)/../kernel_module" "$defconfig"
# TODO Can't get rid of this for now.
# http://stackoverflow.com/questions/44078245/is-it-possible-to-use-config-fragments-with-buildroots-config
cat ../buildroot_config_fragment >> .config
cat ../buildroot_config_fragment >> "${outdir}/.config"
# HOST_QEMU_OPTS is a hack that happens to work because the QEMU package luckly uses += at all times.
# It shouldn't be necessary in the first place: https://bugs.busybox.net/show_bug.cgi?id=9936
# Even if were an autotools package, there is no general way currently to pass extra configs to it:
# https://stackoverflow.com/questions/44341188/how-to-pass-extra-custom-configure-autotools-options-to-a-buildroot-package/44341225#44341225
#
# We might add this later on.
# host-qemu-rebuild \
env \
-u LD_LIBRARY_PATH \
make \
O="$outdir" \
BR2_JLEVEL="$(($(nproc) - 2))" \
HOST_QEMU_OPTS="--enable-debug --enable-sdl --with-sdlabi=2.0" \
host-qemu-rebuild \

11
rungdb
View File

@@ -21,9 +21,10 @@ else
brk=""
fi
gdb="$(pwd)/buildroot/output/host/usr/bin/${arch}-linux-gdb"
cd buildroot/output/build/linux-?.*.*/
if $kgdb; then
buildroot_out_dir="$(pwd)/buildroot/output.${arch}~"
gdb="${buildroot_out_dir}/host/usr/bin/${arch}-linux-gdb"
cd "${buildroot_out_dir}/build"/linux-?.*.*/
if "$kgdb"; then
cmd="$gdb \
-q \
-ex 'add-auto-load-safe-path $(pwd)' \
@@ -32,7 +33,7 @@ if $kgdb; then
"
else
case "$arch" in
x86_64)
'x86_64')
# http://stackoverflow.com/questions/11408041/how-to-debug-the-linux-kernel-with-gdb-and-qemu/33203642#33203642
# http://stackoverflow.com/questions/4943857/linux-kernel-live-debugging-how-its-done-and-what-tools-are-used/42316607#42316607
# http://stackoverflow.com/questions/28607538/how-to-debug-linux-kernel-modules-with-qemu/44095831#44095831
@@ -50,7 +51,7 @@ else
-ex 'lx-symbols ../kernel_module-1.0/'
"
;;
arm)
'arm')
cmd="$gdb \
-q \
-ex 'add-auto-load-safe-path $(pwd)' \

View File

@@ -43,8 +43,7 @@ done
shift "$(($OPTIND - 1))"
extra_flags="$extra_flags $@"
./setoutarch "$arch"
buildroot_out_dir='./buildroot/output'
buildroot_out_dir="./buildroot/output.${arch}~"
images_dir="$buildroot_out_dir/images"
qemu_common="\
$debug_qemu \
@@ -62,6 +61,7 @@ case "$arch" in
cmd="$qemu_common \
-M pc \
-append 'root=/dev/vda $extra_append' \
-device edu \
-drive file=${images_dir}/rootfs.ext2,if=virtio,format=raw \
-kernel ${images_dir}/bzImage \
-net nic,model=virtio \

View File

@@ -1,10 +0,0 @@
#!/usr/bin/env bash
# Maintain different buildroot/output archs with symlinks.
if [ "$#" -ne 1 ]; then
exit 1
fi
arch="$1"
dst="output.${arch}~"
src='buildroot/output'
mkdir -p "buildroot/$dst"
ln -fns "$dst" "$src"