Inital zig build support and integrating it with the CI #982
Inital zig build support and integrating it with the CI #982Avokadoen wants to merge 5 commits intoerincatto:mainfrom
Conversation
|
Before I go ahead and do additional changes I would like some input from you @erincatto:
|
|
Update: given the problems with enkiTS and my lack of knowledge of zig, it is probably best if the zig script does the minimal thing that helps users while still compiling the core library in CI. |
|
Ok. I'll make this PR do the following when I have time:
I have the unit tests compiling and passing with the exception of deterministic one. I'll raise an issue in enkiTS to add support for zig build as well. Fixing the remaining test is trivial at that point. |
d8d5f09 to
cea29db
Compare
This adds support for building box2d as a library for zig 0.14.1
|
Created enkiTS#142 |
|
Converting to draft until enkiTS PR is merged |
|
Seems like the built determinism tests fails on both: ENSURE( data.sleepStep == EXPECTED_SLEEP_STEP );
ENSURE( data.hash == EXPECTED_HASH ); |
|
@erincatto are you suuuuure the test is deterministic? 😅 Not quite sure how a build script can cause a race condition in these tests. Am I maybe missing some flags or macros? |
fe97e23 to
653e3ac
Compare
|
Does zig have some flags for fast math? If the compiler introduces contractions (e.g. fused multiply-add) then determinism will fail. This needs to pass single-threaded before considering multi-threaded determinism. |
|
Issue was that I was missing |
| .shared = false, | ||
| .unit_tests = false, | ||
| .disable_simd = false, | ||
| .avx2 = true, |
There was a problem hiding this comment.
Not sure this is desired, or avx2 should always be explicitly enabled.
Current logic will always enabled avx2 if features is supported by compile target, it will always be false if not supported.
|
@erincatto I think this is ready, before you take a look. These are the following options I did not implement:
It seems like users can lean on cmake for these. I doesnt make sense to support everything for both build infrastructures in my mind: I also changed the CI to utilize a matrix strategy to remove some of the boilerplate in the |
fab38c8 to
30a70a8
Compare
Add - disable_simd (BOX2D_DISABLE_SIMD) - avx2 (BOX2D_AVX2) Additionally update the zon enkiTS reference to point upstream!
|
Sorry for the spam 😮💨 (was wrestling github ci config) |
a3be7ed to
1b17d27
Compare
|
Can the number of CI steps be reduced and still have reasonable confirmation of compatibility? |
|
Yes, each permutation gets its own run in the UI. |
|
Can we reduce the number of stages to 1 or 2? Imagine 10 years from now I have Odin, Swift, MinGW, Zig, Jai, etc. If I have 100 stages this is going to be quite unpleasant. |
|
Sure I'll get to it later today. I'll reduce it to 1 windows + 1 Linux target
You forgot to mention rust! |
|
Reduced zig testing to two jobs: https://github.com/Avokadoen/box2d/actions/runs/18657086820 |
This PR adds a build.zig + build.zig.zon. It also add jobs in the CI to build with zig for windows and linux
This means there is now support for building box2d as a lib and enabling any zig build users (including other C/C++ projects) to trivially call
zig fetch --save git+https://github.com/erincatto/box2dand start using it!TODOs:
Out of PR scope?
option BOX2D_SAMPLES
option BOX2D_BENCHMARKS