From 20a530bfa6938dc33be2a72afcbadb17e9c2c613 Mon Sep 17 00:00:00 2001 From: Saza-ku Date: Fri, 9 Aug 2024 14:39:47 +0900 Subject: [PATCH 1/6] upgrade zig to 0.12.1 --- .devcontainer/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 75cdb98..e3e692c 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -3,7 +3,7 @@ FROM mcr.microsoft.com/devcontainers/rust:1-1-bookworm RUN apt-get update && apt-get install -y cmake ARG LLVM_URL=https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.0/clang+llvm-15.0.0-x86_64-linux-gnu-rhel-8.4.tar.xz -ARG ZIG_VERSION=zig-linux-x86_64-0.12.0-dev.1856+94c63f31f +ARG ZIG_VERSION=zig-linux-x86_64-0.12.1 ENV PATH="/usr/bin/zig:${PATH}" ENV PATH=/usr/local/llvm/bin:$PATH @@ -17,8 +17,8 @@ RUN mkdir -p /usr/local/llvm \ WORKDIR /work -RUN git clone https://github.com/Mewz-project/Wasker.git \ - && cd Wasker \ +RUN git clone https://github.com/mewz-project/wasker.git \ + && cd wasker \ && cargo build --release \ && cp target/release/wasker /usr/bin From cdc8586021bf02d78faa00568ca7181c5c450c28 Mon Sep 17 00:00:00 2001 From: Saza-ku Date: Sat, 10 Aug 2024 17:43:52 +0900 Subject: [PATCH 2/6] fix build.zig for 0.12.1 --- build.zig | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/build.zig b/build.zig index b0673c9..f7ead18 100644 --- a/build.zig +++ b/build.zig @@ -1,7 +1,7 @@ const std = @import("std"); const Build = @import("std").Build; const Target = @import("std").Target; -const CrossTarget = @import("std").zig.CrossTarget; +const Query = @import("std").Target.Query; const Feature = @import("std").Target.Cpu.Feature; const TEST_DIR_PATH = "build/test"; @@ -91,7 +91,7 @@ pub fn build(b: *Build) !void { disabled_features.addFeature(@intFromEnum(features.avx2)); enabled_features.addFeature(@intFromEnum(features.soft_float)); - const target = CrossTarget{ .cpu_arch = Target.Cpu.Arch.x86_64, .os_tag = Target.Os.Tag.freestanding, .cpu_features_sub = disabled_features, .cpu_features_add = enabled_features }; + const target = Query{ .cpu_arch = Target.Cpu.Arch.x86_64, .os_tag = Target.Os.Tag.freestanding, .cpu_features_sub = disabled_features, .cpu_features_add = enabled_features }; const optimize = b.standardOptimizeOption(.{}); @@ -102,10 +102,9 @@ pub fn build(b: *Build) !void { .name = "mewz.elf", .root_source_file = .{ .path = "src/main.zig" }, .optimize = optimize, - .target = target, - .linkage = std.build.CompileStep.Linkage.static, + .target = b.resolveTargetQuery(target), + .linkage = std.builtin.LinkMode.static, }); - kernel.code_model = .kernel; kernel.setLinkerScriptPath(.{ .path = "src/x64.ld" }); kernel.addAssemblyFile(Build.LazyPath{ .path = "src/boot.S" }); kernel.addAssemblyFile(Build.LazyPath{ .path = "src/interrupt.S" }); @@ -113,15 +112,15 @@ pub fn build(b: *Build) !void { kernel.addObjectFile(Build.LazyPath{ .path = "build/lwip/libtcpip.a" }); kernel.addObjectFile(Build.LazyPath{ .path = "build/lwip/liblwipcore.a" }); kernel.addObjectFile(Build.LazyPath{ .path = "build/lwip/liblwipallapps.a" }); - kernel.addCSourceFile(Build.Step.Compile.CSourceFile{ .file = Build.LazyPath{ .path = "src/c/newlib_support.c" }, .flags = &[_][]const u8{ "-I", "submodules/newlib/newlib/libc/include" } }); - kernel.addCSourceFile(Build.Step.Compile.CSourceFile{ .file = Build.LazyPath{ .path = "src/c/lwip_support.c" }, .flags = &[_][]const u8{ "-I", "submodules/newlib/newlib/libc/include" } }); + kernel.addCSourceFile(Build.Module.CSourceFile{ .file = Build.LazyPath{ .path = "src/c/newlib_support.c" }, .flags = &[_][]const u8{ "-I", "submodules/newlib/newlib/libc/include" } }); + kernel.addCSourceFile(Build.Module.CSourceFile{ .file = Build.LazyPath{ .path = "src/c/lwip_support.c" }, .flags = &[_][]const u8{ "-I", "submodules/newlib/newlib/libc/include" } }); if (params.obj_path) |p| { kernel.addObjectFile(Build.LazyPath{ .path = p }); } if (params.dir_path) |_| { kernel.addObjectFile(Build.LazyPath{ .path = "build/disk.o" }); } - kernel.addOptions("options", options); + kernel.root_module.addOptions("options", options); b.installArtifact(kernel); const kernel_step = b.step("kernel", "Build the kernel"); From b560b51df30b98ae2bd1bcac598f129aedb77e5b Mon Sep 17 00:00:00 2001 From: Saza-ku Date: Sat, 10 Aug 2024 17:48:27 +0900 Subject: [PATCH 3/6] fix codes for 0.12.1 --- src/drivers/virtio/common.zig | 2 +- src/fs.zig | 3 ++- src/sync.zig | 8 ++++---- src/timer.zig | 2 +- src/x64.zig | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/drivers/virtio/common.zig b/src/drivers/virtio/common.zig index 4d9520d..b093548 100644 --- a/src/drivers/virtio/common.zig +++ b/src/drivers/virtio/common.zig @@ -535,7 +535,7 @@ pub fn VirtioMmioTransport(comptime DeviceConfigType: type) type { } self.common_config.queue_select = virtq.index; - @fence(std.builtin.AtomicOrder.SeqCst); + @fence(std.builtin.AtomicOrder.seq_cst); const offset = self.notify_off_multiplier * self.common_config.queue_notify_off; const addr = self.notify + @as(usize, @intCast(offset)); @as(*volatile u16, @ptrFromInt(addr)).* = virtq.index; diff --git a/src/fs.zig b/src/fs.zig index 67585eb..bb80371 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -99,7 +99,8 @@ pub fn init() void { } log.debug.printf("FILES_MAX: {d}\n", .{FILES_MAX}); - const disk_pointer = @as([*]u8, @ptrCast(&_binary_build_disk_tar_start)); + const disk_ptr_addr = &_binary_build_disk_tar_start; + const disk_pointer = @as([*]u8, @ptrCast(@constCast(disk_ptr_addr))); var off: usize = 0; var i: usize = 0; diff --git a/src/sync.zig b/src/sync.zig index 2815a45..bd6ab51 100644 --- a/src/sync.zig +++ b/src/sync.zig @@ -20,13 +20,13 @@ pub fn SpinLock(comptime T: type) type { @panic("deadlock"); } - while (@atomicRmw(bool, &this.locked, builtin.AtomicRmwOp.Xchg, true, builtin.AtomicOrder.Acquire)) {} + while (@atomicRmw(bool, &this.locked, builtin.AtomicRmwOp.Xchg, true, builtin.AtomicOrder.acquire)) {} return @as(*T, @alignCast(@ptrCast(this.ptr))); } pub fn release(this: *volatile This) void { - _ = @atomicRmw(bool, &this.locked, builtin.AtomicRmwOp.Xchg, false, builtin.AtomicOrder.Release); + _ = @atomicRmw(bool, &this.locked, builtin.AtomicRmwOp.Xchg, false, builtin.AtomicOrder.release); popcli(); } @@ -43,13 +43,13 @@ pub const Waiter = struct { } pub fn setWait(self: *volatile Self) void { - @atomicStore(bool, &self.waiting, true, builtin.AtomicOrder.SeqCst); + @atomicStore(bool, &self.waiting, true, builtin.AtomicOrder.seq_cst); } pub fn wait(self: *volatile Self) void { while (true) { while (self.waiting) {} - if (!@atomicLoad(bool, &self.waiting, builtin.AtomicOrder.SeqCst)) { + if (!@atomicLoad(bool, &self.waiting, builtin.AtomicOrder.seq_cst)) { break; } } diff --git a/src/timer.zig b/src/timer.zig index 324305b..3603dd1 100644 --- a/src/timer.zig +++ b/src/timer.zig @@ -41,7 +41,7 @@ pub const Timer = struct { } pub fn isFinished(self: *Self) bool { - return @atomicLoad(bool, &self.*.is_finished_internal, std.builtin.AtomicOrder.SeqCst); + return @atomicLoad(bool, &self.*.is_finished_internal, std.builtin.AtomicOrder.seq_cst); } }; diff --git a/src/x64.zig b/src/x64.zig index 68feaa0..f1fa797 100644 --- a/src/x64.zig +++ b/src/x64.zig @@ -4,7 +4,7 @@ pub const EFLAGS_IF = 0x00000200; pub fn init() void { enableSSE(); - @fence(std.builtin.AtomicOrder.SeqCst); + @fence(std.builtin.AtomicOrder.seq_cst); enableAVX(); } From 87be93066ca16b29bf605104cd201010deedf8de Mon Sep 17 00:00:00 2001 From: Saza-ku Date: Tue, 13 Aug 2024 17:01:24 +0900 Subject: [PATCH 4/6] specify entry point in build.zig --- build.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/build.zig b/build.zig index f7ead18..b5af2aa 100644 --- a/build.zig +++ b/build.zig @@ -105,6 +105,7 @@ pub fn build(b: *Build) !void { .target = b.resolveTargetQuery(target), .linkage = std.builtin.LinkMode.static, }); + kernel.entry = .{ .symbol_name = "boot" }; kernel.setLinkerScriptPath(.{ .path = "src/x64.ld" }); kernel.addAssemblyFile(Build.LazyPath{ .path = "src/boot.S" }); kernel.addAssemblyFile(Build.LazyPath{ .path = "src/interrupt.S" }); From 75a6907a23d49f0b4599e24c1a38d90fd7f129ad Mon Sep 17 00:00:00 2001 From: Saza-ku Date: Tue, 13 Aug 2024 17:16:57 +0900 Subject: [PATCH 5/6] update lwip --- submodules/lwip | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/lwip b/submodules/lwip index 1cc1536..73fcf72 160000 --- a/submodules/lwip +++ b/submodules/lwip @@ -1 +1 @@ -Subproject commit 1cc1536e6a7117e23ebaf5546405a843a3e558ae +Subproject commit 73fcf72792a926a4e0ac8b656b29bff70552d927 From c3396640edb33225dc5f4d1dbfa64097f425259c Mon Sep 17 00:00:00 2001 From: Saza-ku Date: Tue, 13 Aug 2024 17:19:43 +0900 Subject: [PATCH 6/6] upgrade zig to 0.12.1 in ci --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a4d2fb2..726b4e1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,7 +23,7 @@ jobs: - name: Install Zig uses: goto-bus-stop/setup-zig@v2 with: - version: 0.12.0-dev.926+3be8490d8 + version: 0.12.1 cache: true - name: Install packages for running tests