Merge pull request #2 from OrichalcumCosmonaut/patch-2
add clang support
This commit is contained in:
commit
09436f0309
30
Makefile
30
Makefile
|
@ -1,16 +1,28 @@
|
|||
CODE=src/
|
||||
CROSS_COMPILE=riscv64-unknown-elf-
|
||||
CC=$(CROSS_COMPILE)gcc
|
||||
GDB=$(CROSS_COMPILE)gdb
|
||||
CFLAGS=-march=rv64gc -mabi=lp64d -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles -Tkernel.ld -g -Wall -Wextra
|
||||
EMU=qemu-system-riscv64
|
||||
EFLAGS=-machine virt -cpu rv64 -bios opensbi-riscv64-generic-fw_dynamic.bin -m 256m -nographic -global virtio-mmio.force-legacy=false -s #-S
|
||||
TARGET = riscv64-unknown-elf
|
||||
CC = $(TARGET)-gcc
|
||||
GDB = $(TARGET)-gdb
|
||||
EMU = qemu-system-riscv64
|
||||
|
||||
.PHONY: all clean run
|
||||
CODE = src/
|
||||
|
||||
CFLAGS = -march=rv64gc -mabi=lp64d -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles -Tkernel.ld -g -Wall -Wextra
|
||||
ifeq ($(CC),clang)
|
||||
CFLAGS += -target $(TARGET) -mno-relax -Wno-unused-command-line-argument
|
||||
endif
|
||||
|
||||
EFLAGS = -machine virt -cpu rv64 -bios opensbi-riscv64-generic-fw_dynamic.bin -m 256m -nographic -global virtio-mmio.force-legacy=false -s
|
||||
ifdef WAIT_GDB
|
||||
EFLAGS += -S
|
||||
endif
|
||||
|
||||
.PHONY: all clean run gdb
|
||||
|
||||
all: $(CODE)*.s $(CODE)*.c
|
||||
$(CC) $(CFLAGS) $? -o kernel
|
||||
|
||||
|
||||
clean:
|
||||
-rm kernel
|
||||
|
||||
run:
|
||||
$(EMU) $(EFLAGS) -kernel kernel
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
# example-os
|
||||
An example bare bones OS template for RISC V.
|
||||
An example bare bones OS template for RISC-V.
|
||||
|
||||
## Build instructions
|
||||
Install [the Newlib GNU RISC V toolchain](https://github.com/riscv/riscv-gnu-toolchain#installation-newlib) and do `make` to build. Do `make run` to run. It should print out a bunch of debug information related to OpenSBI and then a single `a`.
|
||||
Install [the Newlib GNU RISC-V toolchain](https://github.com/riscv/riscv-gnu-toolchain#installation-newlib) and do `make` to build. Do `make run` to run. It should print out a bunch of debug information related to OpenSBI and then a single `a`.
|
||||
|
||||
Alternatively, you can install Clang and use `make CC=clang`.
|
||||
|
||||
## Exiting QEMU
|
||||
This is the new "how to exit Vi" I guess. To exit, press control+a, unpress those keys, and then press x.
|
||||
|
@ -10,7 +12,7 @@ This is the new "how to exit Vi" I guess. To exit, press control+a, unpress thos
|
|||
## Debugging
|
||||
Execute `make gdb` and then `make run`.
|
||||
|
||||
If you'd like to trace the execution since the beginning, uncomment the `# -S` at the end of the line in the makefile and run. This halts the emulator until a gdb connection is established.
|
||||
If you'd like to trace the execution since the beginning, use `make run WAIT_GDB=1`. This halts the emulator until a gdb connection is established.
|
||||
|
||||
## Resources
|
||||
- [OpenSBI docs](https://github.com/riscv/riscv-sbi-doc/blob/master/riscv-sbi.adoc)
|
||||
|
|
Reference in New Issue