summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuinn Stephens <quinn@osmora.org>2025-02-14 16:55:45 -0500
committerIan Moffett <ian@osmora.org>2025-02-14 19:43:38 -0500
commitd8fd1be4f13f8f744b3a6eae1e4e633b405a8419 (patch)
treefcd90f4678ef54b8a6bd6f2d171fef1816b00bd1
parent38021bbed3b2feecb9b103875adf90c877ab2126 (diff)
build: Add Clang/LLVM toolchain support
Added support for building with Clang/LLVM and made it the default since building a cross-compiling toolchain with GCC is generally less efficient. In `configure.ac`, `TOOLCHAIN` must be set to `clang` or `gcc`. Signed-off-by: Quinn Stephens <quinn@osmora.org> Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--Makefile.in25
-rw-r--r--configure.ac4
2 files changed, 21 insertions, 8 deletions
diff --git a/Makefile.in b/Makefile.in
index 01fe328..7783676 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -15,14 +15,25 @@ override KERNEL_DEFINES = $ -DHYRA_VERSION="\"$(HYRA_VERSION)\""\
-DHYRA_ARCH="\"@ARCH@\"" $(shell cat sys/arch/$(ARCH)/conf/GENERIC | tools/kconf/kconf)
######################
-# Binutils stuff
+# Toolchain
######################
-ifeq ($(ARCH), amd64)
- override CC = $(shell pwd)/cross/bin/x86_64-hyra-gcc
- override LD = $(shell pwd)/cross/bin/x86_64-hyra-ld
-else
- override CC = $(shell pwd)/cross/bin/$(ARCH)-hyra-gcc
- override LD = $(shell pwd)/cross/bin/$(ARCH)-hyra-ld
+override TOOLCHAIN = @TOOLCHAIN@
+ifeq ($(TOOLCHAIN), clang)
+ ifeq ($(ARCH), amd64)
+ override CC = clang -target x86_64-none-elf
+ override LD = ld.lld
+ else
+ override CC = clang -target $(ARCH)-none-elf
+ override LD = ld.lld
+ endif
+else ifeq ($(TOOLCHAIN), gcc)
+ ifeq ($(ARCH), amd64)
+ override CC = $(shell pwd)/cross/bin/x86_64-hyra-gcc
+ override LD = $(shell pwd)/cross/bin/x86_64-hyra-ld
+ else
+ override CC = $(shell pwd)/cross/bin/$(ARCH)-hyra-gcc
+ override LD = $(shell pwd)/cross/bin/$(ARCH)-hyra-ld
+ endif
endif
##########################
diff --git a/configure.ac b/configure.ac
index 41333c7..8a9db93 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,7 +7,8 @@ KERN_CFLAGS_AMD64="-fexceptions --std=gnu11 -ffreestanding -fno-stack-protector
-Werror=incompatible-pointer-types -Werror=int-to-pointer-cast \\
-Werror=return-type -Wunused -mabi=sysv -mno-80387 -mno-mmx -mno-3dnow \\
-mno-sse -mno-sse2 -mno-red-zone -mcmodel=kernel -pedantic \\
- -I sys/include/ -I sys/include/lib/ -D_KERNEL -Wno-pointer-sign -MMD"
+ -I sys/include/ -I sys/include/lib/ -D_KERNEL -Wno-pointer-sign -MMD \\
+ -Wno-gnu-zero-variadic-macro-arguments -Wno-language-extension-token -Wno-tautological-constant-out-of-range-compare -Wno-c23-extensions"
QEMU_FLAGS_AMD64="--enable-kvm -monitor stdio \\
-M q35 -m 1G -smp 4 -cpu host \\
@@ -23,5 +24,6 @@ AC_SUBST(KERNEL_CFLAGS, [$KERN_CFLAGS_AMD64])
AC_SUBST(QEMU_FLAGS, [$QEMU_FLAGS_AMD64])
AC_SUBST(QEMU, [qemu-system-x86_64])
AC_SUBST(ARCH, [amd64])
+AC_SUBST(TOOLCHAIN, [clang])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT