Skip to content

Commit

Permalink
examples/zig: update for latest Zig
Browse files Browse the repository at this point in the history
0.12.0-dev.1533+b2ed2c4d4 was used.
  • Loading branch information
Ivan-Velickovic committed Nov 13, 2023
1 parent f765308 commit 3eeff51
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 23 deletions.
7 changes: 5 additions & 2 deletions examples/zig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ the Zig C compiler. Building the example is done via the Zig build system.

## Building the example

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
Expand Down
43 changes: 23 additions & 20 deletions examples/zig/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,29 @@ 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", // @ivanv: should not be necessary
// "-fno-sanitize=undefined",
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
// "-fno-sanitize=undefined",
}
});

libvmm.addIncludePath(.{ .path = libvmm_src });
Expand Down
3 changes: 2 additions & 1 deletion shell.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
let
rust_overlay = import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz");
zig = import (builtins.fetchTarball "https://github.com/mitchellh/zig-overlay/archive/master.tar.gz") {};
pkgs = import <nixpkgs> { overlays = [ rust_overlay ]; };
rust = pkgs.rust-bin.fromRustupToolchainFile ./examples/rust/rust-toolchain.toml;
llvm = pkgs.llvmPackages_11;
in
pkgs.mkShell {
buildInputs = with pkgs.buildPackages; [
zig_0_11
zig.master
rust
qemu
gnumake
Expand Down

0 comments on commit 3eeff51

Please sign in to comment.