[Modified] update makefile

This commit is contained in:
bLueriVerLHR
2023-07-22 02:02:10 +08:00
parent 82f8712de1
commit 1811d54f49
3 changed files with 21 additions and 22 deletions

View File

@@ -7,30 +7,29 @@ submodue-update-init:
# prepare loongarch toolchain # prepare loongarch toolchain
TOOLCHAIN_PK := loongarch64-linux-gnu/toolchain-loongarch64-linux-gnu-gcc8-host-x86_64-2022-07-18.tar.xz TOOLCHAIN_URL := https://gitee.com/loongson-edu/la32r-toolchains/releases/download/v0.0.2/loongarch32r-linux-gnusf-2022-05-20-x86.tar.gz
LA_GDB_URL := https://gitee.com/loongson-edu/la32r-toolchains/releases/download/v0.0.2/loongarch32r-linux-gnusf-gdb-x86
LA_PATH := ext/toolchain-loongarch64-linux-gnu-gcc8-host-x86_64-2022-07-18/bin TOOLCHAIN_TAR := $(notdir $(TOOLCHAIN_URL))
LA_ARCH := loongarch64-linux-gnu- LA_GDB_TAR := $(notdir $(LA_GDB_URL))
LA := $(LA_PATH)/$(LA_ARCH)
GCC := $(LA)gcc ext/$(TOOLCHAIN_TAR):
OD := $(LA)objdump wget $(TOOLCHAIN_URL)
OC := $(LA)objcopy tar -zxvf $(notdir $@)
RE := $(LA)readelf mv loongarch32r-linux-gnusf-* ext
LA_TOOLS := $(GCC) $(OD) $(OC) $(RE) lagcc: ext/$(TOOLCHAIN_TAR)
unpk-gcc: submodue-update-init LA_ARCH := loongarch32r-linux-gnusf-
mkdir -p ext
tar -xvf $(TOOLCHAIN_PK) -C ext
$(LA_TOOLS): unpk-gcc
# prepare loongarch source code # prepare loongarch source code
xv6: xv6: lagcc
TOOLPREFIX=$(CURDIR)/$(LA) $(MAKE) -C lasoft/xv6-la build TOOLPREFIX=$(CURDIR)/$(shell find ext -type d -name '$(LA_ARCH)*')/bin/$(LA_ARCH) \
$(MAKE) -C lasoft/xv6-la build
xv6-clean: xv6-clean:
$(MAKE) -C lasoft/xv6-la clean $(MAKE) -C lasoft/xv6-la clean
clean-latc:
rm -r ext/*

View File

@@ -30,8 +30,6 @@ OBJS = \
$K/plic.o \ $K/plic.o \
$K/virtio_disk.o $K/virtio_disk.o
# riscv64-unknown-elf- or riscv64-linux-gnu-
# perhaps in /opt/riscv/bin
TOOLPREFIX ?= TOOLPREFIX ?=
CC = $(TOOLPREFIX)gcc CC = $(TOOLPREFIX)gcc
@@ -42,9 +40,10 @@ OBJDUMP = $(TOOLPREFIX)objdump
CFLAGS = -Wall -Werror -O -fno-omit-frame-pointer -ggdb -gdwarf-2 CFLAGS = -Wall -Werror -O -fno-omit-frame-pointer -ggdb -gdwarf-2
CFLAGS += -MD CFLAGS += -MD
CFLAGS += -mcmodel=medany CFLAGS += -mcmodel=normal
CFLAGS += -ffreestanding -fno-common -nostdlib -mno-relax CFLAGS += -ffreestanding -fno-common -nostdlib -mstrict-align
CFLAGS += -I. CFLAGS += -I.
CFLAGS += -mfpu=none -mabi=ilp32s -march=loongarch32r
CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector) CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector)
# Disable PIE when possible (for Ubuntu 16.10 toolchain) # Disable PIE when possible (for Ubuntu 16.10 toolchain)
@@ -58,12 +57,12 @@ endif
LDFLAGS = -z max-page-size=4096 LDFLAGS = -z max-page-size=4096
$K/kernel: $(OBJS) $K/kernel.ld $U/initcode $K/kernel: $(OBJS) $K/kernel.ld $U/initcode
$(LD) $(LDFLAGS) -T $K/kernel.ld -o $K/kernel $(OBJS) $(LD) $(LDFLAGS) -T $K/kernel.ld -o $K/kernel $(OBJS)
$(OBJDUMP) -S $K/kernel > $K/kernel.asm $(OBJDUMP) -S $K/kernel > $K/kernel.asm
$(OBJDUMP) -t $K/kernel | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > $K/kernel.sym $(OBJDUMP) -t $K/kernel | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > $K/kernel.sym
$U/initcode: $U/initcode.S $U/initcode: $U/initcode.S
$(CC) $(CFLAGS) -march=rv64g -nostdinc -I. -Ikernel -c $U/initcode.S -o $U/initcode.o $(CC) $(CFLAGS) -nostdinc -I. -Ikernel -c $U/initcode.S -o $U/initcode.o
$(LD) $(LDFLAGS) -N -e start -Ttext 0 -o $U/initcode.out $U/initcode.o $(LD) $(LDFLAGS) -N -e start -Ttext 0 -o $U/initcode.out $U/initcode.o
$(OBJCOPY) -S -O binary $U/initcode.out $U/initcode $(OBJCOPY) -S -O binary $U/initcode.out $U/initcode
$(OBJDUMP) -S $U/initcode.o > $U/initcode.asm $(OBJDUMP) -S $U/initcode.o > $U/initcode.asm

View File

@@ -1,3 +1,4 @@
#include "csr.h"
# qemu -kernel loads the kernel at 0x80000000 # qemu -kernel loads the kernel at 0x80000000
# and causes each hart (i.e. CPU) to jump there. # and causes each hart (i.e. CPU) to jump there.
# kernel.ld causes the following code to # kernel.ld causes the following code to