{"id":20316055,"url":"https://github.com/lupyuen/zig-pinephone-mach","last_synced_at":"2026-06-12T09:31:11.871Z","repository":{"id":49319554,"uuid":"517241137","full_name":"lupyuen/zig-pinephone-mach","owner":"lupyuen","description":"(Experimental) Mach Zig Game Engine on PinePhone","archived":false,"fork":false,"pushed_at":"2022-07-25T10:29:41.000Z","size":76,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-04T09:13:34.761Z","etag":null,"topics":["gamedev","graphics-engine","mach","opengles","pinephone","webgpu","zig"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lupyuen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["lupyuen"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["paypal.me/lupyuen"]}},"created_at":"2022-07-24T06:04:29.000Z","updated_at":"2022-07-24T06:45:24.000Z","dependencies_parsed_at":"2022-08-27T10:01:09.129Z","dependency_job_id":null,"html_url":"https://github.com/lupyuen/zig-pinephone-mach","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lupyuen/zig-pinephone-mach","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lupyuen%2Fzig-pinephone-mach","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lupyuen%2Fzig-pinephone-mach/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lupyuen%2Fzig-pinephone-mach/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lupyuen%2Fzig-pinephone-mach/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lupyuen","download_url":"https://codeload.github.com/lupyuen/zig-pinephone-mach/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lupyuen%2Fzig-pinephone-mach/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34238711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-12T02:00:06.859Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gamedev","graphics-engine","mach","opengles","pinephone","webgpu","zig"],"created_at":"2024-11-14T18:24:02.895Z","updated_at":"2026-06-12T09:31:11.848Z","avatar_url":"https://github.com/lupyuen.png","language":null,"funding_links":["https://github.com/sponsors/lupyuen","paypal.me/lupyuen"],"categories":[],"sub_categories":[],"readme":"# (Experimental) Mach Zig Game Engine on PinePhone\n\nCan we run the Mach Game Engine (in Zig) on PinePhone?\n\nhttps://machengine.org/\n\nhttps://github.com/hexops/mach\n\nLet's find out! (With Manjaro Phosh)\n\n```text\n██████████████████  ████████   manjaro@manjaro-arm \n██████████████████  ████████   ------------------- \n██████████████████  ████████   OS: Manjaro ARM Linux aarch64 \n██████████████████  ████████   Host: Pine64 PinePhone (1.2) \n████████            ████████   Kernel: 5.18.3-1-MANJARO-ARM \n████████  ████████  ████████   Uptime: 1 hour, 48 mins \n████████  ████████  ████████   Packages: 806 (pacman) \n████████  ████████  ████████   Shell: bash 5.1.16 \n████████  ████████  ████████   Resolution: 720x1440 \n████████  ████████  ████████   Terminal: node \n████████  ████████  ████████   CPU: (4) @ 1.152GHz \n████████  ████████  ████████   Memory: 507MiB / 1991MiB \n████████  ████████  ████████\n████████  ████████  ████████       \n```\n\n# Build Mach\n\nFollow these steps to download Zig, download Mach and build Mach on PinePhone...\n\n```bash\n$ curl -O -L https://ziglang.org/builds/zig-linux-aarch64-0.10.0-dev.3080+eb1b2f5c5.tar.xz\n$ tar xf zig-linux-aarch64-0.10.0-dev.3080+eb1b2f5c5.tar.xz\n$ export PATH=\"$HOME/zig-linux-aarch64-0.10.0-dev.3080+eb1b2f5c5:$PATH\"\n$ git clone https://github.com/hexops/mach\n$ cd mach\n$ zig build example-rotating-cube -Ddawn-from-source=true\n```\n\n[(See the complete log)](https://gist.github.com/lupyuen/ff77c494b0589371b44b6c96f8491e31)\n\nBe patient, it takes roughly 1.5 hours for the first build. Subsequent builds will complete in seconds.\n\n# Missing Arm64 Atomics\n\nMach fails to build on PinePhone due to Missing Arm64 Atomics...\n\n```bash\n$ zig build example-rotating-cube -Ddawn-from-source=true\nLLD Link... \nld.lld: error: undefined symbol: __aarch64_ldadd8_relax\nld.lld: error: undefined symbol: __aarch64_ldadd8_acq\nld.lld: error: undefined symbol: __aarch64_ldadd8_rel\nld.lld: error: undefined symbol: __aarch64_ldadd8_acq_rel\nld.lld: error: undefined symbol: __aarch64_ldadd4_relax\nld.lld: error: undefined symbol: __aarch64_ldadd4_acq\nld.lld: error: undefined symbol: __aarch64_ldadd4_rel\nld.lld: error: undefined symbol: __aarch64_ldadd4_acq_rel\nld.lld: error: undefined symbol: __aarch64_swp8_acq_rel\nld.lld: error: undefined symbol: __aarch64_cas8_acq_rel\n```\n\n[(See the complete log)](https://gist.github.com/lupyuen/ff77c494b0589371b44b6c96f8491e31)\n\nThis is caused by Zig's incomplete support for LLVM and Atomics...\n\nhttps://github.com/ziglang/zig/issues/10086\n\nSo we copy the Arm64 Atomics from this Rust Implementation...\n\nhttps://github.com/suptalentdev/mustang/blob/master/c-scape/aarch64_outline_atomics/aarch64_outline_atomics/src/lib.rs\n\nhttps://docs.rs/atomic/latest/atomic/struct.Atomic.html\n\n# Fix Missing Arm64 Atomics\n\nTo build Mach correctly on PinePhone, apply this fix for the Missing Arm64 Atomics...\n\n```zig\n//// TODO: To fix the Missing Atomics for Mach Zig Game Engine on PinePhone Manjaro Phosh,\n//// Insert these lines at the bottom of mach/examples/rotating-cube/main.zig\n////\n//// Here are the Linker Errors for the Missing Atomics: \n//// https://gist.github.com/lupyuen/ff77c494b0589371b44b6c96f8491e31\n////\n//// Refer to this issue: https://github.com/ziglang/zig/issues/10086\n//// Rust Implementation: https://github.com/suptalentdev/mustang/blob/master/c-scape/aarch64_outline_atomics/aarch64_outline_atomics/src/lib.rs\n//// Rust Atomic Struct: https://docs.rs/atomic/latest/atomic/struct.Atomic.html\n\npub export fn __aarch64_ldadd4_relax()   c_int { _ = puts(\"TODO: __aarch64_ldadd4_relax\");   return 0; }\npub export fn __aarch64_ldadd4_acq()     c_int { _ = puts(\"TODO: __aarch64_ldadd4_acq\");     return 0; }\npub export fn __aarch64_ldadd4_rel()     c_int { _ = puts(\"TODO: __aarch64_ldadd4_rel\");     return 0; }\n\npub export fn __aarch64_ldadd4_acq_rel(x: u32, p: [*c]u32) u32 { \n    // (*p).fetch_add(x, AcqRel)\n    // Add to the current value, returning the previous value.\n    // AcqRel: For loads it uses Acquire ordering. For stores it uses the Release ordering.\n    const ret = p.*;\n    _ = printf(\"__aarch64_ldadd4_acq_rel: x=%d, p=%p, ret=%d\\n\", x, p, ret);\n    p.* +%= x;\n    return ret; \n}\n\npub export fn __aarch64_ldadd8_relax(x: u32, p: [*c]u32) u32 { \n    // (*p).fetch_add(x, Relaxed)\n    // Add to the current value, returning the previous value.\n    // Relaxed: No ordering constraints, only atomic operation\n    const ret = p.*;\n    _ = printf(\"__aarch64_ldadd8_relax: x=%d, p=%p, ret=%d\\n\", x, p, ret);\n    p.* +%= x;\n    return ret; \n}\n\npub export fn __aarch64_ldadd8_acq()     c_int { _ = puts(\"TODO: __aarch64_ldadd8_acq\");     return 0; }\n\npub export fn __aarch64_ldadd8_rel(x: u64, p: [*c]u64) u64 {\n    // (*p).fetch_add(x, AcqRel)\n    // Add to the current value, returning the previous value.\n    const ret = p.*;\n    _ = printf(\"__aarch64_ldadd8_rel: x=%d, p=%p, ret=%d\\n\", x, p, ret);\n    p.* +%= x;\n    return ret; \n}\n\npub export fn __aarch64_ldadd8_acq_rel(x: u64, p: [*c]u64) u64 {\n    // (*p).fetch_add(x, AcqRel)\n    // Add to the current value, returning the previous value.\n    // AcqRel: For loads it uses Acquire ordering. For stores it uses the Release ordering.\n    const ret = p.*;\n    _ = printf(\"__aarch64_ldadd8_acq_rel: x=%d, p=%p, ret=%d\\n\", x, p, ret);\n    p.* +%= x;\n    return ret; \n}\n\npub export fn __aarch64_swp8_acq_rel()   c_int { _ = puts(\"TODO: __aarch64_swp8_acq_rel\");   return 0; }\npub export fn __aarch64_cas8_acq_rel()   c_int { _ = puts(\"TODO: __aarch64_cas8_acq_rel\");   return 0; }\n\nextern fn printf(format: [*:0]const u8, ...) c_int;\nextern fn puts(str: [*:0]const u8) c_int;\n```\n\nAfter fixing, Mach builds OK on PinePhone...\n\n```bash\n$ zig build example-rotating-cube -Ddawn-from-source=true\n```\n\n# GLFW Error\n\nWhen we run Mach on PinePhone, it fails with a GLFW Error...\n\n```bash\n$ zig build example-rotating-cube -Ddawn-from-source=true\n\n$ export GPU_BACKEND=opengl\n$ zig-out/bin/example-rotating-cube\nglfw: error.VersionUnavailable: GLX: Failed to create context: GLXBadFBConfig\n\n$ export GPU_BACKEND=opengles\n$ zig-out/bin/example-rotating-cube\nglfw: error.VersionUnavailable: EGL: Failed to create context: An EGLConfig argument does not name a valid EGL frame buffer configuration\n```\n\n[(See complete log)](https://gist.github.com/lupyuen/700efb3b25463bc042ce9e23169efb18)\n\nWhich might be caused by the OpenGL Version on PinePhone...\n\n# OpenGL Version\n\nPinePhone supports OpenGL version 2.1, which might be too old for Mach...\n\n```text\n$ glxinfo | grep \"OpenGL version\"\nOpenGL version string: 2.1 Mesa 22.1.3\n```\n\nWhen we set `MESA_GL_VERSION_OVERRIDE`, Mach fails with a GLSL Error ...\n\n```bash\n$ zig build example-rotating-cube -Ddawn-from-source=true\n$ export GPU_BACKEND=opengl\n$ export MESA_GL_VERSION_OVERRIDE=4.5\n\n$ glxinfo | grep 'OpenGL version'\nOpenGL version string: 4.5 (Compatibility Profile) Mesa 22.1.3\n\n$ zig-out/bin/example-rotating-cube\nmach: found OpenGL backend on Unknown adapter: Mali400, OpenGL version 4.5 (Core Profile) Mesa 22.1.3\ngpu: validation error: #version 450\nProgram compilation failed:\n0:1(10): error: GLSL 4.50 is not supported. Supported versions are: 1.10, 1.20, and 1.00 ES\n - While calling [Device].CreateRenderPipeline([RenderPipelineDescriptor]).\n```\n\n[(See the complete log)](https://gist.github.com/lupyuen/9d3aca0d10cc6dfee0a7d3e50f14e191)\n\nThis says that Mach failed to create the GPU Render Pipeline...\n\n```zig\nconst vs_module = core.device.createShaderModule(\u0026.{\n    .label = \"my vertex shader\",\n    .code = .{ .wgsl = @embedFile(\"vert.wgsl\") },\n});\n\nconst pipeline_descriptor = gpu.RenderPipeline.Descriptor{\n    .fragment = \u0026fragment,\n    .layout = pipeline_layout,\n    .depth_stencil = null,\n    .vertex = .{\n        .module = vs_module,\n        .entry_point = \"main\",\n        .buffers = \u0026.{vertex_buffer_layout},\n```\n\n[(Source)](https://github.com/hexops/mach/blob/main/examples/rotating-cube/main.zig#L87-L107)\n\nBecause PinePhone failed to load the [OpenGL Shading Language](https://www.khronos.org/opengl/wiki/OpenGL_Shading_Language) (GLSL) file [vert.wgsl](https://github.com/hexops/mach/blob/main/examples/rotating-cube/vert.wgsl).\n\nThis GLSL Error appears when we set `MESA_GL_VERSION_OVERRIDE` to 4.4 or above.\n\nThe GLFW Error appears when we set `MESA_GL_VERSION_OVERRIDE` to 4.3 or below.\n\nSo it seems Mach only works with OpenGL / GLSL version 4.4 and above. Which isn't supported on PinePhone.\n\nPerhaps PinePhone Pro (with Vulkan) will support Mach.\n\n# Pinebook Pro\n\nWill Mach run on Pinebook Pro?\n\n```text\n██████████████████  ████████   luppy@pinebook \n██████████████████  ████████   -------------- \n██████████████████  ████████   OS: Manjaro ARM Linux aarch64 \n██████████████████  ████████   Host: Pine64 Pinebook Pro \n████████            ████████   Kernel: 5.18.5-1-MANJARO-ARM \n████████  ████████  ████████   Uptime: 53 mins \n████████  ████████  ████████   Packages: 1006 (pacman) \n████████  ████████  ████████   Shell: bash 5.1.16 \n████████  ████████  ████████   Resolution: 1920x1080 \n████████  ████████  ████████   Terminal: node \n████████  ████████  ████████   CPU: (6) @ 1.416GHz \n████████  ████████  ████████   Memory: 914MiB / 3868MiB \n████████  ████████  ████████\n████████  ████████  ████████    \n```\n\nWe run the same steps to build Mach on Pinebook Pro (Manjaro Xfce)...\n\nhttps://github.com/lupyuen/zig-pinephone-mach#build-mach\n\nAnd apply the fix for Missing Arm64 Atomics...\n\nhttps://github.com/lupyuen/zig-pinephone-mach#missing-arm64-atomics\n\n[(See the build log)](https://gist.github.com/lupyuen/1aaca1615848d86844a4d2873a847439)\n\n(Mach builds on Pinebook Pro in roughly half an hour)\n\nMach fails with the same GLFW Error on Pinebook Pro even though it supports OpenGL 3.1...\n\n```bash\n$ zig build example-rotating-cube -Ddawn-from-source=true\n$ export GPU_BACKEND=opengl\n\n$ glxinfo | grep 'OpenGL version'\nOpenGL version string: 3.1 Mesa 22.1.3\n\n$ zig-out/bin/example-rotating-cube\nglfw: error.VersionUnavailable: GLX: Failed to create context: GLXBadFBConfig\n```\n\n[(See the complete log)](https://gist.github.com/lupyuen/46d5e398fad09ec498d8c9c93d82e03a)\n\nWhen we set `MESA_GL_VERSION_OVERRIDE`, Mach fails with the same GLSL Error...\n\n```bash\n$ zig build example-rotating-cube -Ddawn-from-source=true\n$ export GPU_BACKEND=opengl\n$ export MESA_GL_VERSION_OVERRIDE=4.5\n\n$ glxinfo |  grep 'OpenGL version'\nOpenGL version string: 4.5 (Compatibility Profile) Mesa 22.1.3\n\n$ zig-out/bin/example-rotating-cube\nmach: found OpenGL backend on Unknown adapter: Mali-T860 (Panfrost), OpenGL version 4.5 (Core Profile) Mesa 22.1.3\ngpu: validation error: #version 450\nProgram compilation failed:\n0:1(10): error: GLSL 4.50 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.40, 1.00 ES, and 3.00 ES\n - While calling [Device].CreateRenderPipeline([RenderPipelineDescriptor]).\n```\n\n[(See the complete log)](https://gist.github.com/lupyuen/849491f0aef2b8ad67e8ab1ce250f067)\n\nSo it seems Mach won't run on Pinebook Pro because it doesn't support OpenGL / GLSL version 4.4 or later.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flupyuen%2Fzig-pinephone-mach","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flupyuen%2Fzig-pinephone-mach","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flupyuen%2Fzig-pinephone-mach/lists"}