aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2022-05-05 23:19:42 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2022-05-05 23:19:42 +0300
commit5fb1af3ab12880331fb1e2150aa23b1278e60ddd (patch)
tree3e905ee027369f01611edbc1b1a1a00e9a30dc41 /arch
parent9273c16434316a8ab60dc78ee65a03e68031203a (diff)
downloadkmi-5fb1af3ab12880331fb1e2150aa23b1278e60ddd.tar.gz
kmi-5fb1af3ab12880331fb1e2150aa23b1278e60ddd.zip
riscv64 boots with clang (sort of)
Diffstat (limited to 'arch')
-rw-r--r--arch/riscv64/gen/asm-offsets.c2
-rw-r--r--arch/riscv64/gen/source.mk4
-rw-r--r--arch/riscv64/source.mk18
3 files changed, 12 insertions, 12 deletions
diff --git a/arch/riscv64/gen/asm-offsets.c b/arch/riscv64/gen/asm-offsets.c
index d78e0ec..6920245 100644
--- a/arch/riscv64/gen/asm-offsets.c
+++ b/arch/riscv64/gen/asm-offsets.c
@@ -3,7 +3,7 @@
/* largely based on linux */
#define DEFINE(sym, val) \
- __asm__ volatile("\n-> " #sym " %0 " #val "\n" ::"i"(val))
+ __asm__ volatile("\n#-> " #sym " %0 " #val "\n" ::"i"(val))
#define OFFSETOF(m, s) DEFINE(offsetof_##m, offsetof(s, m))
#define SIZEOF(n, s) DEFINE(sizeof_##n, sizeof(s))
diff --git a/arch/riscv64/gen/source.mk b/arch/riscv64/gen/source.mk
index d291983..596255f 100644
--- a/arch/riscv64/gen/source.mk
+++ b/arch/riscv64/gen/source.mk
@@ -1,8 +1,8 @@
$(ARCH_SOURCE)/include/gen/asm-offsets.h: $(ARCH_SOURCE)/gen/asm-offsets.c
echo "#ifndef APOS_ASM_OFFSETS_H" > $@
echo "#define APOS_ASM_OFFSETS_H" >> $@
- $(COMPILER) $(INCLUDE_FLAGS) -S $< -o - |\
- awk '($$1 == "->") { print "#define " $$2 " " $$3 }' >> $@
+ $(COMPILER) $(DEPFLAGS) $(INCLUDE_FLAGS) -S $< -o - |\
+ awk '($$1 == "#->") { print "#define " $$2 " " $$3 }' >> $@
echo "#endif /* APOS_ASM_OFFSETS_H */" >> $@
CLEANUP += $(ARCH_SOURCE)/include/gen/*
diff --git a/arch/riscv64/source.mk b/arch/riscv64/source.mk
index 8c1dfcb..fcb7f69 100644
--- a/arch/riscv64/source.mk
+++ b/arch/riscv64/source.mk
@@ -3,17 +3,17 @@ KERNEL_SOURCES += $(KERNEL_LOCAL)
INIT_SOURCES += $(ARCH_SOURCE)/init/*.[cS]
# this doesn't work for rv32, but fine for now */
-CLEANUP_CMD := $(ARCH_SOURCE)/conf/rmimage.sh
-
ARCH_CFLAGS := -mcmodel=medany
-ARCH_LDFLAGS :=
+ARCH_LDFLAGS := -fuse-ld=bfd
+
+# slightly hacky but bfd is currently the only compiler that correctly handles
+# riscv relocations, but it doesn't recognise LLVM lto files, so if we're
+# doing an LLVM compilation, remove lto support
+DEBUGFLAGS != [ $(LLVM) ] && echo $(DEBUGFLAGS:-flto=) || echo $(DEBUGFLAGS)
-# llvm compilation doesn't seem to work, either bfd reads the object files wrong
-# and outputs incorrect symbols or lld handles relocations in a dumb way. Only
-# GCC compiles the kernel correctly at the moment (on RISCV, at least). I'll
-# look into this later, but for now I'll just use GCC. The code does _compile_
-# with clang, it just won't link.
-#LINKFLAGS := -fuse-ld=bfd
+# llvm-objcopy is buggy, use gnu tools instead
+# christ, not much LLVM tooling available for RISCV :D
+OBJCOPY := $(CROSS_COMPILE)-objcopy
run:
$(ARCH_SOURCE)/conf/mkimage.sh