From c4a20eef72e674007b1f250465ed338a2eeda686 Mon Sep 17 00:00:00 2001 From: kheersagar patel <75828030+kheersagarpatel@users.noreply.github.com> Date: Thu, 30 Jul 2026 18:56:34 +0530 Subject: [PATCH] fix(kernel,boot): improve GCC/Clang compatibility across kernel and boot components - Add compiler and architecture guards for platform-specific headers - Replace compiler-specific _va_list_ with standard va_list - Fix invalid return statements in non-void process wait functions - Correct the _MSC_VER preprocessor check - Remove an unnecessary host Linux header dependency - Update AArch64 Makefiles for consistent GCC toolchain builds --- BaseHdr/Hal/x86_64_gdt.h | 4 ++++ BaseHdr/timer.h | 4 ++++ Boot/xnldr.cpp | 2 +- BootAA64/Makefile | 3 ++- BootAA64/xnldr.h | 4 ++++ Kernel/Hal/serial.cpp | 2 +- Kernel/_CRT.cpp | 4 ++++ Kernel/process.cpp | 2 +- KernelAA64/Makefile | 1 + KernelAA64/init.c | 1 - KernelAA64/process.c | 4 ++-- Process/DeodhaiXR/alpha.cpp | 2 ++ Process/DeodhaiXR/main.cpp | 2 ++ Process/XELnch/rrect.cpp | 4 +++- 14 files changed, 31 insertions(+), 8 deletions(-) diff --git a/BaseHdr/Hal/x86_64_gdt.h b/BaseHdr/Hal/x86_64_gdt.h index cfef95060..da1b5030d 100644 --- a/BaseHdr/Hal/x86_64_gdt.h +++ b/BaseHdr/Hal/x86_64_gdt.h @@ -31,7 +31,11 @@ #define __X86_64_GDT_H__ #include +#if defined(__GNUC__) || defined(__clang__) +#ifndef __cplusplus #include +#endif +#endif #define GDT_ENTRY_NULL 0 #define GDT_ENTRY_KERNEL_CODE 1 diff --git a/BaseHdr/timer.h b/BaseHdr/timer.h index 32aab266a..cd2676e55 100644 --- a/BaseHdr/timer.h +++ b/BaseHdr/timer.h @@ -33,7 +33,11 @@ #define __TIMER_H__ #include +#ifdef ARCH_X64 +#include +#elif ARCH_ARM64 #include +#endif #if defined(__GNUC__) || defined(__clang__) #ifndef __cplusplus #include diff --git a/Boot/xnldr.cpp b/Boot/xnldr.cpp index e41d74c73..9f6dcbd16 100644 --- a/Boot/xnldr.cpp +++ b/Boot/xnldr.cpp @@ -260,7 +260,7 @@ EFI_STATUS efi_main_handler(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTabl *------------------------------------------------------------------- */ void* xdsp_address = NULL; -#ifdef __MSC_VER +#ifdef _MSC_VER static EFI_GUID acpi_guid = EFI_ACPI_20_TABLE_GUID; #else static EFI_GUID acpi_guid = ACPI_20_TABLE_GUID; diff --git a/BootAA64/Makefile b/BootAA64/Makefile index 4b3306a48..3572f281a 100644 --- a/BootAA64/Makefile +++ b/BootAA64/Makefile @@ -1,4 +1,5 @@ # Target EFI binary +.DEFAULT_GOAL := all TARGET_EFI = BOOTAA64.efi TARGET_SO = BOOTAA64.so @@ -84,7 +85,7 @@ $(EFI_OUTPUT): $(OBJS) else # Original GCC compilation $(SO_OUTPUT): $(CRT0) $(OBJS) - $(LD) -nostdlib --warn-common --no-undefined --build-id=sha1 -z noexecstack -z max-page-size=4096 \ + $(LD) -nostdlib --warn-common --no-undefined --build-id=sha1 -z muldefs -z noexecstack -z max-page-size=4096 \ -shared -Bsymbolic $(LIBDIRS) -T$(LDSCRIPT) $(CRT0) $(OBJS) -o $@ $(LIBS) $(EFI_OUTPUT): $(SO_OUTPUT) diff --git a/BootAA64/xnldr.h b/BootAA64/xnldr.h index 8b89b863a..20359ec26 100644 --- a/BootAA64/xnldr.h +++ b/BootAA64/xnldr.h @@ -34,7 +34,11 @@ #include #include +#if defined(__GNUC__) || defined(__clang__) +#ifndef __cplusplus #include +#endif +#endif #ifndef SIZE_MAX #if defined(ARCH_ARM64) || defined(ARCH_X64) || defined(_M_AMD64) || defined(_M_ARM64) || defined(__x86_64__) || defined(__aarch64__) #define SIZE_MAX 0xFFFFFFFFFFFFFFFFULL diff --git a/Kernel/Hal/serial.cpp b/Kernel/Hal/serial.cpp index a95cdf29e..ee65d8274 100644 --- a/Kernel/Hal/serial.cpp +++ b/Kernel/Hal/serial.cpp @@ -80,7 +80,7 @@ void DebugSerial(char* string) { */ AU_EXTERN AU_EXPORT void SeTextOut(char* format, ...) { - _va_list_ args; + va_list args; va_start(args, format); while (*format) diff --git a/Kernel/_CRT.cpp b/Kernel/_CRT.cpp index 8d9a9cfdb..48017c24c 100644 --- a/Kernel/_CRT.cpp +++ b/Kernel/_CRT.cpp @@ -30,7 +30,11 @@ #include +#if defined(__GNUC__) || defined(__clang__) +#ifndef __cplusplus #include +#endif +#endif extern "C" int _fltused = 1; diff --git a/Kernel/process.cpp b/Kernel/process.cpp index 1bfcf9bf8..4e0803ec8 100644 --- a/Kernel/process.cpp +++ b/Kernel/process.cpp @@ -407,7 +407,7 @@ int AuProcessWaitForTermination(AuProcess *proc, int pid) { else { AuProcess* proc = AuProcessFindByPID(0,pid); if (!proc) - return; + return -1; AuThread* thr = AuGetCurrentThread(); AuBlockThread(thr); list_add(proc->waitlist, thr); diff --git a/KernelAA64/Makefile b/KernelAA64/Makefile index d43929072..5c9898ac7 100644 --- a/KernelAA64/Makefile +++ b/KernelAA64/Makefile @@ -1,4 +1,5 @@ # XenevaOS KernelAA64 Makefile +.DEFAULT_GOAL := all TARGET = KernelAA64.elf OBJDIR = obj diff --git a/KernelAA64/init.c b/KernelAA64/init.c index ddd8d644e..3b4a89e08 100644 --- a/KernelAA64/init.c +++ b/KernelAA64/init.c @@ -69,7 +69,6 @@ #include #include #include -#include extern int _fltused = 1; static bool _littleboot_used; diff --git a/KernelAA64/process.c b/KernelAA64/process.c index ff4bdf3da..4ab44da23 100644 --- a/KernelAA64/process.c +++ b/KernelAA64/process.c @@ -402,7 +402,7 @@ void AuProcessFreeKeResource(AA64Thread* thr) { * @param proc -- process to exit * @param schedulable -- schedule to next thread */ -void AuProcessExit(AuProcess* proc, BOOL schedulable) { +void AuProcessExit(AuProcess* proc, bool schedulable) { if (proc == root_proc) { UARTDebugOut("[aurora]: cannot exit root process \r\n"); return; @@ -515,7 +515,7 @@ int AuProcessWaitForTermination(AuProcess* proc, int pid) { else { AuProcess* proc = AuProcessFindByPID(0, pid); if (!proc) - return; + return -1; AA64Thread* thr = AuGetCurrentThread(); AuBlockThread(thr); list_add(proc->waitlist, thr); diff --git a/Process/DeodhaiXR/alpha.cpp b/Process/DeodhaiXR/alpha.cpp index a609ede6d..7053d9fe4 100644 --- a/Process/DeodhaiXR/alpha.cpp +++ b/Process/DeodhaiXR/alpha.cpp @@ -32,8 +32,10 @@ #include "deodxr.h" #include "alpha.h" #if defined(ARCH_ARM64) +#ifdef ARCH_ARM64 #include #endif +#endif #include #include "window.h" #include diff --git a/Process/DeodhaiXR/main.cpp b/Process/DeodhaiXR/main.cpp index 82c834929..03e9d5eaf 100644 --- a/Process/DeodhaiXR/main.cpp +++ b/Process/DeodhaiXR/main.cpp @@ -51,7 +51,9 @@ #include "animation.h" #include "alpha.h" #include "nanojpg.h" +#ifdef ARCH_ARM64 #include +#endif #include "compose.h" #include diff --git a/Process/XELnch/rrect.cpp b/Process/XELnch/rrect.cpp index d86d7eab7..d8608f30a 100644 --- a/Process/XELnch/rrect.cpp +++ b/Process/XELnch/rrect.cpp @@ -1,4 +1,6 @@ -#include +#ifdef ARCH_ARM64 +#include +#endif #include #include