-
Notifications
You must be signed in to change notification settings - Fork 23
Support LLVM Toolchain #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,27 +17,49 @@ DEFINES := -DF_CPU=$(F_CLK) \ | |
-DF_TIMER=$(F_TICK) \ | ||
-include config.h | ||
|
||
ASFLAGS = -march=rv32imzicsr -mabi=ilp32 | ||
CFLAGS += -Wall -Wextra -Wshadow -Wno-unused-parameter -Werror | ||
CROSS_COMPILE ?= riscv32-unknown-elf- | ||
CC_DEFAULT := $(CROSS_COMPILE)gcc | ||
CC_IS_CLANG := $(shell $(CC_DEFAULT) --version 2>/dev/null | grep -qi clang && echo 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find this approach a bit odd. Why append the gcc suffix and then check for clang? It feels a bit roundabout. |
||
# Architecture flags | ||
ARCH_FLAGS = -march=rv32imzicsr -mabi=ilp32 | ||
|
||
# Common compiler flags | ||
CFLAGS += -Wall -Wextra -Werror -Wshadow -Wno-unused-parameter | ||
CFLAGS += -O2 -std=gnu99 | ||
CFLAGS += -march=rv32imzicsr -mabi=ilp32 | ||
CFLAGS += $(ARCH_FLAGS) | ||
CFLAGS += -mstrict-align -ffreestanding -nostdlib -fomit-frame-pointer | ||
CFLAGS += $(INC_DIRS) $(DEFINES) -fdata-sections -ffunction-sections | ||
ARFLAGS = r | ||
|
||
# Linker flags | ||
LDFLAGS = -melf32lriscv --gc-sections | ||
LDSCRIPT = $(ARCH_DIR)/riscv32-qemu.ld | ||
ifeq ($(CC_IS_CLANG),1) | ||
CC = $(CROSS_COMPILE)clang | ||
AS = $(CROSS_COMPILE)clang | ||
LD = $(CROSS_COMPILE)ld.lld | ||
DUMP = $(CROSS_COMPILE)llvm-objdump -M no-aliases | ||
READ = $(CROSS_COMPILE)llvm-readelf | ||
OBJ = $(CROSS_COMPILE)llvm-objcopy | ||
SIZE = $(CROSS_COMPILE)llvm-size | ||
|
||
CFLAGS += --target=riscv32-unknown-elf | ||
CFLAGS += -Wno-unused-command-line-argument | ||
ASFLAGS = --target=riscv32-unknown-elf | ||
LDFLAGS = -m elf32lriscv | ||
else | ||
CC = $(CC_DEFAULT) | ||
AS = $(CROSS_COMPILE)as | ||
LD = $(CROSS_COMPILE)ld | ||
DUMP = $(CROSS_COMPILE)objdump -Mno-aliases | ||
READ = $(CROSS_COMPILE)readelf | ||
OBJ = $(CROSS_COMPILE)objcopy | ||
SIZE = $(CROSS_COMPILE)size | ||
LDFLAGS = -melf32lriscv | ||
endif | ||
|
||
CROSS_COMPILE ?= riscv-none-elf- | ||
CC = $(CROSS_COMPILE)gcc | ||
AS = $(CROSS_COMPILE)as | ||
LD = $(CROSS_COMPILE)ld | ||
DUMP = $(CROSS_COMPILE)objdump -Mno-aliases | ||
READ = $(CROSS_COMPILE)readelf | ||
OBJ = $(CROSS_COMPILE)objcopy | ||
SIZE = $(CROSS_COMPILE)size | ||
AR = $(CROSS_COMPILE)ar | ||
AR = $(CROSS_COMPILE)ar | ||
ASFLAGS += $(ARCH_FLAGS) | ||
LDFLAGS += --gc-sections | ||
|
||
ARFLAGS = r | ||
LDSCRIPT = $(ARCH_DIR)/riscv32-qemu.ld | ||
|
||
HAL_OBJS := boot.o hal.o muldiv.o | ||
HAL_OBJS := $(addprefix $(BUILD_KERNEL_DIR)/,$(HAL_OBJS)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,15 +34,15 @@ static inline uint16_t pipe_free_space_internal(const pipe_t *p) | |
return (p->mask + 1) - p->used; | ||
} | ||
|
||
static inline char pipe_get_byte(pipe_t *p) | ||
static inline __attribute__((__unused__)) char pipe_get_byte(pipe_t *p) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simply do |
||
{ | ||
char val = p->buf[p->head]; | ||
p->head = (p->head + 1) & p->mask; | ||
p->used--; | ||
return val; | ||
} | ||
|
||
static inline void pipe_put_byte(pipe_t *p, char c) | ||
static inline __attribute__((__unused__)) void pipe_put_byte(pipe_t *p, char c) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like these two functions have no callers. |
||
{ | ||
p->buf[p->tail] = c; | ||
p->tail = (p->tail + 1) & p->mask; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set the default value to
riscv-none-elf-
as xPack GNU RISC-V Embedded GCC is suggested.