Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move build system to zig build #101

Draft
wants to merge 61 commits into
base: main
Choose a base branch
from
Draft

Move build system to zig build #101

wants to merge 61 commits into from

Conversation

rdunnington
Copy link
Collaborator

@rdunnington rdunnington commented Feb 9, 2025

Closes #25. This change ports the python-based orcadev build system to build.zig. Some immediate benefits:

  • Caching of intermediate artifacts - speeds up the build time for iterative builds.
  • Dependency tracking - don't have to worry about remembering to build specific dependencies for a given library.
  • Wasm support - no need to manually install the wasm compiler_rt builtins
  • Single compiler used for all builds - drops MSVC on windows
  • Avoids annoying issues with brew vs apple versions of clang on macos
  • --watch flag that watches for changes to any input files and rebuilds dependent artifacts

There are a few guiding design principles for this change:

  • Try to preserve the original behavior of orcadev and the locations of build artifact outputs as much as possible.
  • zig build XXX should just work on any system, regardless of system-installed dependencies. For example, if we require python to be present for part of the build, the build system should ensure a compatible version to be installed so the user doesn't have to, such as via build.zig.zon.
  • Zig should be used to implement everything used in the build system, including helper programs, to avoid too much language-hopping.

Note that this is a draft and there still remains a bunch of work to be done before this can go in. Namely:

  • Switch zig build to run zig build orca-install by default
  • Don't require presence of orca executable in PATH if --sdk-dir is supplied to zig build orca-install
  • Investigate angle prebuilt artifact false mismatch
  • Investigate sample startup perf differences between old builds and zig build system
  • Try to repro Skytrias' missing openssl issue and ensure zig build handles that case
  • Update CI scripts orcabuild -> zig build
  • Add test job to CI with zig build test
  • Add sketches to CI
  • Update README
  • Try to get delay-loading to work for graphics DLLs on windows (webgpu, EGL, GLESv2)
  • Port macos @rpath stuff from dev.py
  • Address remaining TODOs
  • Cleanup dead or other commented-out code
  • Collapse commit history

@bvisness
Copy link
Collaborator

bvisness commented Mar 2, 2025

I ran into an issue with the latest Zig from Homebrew (which is the latest Zig release afaik):

% zig build
/Users/bvisness/Developer/orca-app/orca/build.zig:292:34: error: no field or member function named 'addUpdateSourceFiles' in 'Build'
    var stage_angle_artifacts = b.addUpdateSourceFiles();
                                ~^~~~~~~~~~~~~~~~~~~~~
/opt/homebrew/Cellar/zig/0.13.0_1/lib/zig/std/Build.zig:1:1: note: struct declared here
const std = @import("std.zig");
^~~~~
referenced by:
    runBuild__anon_8422: /opt/homebrew/Cellar/zig/0.13.0_1/lib/zig/std/Build.zig:2117:37
    main: /opt/homebrew/Cellar/zig/0.13.0_1/lib/zig/compiler/build_runner.zig:301:29
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

@rdunnington
Copy link
Collaborator Author

Yeah as mentioned in discord you need one of the 0.14 dev releases from master to build this - there were a few patches needed to get this working.

* allow installing orca from scratch by specifying sdk-path
* install orca from default build step
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use build.zig for runtime builds
2 participants