Skip to content

Build failure due to @newStackCall being removed in 0.6.0 #3

Open
@peterhellberg

Description

@peterhellberg
Contributor

I found this neat little project today, and thought I should look into making it compile using Zig 0.6.0

(Mainly as a fun challenge, since I do not yet know much about Zig)

Making the following changes allows the code to build

zig build-exe hellos.zig -target i386-freestanding --linker-script linker.ld

diff --git a/hellos.zig b/hellos.zig
index 8563852..506f2c9 100644
--- a/hellos.zig
+++ b/hellos.zig
@@ -20,8 +20,9 @@ export var multiboot align(4) linksection(".multiboot") = MultiBoot{
 export var stack_bytes: [16 * 1024]u8 align(16) linksection(".bss") = undefined;
 const stack_bytes_slice = stack_bytes[0..];
 
-export nakedcc fn _start() noreturn {
-    @newStackCall(stack_bytes_slice, kmain);
+export fn _start() callconv(.Naked) noreturn {
+    @call(.{ .stack = stack_bytes_slice }, kmain, .{});
+
     while (true) {}
 }
 
@@ -34,7 +35,7 @@ pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn
 
 fn kmain() void {
     terminal.initialize();
-    terminal.write("Hello, kernel World!");
+    terminal.write("Hello, Kernel World from Zig 0.6.0!");
 }
 
 // Hardware text mode color constants
@@ -61,23 +62,26 @@ fn vga_entry_color(fg: VgaColor, bg: VgaColor) u8 {
 }
 
 fn vga_entry(uc: u8, color: u8) u16 {
-    return u16(uc) | (u16(color) << 8);
+    var c: u16 = color;
+
+    return uc | (c << 8);
 }
 
 const VGA_WIDTH = 80;
 const VGA_HEIGHT = 25;
 
 const terminal = struct {
-    var row = usize(0);
-    var column = usize(0);
+    var row: usize = 0;
+    var column: usize = 0;
+
     var color = vga_entry_color(VGA_COLOR_LIGHT_GREY, VGA_COLOR_BLACK);
 
     const buffer = @intToPtr([*]volatile u16, 0xB8000);
 
     fn initialize() void {
-        var y = usize(0);
+        var y: usize = 0;
         while (y < VGA_HEIGHT) : (y += 1) {
-            var x = usize(0);
+            var x: usize = 0;
             while (x < VGA_WIDTH) : (x += 1) {
                 putCharAt(' ', color, x, y);
             }

Screenshot

hellos

Gist

https://gist.github.com/peterhellberg/e81128eae5adc6293d5c1bbeef3a3380

Activity

cubranic

cubranic commented on Sep 8, 2020

@cubranic

I can verify that this patch got HellOS to compile and run with Zig 0.6.0.

andrewrk

andrewrk commented on Sep 9, 2020

@andrewrk
Owner

Happy to merge it, do you want to make it a PR and get authorship for it?

peterhellberg

peterhellberg commented on Sep 9, 2020

@peterhellberg
ContributorAuthor

@andrewrk Ok, will do so right away.

xyproto

xyproto commented on Sep 29, 2020

@xyproto

I can confirm that the patch-1 branch from @peterhellberg compiles, using zig 0.6.0+281fc10ec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @xyproto@andrewrk@peterhellberg@cubranic

        Issue actions

          Build failure due to @newStackCall being removed in 0.6.0 · Issue #3 · andrewrk/HellOS