Skip to content

Commit 98a261e

Browse files
committed
Updated Supporting Build Scripts
1 parent 3308ca8 commit 98a261e

4 files changed

Lines changed: 17 additions & 19 deletions

File tree

.github/workflows/cmake.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,18 @@ jobs:
3939
mkdir -p assets
4040
wget -O assets/smollm2.gguf https://huggingface.co/bartowski/SmolLM2-135M-Instruct-GGUF/resolve/main/SmolLM2-135M-Instruct-Q4_K_M.gguf
4141
42-
- name: Configure CMake
42+
- name: Build BasicallyLinux
4343
run: |
44-
cmake -B build \
45-
-DCMAKE_C_COMPILER=i686-linux-gnu-gcc \
46-
-DCMAKE_ASM_NASM_COMPILER=nasm \
47-
-DCMAKE_BUILD_TYPE=Release
44+
mkdir -p build
45+
cd build
46+
# Force the assembler and compiler to 32-bit mode
47+
cmake .. -DCMAKE_ASM_NASM_FLAGS="-f elf32" -DCMAKE_C_FLAGS="-m32"
48+
make
4849
49-
- name: Build BasicallyLinux
50+
- name: Verify Kernel Architecture
5051
run: |
51-
cmake --build build
52+
file build/kernel.bin
53+
i686-linux-gnu-objdump -f build/kernel.bin | grep "architecture: i386"
5254
5355
- name: Archive Artifacts
5456
if: success()

CMakeLists.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
cmake_minimum_required(VERSION 3.16)
22

3-
# Set NASM flags BEFORE the project() call to ensure they are used during initialization
4-
set(CMAKE_ASM_NASM_FLAGS "-f elf32" CACHE STRING "NASM flags" FORCE)
3+
# Force the NASM object format to 32-bit ELF
4+
set(CMAKE_ASM_NASM_OBJECT_FORMAT elf32)
5+
set(CMAKE_ASM_NASM_FLAGS "-f elf32")
56

67
project(BasicallyLinux C ASM_NASM)
78

@@ -31,11 +32,6 @@ include_directories(include)
3132
file(GLOB_RECURSE ASM_SOURCES "src/*.asm")
3233
file(GLOB_RECURSE C_SOURCES "src/*.c")
3334

34-
# Force -f elf32 on all assembly files explicitly as well
35-
foreach(asm_file ${ASM_SOURCES})
36-
set_source_files_properties(${asm_file} PROPERTIES COMPILE_FLAGS "-f elf32")
37-
endforeach()
38-
3935
# Exclude specific files if needed
4036
list(FILTER C_SOURCES EXCLUDE REGEX "src/drivers/vga.c")
4137

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ BUILD_DIR := build
1212
MODEL_BLOB := $(firstword $(wildcard assets/smollm2.gguf) $(wildcard assets/smollm-135m.gguf) $(wildcard assets/SmolLM2-135M-Instruct-Q4_K_M.gguf))
1313
MODEL_OBJ := $(BUILD_DIR)/model.o
1414

15-
ASM_SRCS := $(shell find $(SRC_DIR) -name "*.s")
15+
ASM_SRCS := $(shell find $(SRC_DIR) -name "*.asm")
1616
C_SRCS := $(filter-out $(SRC_DIR)/drivers/vga.c, $(shell find $(SRC_DIR) -name "*.c"))
1717

18-
ASM_OBJS := $(patsubst $(SRC_DIR)/%.s,$(BUILD_DIR)/%.s.o,$(ASM_SRCS))
18+
ASM_OBJS := $(patsubst $(SRC_DIR)/%.asm,$(BUILD_DIR)/%.asm.o,$(ASM_SRCS))
1919
C_OBJS := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.c.o,$(C_SRCS))
2020

21-
BOOT_OBJ := $(BUILD_DIR)/boot.s.o
21+
BOOT_OBJ := $(BUILD_DIR)/boot.asm.o
2222
OTHER_OBJS := $(sort $(filter-out $(BOOT_OBJ),$(ASM_OBJS) $(C_OBJS)))
2323
OBJS := $(BOOT_OBJ) $(OTHER_OBJS)
2424

@@ -31,7 +31,7 @@ all: $(BUILD_DIR) kernel.bin
3131
$(BUILD_DIR):
3232
mkdir -p $(BUILD_DIR)
3333

34-
$(BUILD_DIR)/%.s.o: $(SRC_DIR)/%.s
34+
$(BUILD_DIR)/%.asm.o: $(SRC_DIR)/%.asm
3535
mkdir -p $(dir $@)
3636
$(AS) $(ASFLAGS) $< -o $@
3737

build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ if (-not (Test-Path $buildDir)) {
6363
New-Item -ItemType Directory -Force -Path $buildDir | Out-Null
6464
}
6565

66-
$asmSrcs = Get-ChildItem -Path $srcDir -Recurse -Filter "*.s"
66+
$asmSrcs = Get-ChildItem -Path $srcDir -Recurse -Filter "*.asm"
6767
$cSrcs = Get-ChildItem -Path $srcDir -Recurse -Filter "*.c"
6868

6969
$objPaths = @()

0 commit comments

Comments
 (0)