diff --git a/tools/Makefile b/tools/Makefile index 229f38ef..0014b9d2 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -2,7 +2,7 @@ WORKING_DIR = $(CURDIR) CROSS_DIR=$(WORKING_DIR)/cross export PATH := $(CROSS_DIR):$(PATH) -QEMU_VERSION = 9.1.2 +QEMU_VERSION = 9.2.0 default: $(error Please specify a target) @@ -11,6 +11,9 @@ all: do_tools do_limine __clone_all do_binutils do_gcc do_qemu clean: rm -f rep ep + rm -rf binutils-gdb + rm -rf gcc + rm -rf qemu do_tools: gcc -w ReadEthernetPackets.c -o rep @@ -27,12 +30,14 @@ endif __clone_qemu: ifeq ("$(wildcard ./qemu)", "") - wget https://download.qemu.org/qemu-${QEMU_VERSION}.tar.xz - tar xvJf qemu-${QEMU_VERSION}.tar.xz - rm -f qemu-${QEMU_VERSION}.tar.xz - mv qemu-${QEMU_VERSION} qemu + git clone --depth 1 -b v${QEMU_VERSION} --single-branch https://gitlab.com/qemu-project/qemu.git qemu else - $(info > TOOLS: Skipping downloading qemu because directory already exists.) + $(info > TOOLS: Reseting qemu...) + cd qemu && \ + git fetch origin && \ + git reset --hard v${QEMU_VERSION} && \ + git clean -dfx + $(info > TOOLS: Operation completed for qemu) endif .PHONY: all clean __clone_binutils __clone_gcc __prep_cross __patch_cross __patch_cross_binutils __patch_cross_gcc @@ -74,6 +79,10 @@ __patch_cross_gcc: __clone_gcc $(info > TOOLS: Running autoconf for gcc/libstdc++-v3) cd gcc/libstdc++-v3 && autoconf +__patch_cross_qemu: __clone_qemu + $(info > TOOLS: Patching qemu) + cd qemu && git apply ../qemu.patch + __patch_cross: __patch_cross_binutils __patch_cross_gcc __prep_cross: @@ -86,6 +95,8 @@ __clone_all_no_qemu: __clone_binutils __clone_gcc __clone_all: __clone_qemu __clone_all_no_qemu do_qemu: __prep_cross + $(MAKE) __patch_cross_qemu + $(MAKE) __prep_cross cd qemu && \ bash ./configure --target-list=x86_64-softmmu,i386-softmmu,aarch64-softmmu \ --prefix="$(CROSS_DIR)" \ diff --git a/tools/README.md b/tools/README.md index 3752cd6a..06e601bb 100644 --- a/tools/README.md +++ b/tools/README.md @@ -5,5 +5,21 @@ In this directory, you will find: - An error parser for qemu debug output. - Ethernet packet reader for testing network connection. -- A makefile script to clone and build gcc, binutils and qemu. +- A Makefile script to clone, patch and build gcc, binutils and qemu for you. - `website` directory containing the source code for the website. + +## Reasons for the following patches + +- `gcc.patch` + - Required for cross-compiling the OS. + +- `binutils-gdb.patch` + - Same as above. + +- `qemu.patch` + - Removed patch "Replace GDB exit calls with proper shutdown" so when we stop debugging in vscode, the qemu process is automatically killed. + +## Useful links + +- [Create git patches](https://stackoverflow.com/a/15438863/9352057) +- [QEMU git tags](https://gitlab.com/qemu-project/qemu/-/tags) diff --git a/tools/qemu.patch b/tools/qemu.patch new file mode 100644 index 00000000..848aad3f --- /dev/null +++ b/tools/qemu.patch @@ -0,0 +1,22 @@ +diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c +index b1def7e..a02b29a 100644 +--- a/gdbstub/gdbstub.c ++++ b/gdbstub/gdbstub.c +@@ -1438,7 +1438,7 @@ static void handle_v_kill(GArray *params, void *user_ctx) + gdb_put_packet("OK"); + error_report("QEMU: Terminated via GDBstub"); + gdb_exit(0); +- gdb_qemu_exit(0); ++ exit(0); + } + + static const GdbCmdParseEntry gdb_v_commands_table[] = { +@@ -2091,7 +2091,7 @@ static int gdb_handle_packet(const char *line_buf) + /* Kill the target */ + error_report("QEMU: Terminated via GDBstub"); + gdb_exit(0); +- gdb_qemu_exit(0); ++ exit(0); + break; + case 'D': + {