Skip to content

Instantly share code, notes, and snippets.

@heatd
Created February 13, 2022 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heatd/d1fb5f267a61b8d1091f7c3b08fd63dd to your computer and use it in GitHub Desktop.
Save heatd/d1fb5f267a61b8d1091f7c3b08fd63dd to your computer and use it in GitHub Desktop.
diff --git a/debug.sh b/debug.sh
index 418dadc..57e68aa 100755
--- a/debug.sh
+++ b/debug.sh
@@ -8,7 +8,7 @@ make -C loader &&
qemu-system-x86_64 -cpu qemu64 \
-drive if=pflash,format=raw,unit=0,file=/usr/share/ovmf/x64/OVMF_CODE.fd,readonly=on \
- -drive if=pflash,format=raw,unit=1,file=OVMF_VARS.fd \
+ #-drive if=pflash,format=raw,unit=1,file=OVMF_VARS.fd \
-net none -drive file=uefi.img,if=ide,format=raw -monitor stdio \
-serial file:sophia.log -d int -no-shutdown -no-reboot -s -S
diff --git a/defaults.mk b/defaults.mk
index 16193f2..3fc2c51 100644
--- a/defaults.mk
+++ b/defaults.mk
@@ -3,18 +3,18 @@
ARCH := x86_64
ABI := elf
TARGET := $(ARCH)-$(ABI)
-CC := $(TARGET)-gcc
-CXX := $(TARGET)-g++
-AS := $(TARGET)-as
-LD := $(TARGET)-ld
+CC := clang
+CXX := clang++
+AS := clang
+LD := ld.bfd
OBJCOPY := objcopy
CFLAGS += -ffreestanding -mno-red-zone -ggdb -std=c2x \
-Wall -Wextra -Werror -fno-stack-protector \
- -Wpedantic
+ -Wpedantic --target=$(ARCH)-$(ABI)
CXXFLAGS += -ffreestanding -mno-red-zone -ggdb \
- -Wall -Wextra -Werror -fno-stack-protector
+ -Wall -Wextra -Werror -fno-stack-protector --target=$(ARCH)-$(ABI)
LDFLAGS += -nostdlib
LIBDIRS += -L$(dir $(shell $(CC) -print-libgcc-file-name))
diff --git a/efi.mk b/efi.mk
index 4067e44..5f34564 100644
--- a/efi.mk
+++ b/efi.mk
@@ -21,7 +21,7 @@ EFILDSCRIPT := $(EFILIBDIR)/elf_$(GNUEFIARCH)_efi.lds
CPPFLAGS += -I$(EFIAPIDIR) -I$(EFIAPIDIR)/protocol -I$(EFIAPIDIR)/$(GNUEFIARCH) \
-DGNU_EFI_USE_MS_ABI -DEFI_CALL_WRAPPER -DEFI_DEBUG
-CFLAGS += -fPIC -fshort-wchar -maccumulate-outgoing-args -mno-avx -mno-sse \
+CFLAGS += -fPIC -fshort-wchar -mno-avx -mno-sse \
-mno-mmx -funsigned-char -Wno-pointer-sign
OBJCOPY.efi = $(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic \
@@ -40,13 +40,13 @@ LINK._efi.so = $(LD) $(LDFLAGS) -znocombreloc -Bsymbolic -shared --no-undefined
%.efi: %_efi.so
$(OBJCOPY.info)
- @$(OBJCOPY.efi)
+ $(OBJCOPY.efi)
%.debug.efi: %_efi.so
$(OBJCOPY.info)
- @$(OBJCOPY.debug.efi)
+ $(OBJCOPY.debug.efi)
%_efi.so: $(EFILDSCRIPT) $(EFICRT)
$(LINK.info)
- @$(LINK._efi.so)
+ $(LINK._efi.so)
diff --git a/kc/core/kprint.c b/kc/core/kprint.c
index 5a0fffd..a088c0c 100644
--- a/kc/core/kprint.c
+++ b/kc/core/kprint.c
@@ -6,13 +6,11 @@
#include <stdint.h>
#include <stdbool.h>
- __attribute__((optimize("O3")))
int kputchar(int c)
{
return serial_putchar(c);
}
- __attribute__((optimize("O3")))
int kputs(const char *s)
{
int count = 0;
diff --git a/kc/core/task.c b/kc/core/task.c
index b825f01..7a96d4b 100644
--- a/kc/core/task.c
+++ b/kc/core/task.c
@@ -71,7 +71,8 @@ static void set_thread_status(enum kc_thread_status status)
unlock_scheduler();
}
-static void idle_task_thread(void)
+__attribute__((used))
+void idle_task_thread(void)
{
kputs("in idle thread\n");
while (1)
diff --git a/rules.mk b/rules.mk
index 2115028..d6ec3f4 100644
--- a/rules.mk
+++ b/rules.mk
@@ -23,15 +23,15 @@ COMPILE.info = $(info $$(CC) $@)
%.o: %.c
$(COMPILE.info)
- @$(COMPILE.c) -MMD -MP
+ $(COMPILE.c) -MMD -MP
%.o: %.cpp
$(COMPILE.info)
- @$(COMPILE.cpp) -MMD -MP
+ $(COMPILE.cpp) -MMD -MP
%.o: %.S
$(COMPILE.info)
- @$(COMPILE.S) -MMD -MP
+ $(COMPILE.S) -MMD -MP
clean:
$(info $$(RM) $(CLEANLIST))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment