aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaghuram Subramani <raghus2247@gmail.com>2025-02-02 09:01:29 -0500
committerRaghuram Subramani <raghus2247@gmail.com>2025-02-02 09:01:29 -0500
commitc216a2000179a133e1e38852f55261f4bf9f08f6 (patch)
tree5598723901bfc557169a0d5294f411294662af10
parentf9d0734cf87f5ed03a57fdd994067dd5f872de78 (diff)
misc: gcc->clang && gas->nasm
-rw-r--r--cmake/toolchain.cmake6
-rw-r--r--kernel/CMakeLists.txt16
-rw-r--r--kernel/boot/gdt/gdt.s20
-rw-r--r--toolchain/cross_gcc.mk72
4 files changed, 14 insertions, 100 deletions
diff --git a/cmake/toolchain.cmake b/cmake/toolchain.cmake
index c5ed2a2..716b5e7 100644
--- a/cmake/toolchain.cmake
+++ b/cmake/toolchain.cmake
@@ -1,6 +1,6 @@
-set(CMAKE_C_COMPILER i686-elf-gcc)
-set(CMAKE_CXX_COMPILER i686-elf-g++)
-set(CMAKE_ASM_COMPILER i686-elf-g++)
+set(CMAKE_C_COMPILER clang)
+set(CMAKE_CXX_COMPILER clang++)
+set(CMAKE_ASM_COMPILER nasm)
set(CMAKE_SYSTEM_PROCESSOR i686)
set(CMAKE_C_COMPILER_TARGET i686-elf)
diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt
index a65d436..bab610e 100644
--- a/kernel/CMakeLists.txt
+++ b/kernel/CMakeLists.txt
@@ -65,18 +65,8 @@ set(LINKER_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/boot/linker.ld")
set(LINKER_FLAGS
-T ${LINKER_SCRIPT}
-nostdlib
-)
-
-execute_process(COMMAND ${CMAKE_CXX_COMPILER}
- -print-file-name=crtbegin.o
- OUTPUT_VARIABLE CRTBEGIN_O
- OUTPUT_STRIP_TRAILING_WHITESPACE
-)
-
-execute_process(COMMAND ${CMAKE_CXX_COMPILER}
- -print-file-name=crtend.o
- OUTPUT_VARIABLE CRTEND_O
- OUTPUT_STRIP_TRAILING_WHITESPACE
+ -fuse-ld=lld
+ --target=i686-elf
)
add_library(crti OBJECT boot/init/crti.s)
@@ -94,9 +84,7 @@ set(CRTN_O "${CRTN_OUT}/CMakeFiles/crtn.dir/${CRTN_SRC}.o")
# FIXME: This isn't a good way of setting the link order.
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_COMPILER} <CMAKE_CXX_LINK_FLAGS> <FLAGS> <LINK_FLAGS> \
${CRTI_O} \
- ${CRTBEGIN_O} \
<OBJECTS> \
- ${CRTEND_O} \
${CRTN_O} \
-o <TARGET> <LINK_LIBRARIES>"
)
diff --git a/kernel/boot/gdt/gdt.s b/kernel/boot/gdt/gdt.s
index ee50e4e..d1d768c 100644
--- a/kernel/boot/gdt/gdt.s
+++ b/kernel/boot/gdt/gdt.s
@@ -1,26 +1,24 @@
-.intel_syntax noprefix
-
.global _GDT_flush
.type _GDT_flush, @function
_GDT_flush:
/* First Argument (Pointer to the GDT) */
- mov eax, [esp + 4]
+ movl 4(%esp), %eax
/* Load GDT */
- lgdt [eax]
+ lgdt (%eax)
/* Offset For Kernel Data Segment (16 bits) */
- mov eax, 0x10
+ mov $0x10, %eax
/* Set the Data Segment Selectors */
- mov ds, ax
- mov es, ax
- mov fs, ax
- mov gs, ax
- mov ss, ax
+ mov %ax, %ds
+ mov %ax, %es
+ mov %ax, %fs
+ mov %ax, %gs
+ mov %ax, %ss
/* Set the Code Segment Selector */
- jmp 0x08:.flush
+ jmp $0x08, $.flush
.flush:
ret
diff --git a/toolchain/cross_gcc.mk b/toolchain/cross_gcc.mk
deleted file mode 100644
index 64e6e83..0000000
--- a/toolchain/cross_gcc.mk
+++ /dev/null
@@ -1,72 +0,0 @@
-#
-# bubbl
-# Copyright (C) 2024-2025 Raghuram Subramani <raghus2247@gmail.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-
-include utils.mk
-
-VERSION := 14.2.0
-URL := https://ftp.gnu.org/gnu/gcc/gcc-$(VERSION)/gcc-$(VERSION).tar.gz
-
-DIR := $(BUILD_DIR)/toolchain/gcc-$(VERSION)
-FILE := $(DIR)/gcc-$(VERSION).tar.gz
-SRC := $(DIR)/gcc-$(VERSION)
-OUT := $(OUT_DIR)/cross
-BUILD := $(DIR)/build_cross
-
-TOOLCHAIN_TARGET := i686-elf
-
-all: install
-
-.ONESHELL:
-
-$(call add-to-path,$(shell pwd)/cross/bin)
-$(call add-to-path,$(shell pwd)/host/bin)
-
-$(FILE):
- mkdir -p $(DIR)
- wget $(URL) -O $(FILE)
-
-unpack: $(FILE)
- tar xf $(FILE) -C $(DIR)
-
-configure: unpack
- cd $(SRC)
- ./contrib/download_prerequisites
- mkdir -p $(BUILD)
- cd $(BUILD)
- $(SRC)/configure \
- --prefix=$(OUT) \
- --target=$(TOOLCHAIN_TARGET) \
- --disable-nls \
- --enable-languages=c,c++ \
- --without-headers \
- --disable-hosted-libstdcxx
-
-build: configure
- cd $(BUILD)
- $(MAKE) -j$(PARALLEL_CORES) all-gcc
- $(MAKE) -j$(PARALLEL_CORES) all-target-libgcc
- $(MAKE) -j$(PARALLEL_CORES) all-target-libstdc++-v3
-
-install: build
- cd $(BUILD)
- $(MAKE) install-gcc
- $(MAKE) install-target-libgcc
- $(MAKE) install-target-libstdc++-v3
-
-clean:
- rm -rf $(DIR) $(FILE) $(OUT)