From c3d6ab2119bd036217c3417a786b2b16a00f3ff0 Mon Sep 17 00:00:00 2001 From: Ivan Velickovic Date: Mon, 13 Nov 2023 14:13:12 +1100 Subject: [PATCH] examples/simple: update Zig version used --- examples/simple/README.md | 7 ++-- examples/simple/build.zig | 72 ++++++++++++++++++++++----------------- 2 files changed, 45 insertions(+), 34 deletions(-) diff --git a/examples/simple/README.md b/examples/simple/README.md index f9aa3e24f..e58a267f8 100644 --- a/examples/simple/README.md +++ b/examples/simple/README.md @@ -34,8 +34,11 @@ system running the whole system. For educational purposes, you can also build and run this example using the [Zig](https://ziglang.org/) build system. -You will first need Zig version 0.11.x (e.g 0.11.0 or 0.11.1) which can be -downloaded from [here](https://ziglang.org/download/). +At the moment, Zig still under heavy development and hence this example depends +on the 'master' version of Zig for now. This example has been built using +`0.12.0-dev.1533+b2ed2c4d4`, so anything equal to or above that version should work. + +You can download Zig [here](https://ziglang.org/download/). ```sh zig build -Dsdk=/path/to/sdk -Dboard= diff --git a/examples/simple/build.zig b/examples/simple/build.zig index 21f4e1202..0543d6555 100644 --- a/examples/simple/build.zig +++ b/examples/simple/build.zig @@ -100,25 +100,28 @@ pub fn build(b: *std.Build) void { const libvmm_src = libvmm_path ++ "/src/"; // Right now we only support AArch64 so this is a safe assumption. const libvmm_src_arch = libvmm_src ++ "arch/aarch64/"; - libvmm.addCSourceFiles(&.{ - libvmm_src ++ "guest.c", - libvmm_src ++ "util/util.c", - libvmm_src ++ "util/printf.c", - libvmm_src_arch ++ "vgic/vgic.c", - libvmm_src_arch ++ "vgic/vgic_v2.c", - libvmm_src_arch ++ "fault.c", - libvmm_src_arch ++ "psci.c", - libvmm_src_arch ++ "smc.c", - libvmm_src_arch ++ "virq.c", - libvmm_src_arch ++ "linux.c", - libvmm_src_arch ++ "tcb.c", - libvmm_src_arch ++ "vcpu.c", - }, &.{ - "-Wall", - "-Werror", - "-Wno-unused-function", - "-mstrict-align", - "-DBOARD_qemu_arm_virt", + libvmm.addCSourceFiles(.{ + .files = &.{ + libvmm_src ++ "guest.c", + libvmm_src ++ "util/util.c", + libvmm_src ++ "util/printf.c", + libvmm_src_arch ++ "vgic/vgic.c", + libvmm_src_arch ++ "vgic/vgic_v2.c", + libvmm_src_arch ++ "fault.c", + libvmm_src_arch ++ "psci.c", + libvmm_src_arch ++ "smc.c", + libvmm_src_arch ++ "virq.c", + libvmm_src_arch ++ "linux.c", + libvmm_src_arch ++ "tcb.c", + libvmm_src_arch ++ "vcpu.c", + }, + .flags = &.{ + "-Wall", + "-Werror", + "-Wno-unused-function", + "-mstrict-align", + "-DBOARD_qemu_arm_virt", // @ivanv: should not be necessary + } }); libvmm.addIncludePath(.{ .path = libvmm_src }); @@ -144,7 +147,6 @@ pub fn build(b: *std.Build) void { // Add microkit.h to be used by the API wrapper. exe.addIncludePath(.{ .path = sdk_board_include_dir }); - // The VMM code will include exe.addIncludePath(.{ .path = libvmm_src }); exe.addIncludePath(.{ .path = libvmm_src_arch }); // Add the static library that provides each protection domain's entry @@ -154,12 +156,15 @@ pub fn build(b: *std.Build) void { // Specify the linker script, this is necessary to set the ELF entry point address. exe.setLinkerScriptPath(.{ .path = libmicrokit_linker_script }); - exe.addCSourceFiles(&.{"vmm.c"}, &.{ - "-Wall", - "-Werror", - "-Wno-unused-function", - "-mstrict-align", - "-DBOARD_qemu_arm_virt", // @ivanv: shouldn't be needed as the library should not depend on the board + exe.addCSourceFiles(.{ + .files = &.{"vmm.c"}, + .flags = &.{ + "-Wall", + "-Werror", + "-Wno-unused-function", + "-mstrict-align", + "-DBOARD_qemu_arm_virt", // @ivanv: shouldn't be needed as the library should not depend on the board + } }); const guest_images = b.addObject(.{ @@ -176,12 +181,15 @@ pub fn build(b: *std.Build) void { const initrd_image_path = fmtPrint("board/{s}/rootfs.cpio.gz", .{ microkit_board }); const initrd_image_arg = fmtPrint("-DGUEST_INITRD_IMAGE_PATH=\"{s}\"", .{ initrd_image_path }); const dtb_image_arg = fmtPrint("-DGUEST_DTB_IMAGE_PATH=\"{s}\"", .{ dtb_image_path }); - guest_images.addCSourceFiles(&.{ libvmm_tools ++ "package_guest_images.S" }, &.{ - kernel_image_arg, - dtb_image_arg, - initrd_image_arg, - "-x", - "assembler-with-cpp", + guest_images.addCSourceFiles(.{ + .files = &.{ libvmm_tools ++ "package_guest_images.S" }, + .flags = &.{ + kernel_image_arg, + dtb_image_arg, + initrd_image_arg, + "-x", + "assembler-with-cpp", + } }); exe.addObject(guest_images);