10000 Move build system to zig build by rdunnington · Pull Request #101 · orca-app/orca · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Move build system to zig build #101

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

Merged
merged 20 commits into from
Jul 8, 2025
Merged

Move build system to zig build #101

merged 20 commits into from
Jul 8, 2025

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 -
  • Track down why Dawn startup is so much slower in zig version - maybe not building release version by default?
  • Update CI scripts orcabuild -> zig build
  • Add test job to CI with zig build test
  • Add sketches to CI
  • Update main build build to use most recent angle/dawn release by default instead of requiring a build
  • Update README
  • Port macos @rpath stuff from dev.py
  • Address remaining TODOs
  • Cleanup dead or other commented-out code
  • Collapse commit history
  • Investigate unity build dependencies not triggering real rebuild

Followup tasks for after this change goes in:

  • Try to get delay-loading to work for graphics DLLs on windows (webgpu, EGL, GLESv2)
  • Add support for building, bundling, and running wasm samples. Will unlock running wasm-based tests.
  • Port or otherwise update the GLES binding generation python script to remove the last python dependency
  • Investigate moving away from unity build

@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.

@rdunnington rdunnington force-pushed the rjd/zig-build branch 3 times, most recently from 4e59ad6 to c1fbe47 Compare March 15, 2025 05:05
@rdunnington
Copy link
Collaborator Author

Now that zig 0.14 is out, I've updated everything to use it so you should be able to use the main release now.

@rdunnington rdunnington force-pushed the rjd/zig-build branch 3 times, most recently from 544ae1a to c25f3f9 Compare April 24, 2025 06:59
@rdunnington rdunnington force-pushed the rjd/zig-build branch 8 times, most recently from 37346b8 to a890631 Compare July 3, 2025 18:31
@rdunnington rdunnington marked this pull request as ready for review July 3, 2025 18:33
Copy link
Collaborator
@Parzival-3141 Parzival-3141 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few tweaks but lookin good otherwise

* This change introduces a new build system leveraging the Zig toolchain. With these changes, the
  orcadev workflow is deprecated, though the scripts are left in for now as a reference, and
  because there is still one python dependency left in the repo (generating GLES binding json).
  Some immediate benefits of the change:
    * 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
* Removes angle/dawn builds in favor of leveraging the zig package manager to download platform-
  appropriate artfiacts from angle/dawn repos in the orca github org. This reduces a lot of
  complexity in the build system and lets us remove all related files and CI jobs.
* Fixed a bunch of UBsan errors in C code
* CI now builds and runs tests by default (disabled on windows for now)
* CI now builds sketches by default to avoid further bitrotting
* Checked in generated/copied files such as shader header, wasm-C bindings, GL header
* addStatic/addShared library -> addLibrary
* unmanaged arraylist
Copy link
Collaborator
@Parzival-3141 Parzival-3141 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs some fixes when cross compiling

…s, formatting changes

Switched all calls of addExecutable/Library to use `.root_modue = b.createModule(.{...}),`.
Switched target of build-time scripts to use the host target (including python).
Switched unecessarily mutable variables to `const`. Not sure why these weren't compile errors.
Reformatted some declarations (`const foo = Bar{} -> const foo: Bar = .{}`).
martinfouilleul and others 9E81 added 3 commits July 5, 2025 17:10
…mits.

- The angle one also fixes the LC_ID_DYLIB name of the angle libs to use @rpath.
- Remove some unneeded AddRPath calls from build.zig
- Copy the orca-libc headers when packaging the sdk
rdunnington and others added 4 commits July 7, 2025 14:17
* the GLES api very rarely changes, so we'll just checkin the .json file so it's always available
* this also removes the last Python dependency
@martinfouilleul martinfouilleul merged commit df62ebc into main Jul 8, 2025
6 checks passed
@martinfouilleul martinfouilleul deleted the rjd/zig-build branch July 8, 2025 10:11
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
4 participants
0