From e134202611a50b358c147c92bfb8a7f443030b8b Mon Sep 17 00:00:00 2001 From: Kimplul Date: Mon, 8 Jul 2024 17:43:59 +0300 Subject: fix LLVM + Anything extern is right out as LLVM doesn't produce correct code for them. Maybe if I added some extra attributes but I'm skeptical. Replaced with static variables and getters/setters. + Inline ASM is apparently a bit buggy, so use an assembly stub when jumping to init. + Minimize work done in main() to minimize chance of LLVM doing something silly. Still not 100% certain that I shouldn't just write the main() as an assembly stub in arch/riscv64 to be absolutely sure everything works as intended. + Make .kernel.start section SHF_ALLOC, otherwise lld complains about pc-relative addressing Probably some other stuff as well that I'm forgetting right now. But at least with LLVM14 LTO seems to work, which is pretty cool? --- arch/riscv64/source.mk | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'arch/riscv64/source.mk') diff --git a/arch/riscv64/source.mk b/arch/riscv64/source.mk index 6e72c85..0c10bbc 100644 --- a/arch/riscv64/source.mk +++ b/arch/riscv64/source.mk @@ -1,15 +1,9 @@ KERNEL_LOCAL != echo $(ARCH_SOURCE)/kernel/*.[cS] -KERNEL_SOURCES += $(KERNEL_LOCAL) -INIT_SOURCES += $(ARCH_SOURCE)/init/*.[cS] +KERNEL_SOURCES := $(KERNEL_SOURCES) $(KERNEL_LOCAL) # this doesn't work for rv32, but fine for now */ ARCH_CFLAGS := $(ARCH_CFLAGS) -mcmodel=medany -# oof, LLVM's riscv support has become better since I last looked into -# it, but for some reason LTO still causes a crash. Meaning it has to be -# disabled again, though for a different reason than last time -OPTFLAGS != [ "$(LLVM)" != "0" ] && echo $(OPTFLAGS:-flto=) || echo $(OPTFLAGS) - run: $(ARCH_SOURCE)/conf/mkimage.sh $(ARCH) -- cgit v1.3