mirror of
https://github.com/panpaul/tiny_os
synced 2024-09-20 09:45:19 +08:00
77 lines
2.2 KiB
Makefile
77 lines
2.2 KiB
Makefile
ARCH ?= riscv64
|
|
|
|
ifeq ($(ARCH), riscv64)
|
|
BUILD_TARGET := riscv64imac-unknown-none-elf
|
|
LINKER_LDS := kernel/src/arch/riscv/linker64.ld
|
|
else
|
|
$(error Invalid TARGET: $(ARCH))
|
|
endif
|
|
|
|
RUSTFLAGS += -Crelocation-model=static
|
|
RUSTFLAGS += -Ccode-model=medium
|
|
#RUSTFLAGS += -Ctarget-feature=+relax
|
|
RUSTFLAGS += -Cforce-frame-pointers=yes
|
|
RUSTFLAGS += -Clink-arg=-T$(LINKER_LDS)
|
|
|
|
CARGO_TARGET_ARGS := --target=$(BUILD_TARGET)
|
|
|
|
CARGO_BUILD_ARGS += -Zbuild-std=core,compiler_builtins,alloc
|
|
CARGO_BUILD_ARGS += -Zbuild-std-features=compiler-builtins-mem
|
|
CARGO_BUILD_ARGS += $(CARGO_TARGET_ARGS)
|
|
|
|
kernel:
|
|
env RUSTFLAGS="$(RUSTFLAGS)" cargo build --bin kernel $(CARGO_BUILD_ARGS)
|
|
|
|
clippy:
|
|
cargo clippy -p allocator
|
|
cargo clippy -p utils
|
|
cargo clippy --no-deps $(CARGO_TARGET_ARGS) --manifest-path=kernel/Cargo.toml
|
|
|
|
test:
|
|
cargo test -p allocator
|
|
cargo test -p utils
|
|
env RUSTFLAGS="$(RUSTFLAGS)" cargo test $(CARGO_TARGET_ARGS) --bin=kernel
|
|
|
|
kernel-test-dump:
|
|
@env RUSTFLAGS="$(RUSTFLAGS)" cargo test $(CARGO_TARGET_ARGS) --bin=kernel --no-run --message-format=json
|
|
|
|
kernel-asm: kernel
|
|
riscv64-elf-objdump -d target/$(BUILD_TARGET)/debug/kernel | c++filt -t > kernel.asm
|
|
|
|
build-target:
|
|
@echo $(BUILD_TARGET)
|
|
|
|
clean:
|
|
cargo clean
|
|
|
|
qemu: kernel
|
|
qemu-system-$(ARCH) \
|
|
-nographic -machine virt -serial mon:stdio -smp 1 \
|
|
-kernel target/$(BUILD_TARGET)/debug/kernel
|
|
|
|
qemu-gdb: kernel
|
|
qemu-system-$(ARCH) \
|
|
-nographic -machine virt -serial mon:stdio -smp 1 \
|
|
-kernel target/$(BUILD_TARGET)/debug/kernel \
|
|
-s -S
|
|
|
|
replay.qcow2:
|
|
qemu-img create -f qcow2 replay.qcow2 1G
|
|
|
|
qemu-record: kernel replay.qcow2
|
|
qemu-system-$(ARCH) \
|
|
-nographic -machine virt -serial mon:stdio -smp 1 \
|
|
-kernel target/$(BUILD_TARGET)/debug/kernel \
|
|
-icount shift=auto,rr=record,rrfile=replay.bin,rrsnapshot=init \
|
|
-drive file=replay.qcow2,if=none,id=rr
|
|
|
|
qemu-replay: kernel replay.qcow2
|
|
qemu-system-$(ARCH) \
|
|
-nographic -machine virt -serial mon:stdio -smp 1 \
|
|
-kernel target/$(BUILD_TARGET)/debug/kernel \
|
|
-icount shift=auto,rr=replay,rrfile=replay.bin,rrsnapshot=init \
|
|
-drive file=replay.qcow2,if=none,id=rr \
|
|
-s -S
|
|
|
|
.PHONY: kernel clippy test kernel-test-dump kernel-asm build-target clean qemu qemu-gdb qemu-record qemu-replay
|