kladd / ivy

A 64-bit kernel written in hard tabs.
2 stars 0 forks source link

make gives warning and make run fails #1

Closed saurabh-ss closed 1 year ago

saurabh-ss commented 1 year ago
saurabh@raiden:~/ivy$ make mkdir -p target/kernel nasm -o target/kernel/start.o -felf32 src/arch/x86/main.asm ar rvs target/kernel/libstart.a target/kernel/start.o ar: creating target/kernel/libstart.a a - target/kernel/start.o info: syncing channel updates for 'nightly-x86_64-unknown-linux-gnu' info: latest update on 2023-04-30, rust version 1.71.0-nightly (87b1f891e 2023-04-29) info: downloading component 'cargo' info: downloading component 'clippy' info: downloading component 'rust-docs' info: downloading component 'rust-src' info: downloading component 'rust-std' info: downloading component 'rustc' info: downloading component 'rustfmt' info: installing component 'cargo' info: installing component 'clippy' info: installing component 'rust-docs' info: installing component 'rust-src' info: installing component 'rust-std' info: installing component 'rustc' info: installing component 'rustfmt' Updating crates.io index Downloaded addr2line v0.19.0 Downloaded rustc-demangle v0.1.21 Downloaded unicode-width v0.1.10 Downloaded adler v1.0.2 Downloaded cc v1.0.77 Downloaded memchr v2.5.0 Downloaded cfg-if v1.0.0 Downloaded object v0.30.1 Downloaded hashbrown v0.12.3 Downloaded compiler_builtins v0.1.91 Downloaded libc v0.2.142 Downloaded gimli v0.27.2 Downloaded getopts v0.2.21 Downloaded miniz_oxide v0.6.2 Downloaded 14 crates (2.2 MB) in 0.28s Compiling compiler_builtins v0.1.91 Compiling core v0.0.0 (/home/saurabh/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core) Compiling rustc-std-workspace-core v1.99.0 (/home/saurabh/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core) Compiling alloc v0.0.0 (/home/saurabh/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc) Compiling ivy v0.1.0 (/home/saurabh/ivy) warning: extern block uses type FATFileSystem, which is not FFI-safe --> src/main.rs:68:23 68 fn switch_task(task: &Task) -> u32; ^^^^^ not FFI-safe
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout

note: the type is defined here --> src/fat.rs:204:1 | 204 | pub struct FATFileSystem { | ^^^^^^^^^^^^^^^^^^^^^^^^ = note: #[warn(improper_ctypes)] on by default

warning: ivy (bin "ivy") generated 1 warning Finished dev [unoptimized + debuginfo] target(s) in 10.52s`

saurabh@raiden:~/ivy$ make run nasm -o target/kernel/start.o -felf32 src/arch/x86/main.asm ar rvs target/kernel/libstart.a target/kernel/start.o r - target/kernel/start.o warning: extern block uses type FATFileSystem, which is not FFI-safe --> src/main.rs:68:23 68 fn switch_task(task: &Task) -> u32; ^^^^^ not FFI-safe
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout

note: the type is defined here --> src/fat.rs:204:1 | 204 | pub struct FATFileSystem { | ^^^^^^^^^^^^^^^^^^^^^^^^ = note: #[warn(improper_ctypes)] on by default

warning: ivy (bin "ivy") generated 1 warning Finished dev [unoptimized + debuginfo] target(s) in 0.02s qemu-img"" create -f raw target/kernel/_disk_image 1g Formatting 'target/kernel/_disk_image', fmt=raw size=1073741824 mkfs.fat -F 16 target/kernel/_disk_image make: mkfs.fat: No such file or directory make: *** [Makefile:26: target/kernel/_disk_image] Error 127

kladd commented 1 year ago

Make these changes to fix the build error. Instead of using linux tools to format a FAT16 filesystem, this will have QEMU emulate it. Shouldn't require any dependencies. The warning is...todo.

diff --git a/Makefile b/Makefile
index 359999d..81ab76f 100644
--- a/Makefile
+++ b/Makefile
@@ -29,11 +29,11 @@ $(target_dir)/_disk_image: $(kernel)
        sudo cp -r base/* $(target_dir)/mnt
        sudo umount $(target_dir)/mnt

-run: $(kernel) $(target_dir)/_disk_image
+run: $(kernel)
        @qemu-system-i386$(qemu_exe) -kernel $< \
                -m 2g \
                -serial stdio \
-               -drive file=$(target_dir)/_disk_image,format=raw,media=disk,cache=writethrough
+               -drive file=fat:rw:base,format=raw,media=disk,cache=writethrough
                # TODO: Disk flush? (remove cache=writethrough)

 always: ;
saurabh-ss commented 1 year ago

Worked.