From 64eb7ce83664ec2ad02320f7a3452a6f738592cd Mon Sep 17 00:00:00 2001 From: Mathieu Strypsteen Date: Wed, 25 Dec 2024 20:03:32 +0100 Subject: [PATCH] Download compiler in CI --- .clang-format | 1 + .forgejo/workflows/build.yaml | 8 ++++++++ build.py | 5 ++++- init/.cargo/config.toml | 2 +- init/src/main.rs | 16 +--------------- init/src/start.s | 11 ----------- kernel/src/main.rs | 4 ++-- lib/acpica-build/Makefile | 2 +- 8 files changed, 18 insertions(+), 31 deletions(-) create mode 100644 .clang-format delete mode 100644 init/src/start.s diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..a32aaf8 --- /dev/null +++ b/.clang-format @@ -0,0 +1 @@ +ColumnLimit: 200 diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index ac07aff..513f571 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -12,6 +12,14 @@ jobs: uses: actions/checkout@v4 with: submodules: true + - name: Download Rust + run: | + curl -O ${{ vars.RUST_URL }} + mkdir rust + cd rust + unzip ../compiler.zip + - name: Link toolchain + run: . ~/.bashrc && rustup toolchain link x86_64-unknown-os rust - name: Build run: . ~/.bashrc && ./build.py - name: Install cargo-deny diff --git a/build.py b/build.py index b150b89..1a20976 100755 --- a/build.py +++ b/build.py @@ -18,7 +18,10 @@ def main(): components = ["init", "kernel", "loader"] for component in components: - cargo_cmd = f'cargo build {"--release" if target == "release" else ""}' + toolchain = "+x86_64-unknown-os" + if component == "kernel" or component == "loader": + toolchain = "" + cargo_cmd = f'cargo {toolchain} build {"--release" if target == "release" else ""}' run_command(cargo_cmd, cwd=component) loader_path = f"target/x86_64-unknown-uefi/{target}/loader.efi" diff --git a/init/.cargo/config.toml b/init/.cargo/config.toml index 2eddc64..5b4e9bf 100644 --- a/init/.cargo/config.toml +++ b/init/.cargo/config.toml @@ -1,3 +1,3 @@ [build] -target = "x86_64-unknown-none" +target = "x86_64-unknown-os" rustflags = ["-C", "link-arg=-no-pie"] diff --git a/init/src/main.rs b/init/src/main.rs index da97a56..f328e4d 100644 --- a/init/src/main.rs +++ b/init/src/main.rs @@ -1,15 +1 @@ -#![no_std] -#![no_main] -use core::{arch::global_asm, panic::PanicInfo}; - -global_asm!(include_str!("start.s"), options(att_syntax)); - -#[no_mangle] -extern "C" fn main() -> ! { - loop {} -} - -#[panic_handler] -fn panic(_info: &PanicInfo) -> ! { - loop {} -} +fn main() {} diff --git a/init/src/start.s b/init/src/start.s deleted file mode 100644 index 4d621f8..0000000 --- a/init/src/start.s +++ /dev/null @@ -1,11 +0,0 @@ -.text - -.global _start -_start: - mov $stack, %rsp - call main - -.section .bss -.align 16 -.skip 0x10000 -stack: diff --git a/kernel/src/main.rs b/kernel/src/main.rs index 9779563..be4cc28 100644 --- a/kernel/src/main.rs +++ b/kernel/src/main.rs @@ -66,10 +66,10 @@ global_asm!(include_str!("cpu/trampoline.s"), options(att_syntax)); global_asm!(include_str!("cpu/usermode.s"), options(att_syntax)); #[cfg(debug_assertions)] -const INIT_BINARY: &[u8] = include_bytes!("../../target/x86_64-unknown-none/debug/init"); +const INIT_BINARY: &[u8] = include_bytes!("../../target/x86_64-unknown-os/debug/init"); #[cfg(not(debug_assertions))] -const INIT_BINARY: &[u8] = include_bytes!("../../target/x86_64-unknown-none/release/init"); +const INIT_BINARY: &[u8] = include_bytes!("../../target/x86_64-unknown-os/release/init"); #[no_mangle] extern "C" fn early_main(temp_loader_struct: *const LoaderStruct) -> ! { diff --git a/lib/acpica-build/Makefile b/lib/acpica-build/Makefile index 644d11d..98410a5 100644 --- a/lib/acpica-build/Makefile +++ b/lib/acpica-build/Makefile @@ -3,7 +3,7 @@ COMPONENTS:=dispatcher events executer hardware namespace parser resources table CFILES:=$(foreach comp, $(COMPONENTS), $(wildcard ../acpica/source/components/$(comp)/*.c)) printf.c OFILES:=$(patsubst %.c, %.o, $(CFILES)) CC:=clang -CFLAGS:=--target=x86_64-elf -ffreestanding -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -fstack-protector-strong -O2 -I. -I../acpica/source/include -DACPI_LIBRARY -D__linux__ +CFLAGS:=--target=x86_64-elf -ffreestanding -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -fstack-protector-strong -Wall -Werror -O2 -I. -I../acpica/source/include -DACPI_LIBRARY -D__linux__ libacpica.a: $(OFILES) llvm-ar rcD $@ $^