Skip to content

Build a portable builder! - #1304

Merged
plajjan merged 2 commits into
mainfrom
1290-portable-builder
May 24, 2023
Merged

Build a portable builder!#1304
plajjan merged 2 commits into
mainfrom
1290-portable-builder

Conversation

@plajjan

@plajjan plajjan commented May 24, 2023

Copy link
Copy Markdown
Contributor

One pin down the rabbit hole! Switched from using the zig build frontend, which under the hood just builds the builder program based on our build.zig. It's really build_runner.zig, which in turn imports build.zig. We now do that step manually and are then able to inject our own compilation arguments, like which arch to compile for and should thus get a portable executable that is built for the base CPU feature set without all the bells and whistles of the native CPU of the build machine!

Default to use the zig build!

Fixes #1305.

@plajjan
plajjan force-pushed the 1290-portable-builder branch from 96f0ec6 to 2456c82 Compare May 24, 2023 15:44
plajjan added 2 commits May 24, 2023 17:52
One pin down the rabbit hole! Switched from using the `zig build`
frontend, which under the hood just builds the builder program based on
our build.zig. It's really build_runner.zig, which in turn imports
build.zig. We now do that step manually and are then able to inject our
own compilation arguments, like which arch to compile for and should
thus get a portable executable that is built for the base CPU feature
set without all the bells and whistles of the native CPU of the build
machine!

Default to use the zig build!
@plajjan
plajjan force-pushed the 1290-portable-builder branch from e6baa04 to 7ad3be0 Compare May 24, 2023 15:52
@plajjan

plajjan commented May 24, 2023

Copy link
Copy Markdown
Contributor Author

I have run this PR through 4 CI runs and all jobs have succeeded with exception for brew-macos which is due to #1297. I have verified that we have CI runs where the build-debs job runs on a newer CPU than the subsequent run-linux test jobs, so we indeed we have a portable builder binary. For example https://github.com/actonlang/acton/actions/runs/5070800560/jobs/9108225635 which is the build-debs job on a Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz and then the subsequent https://github.com/actonlang/acton/actions/runs/5070800560/jobs/9108399750 which is on a Intel (R) Xeon(R) CPU E5-2673 v3 @ 2.40GHz. All good. Merging!

@plajjan
plajjan merged commit 7c2b554 into main May 24, 2023
@plajjan
plajjan deleted the 1290-portable-builder branch May 24, 2023 18:20
@sydow

sydow commented May 31, 2023

Copy link
Copy Markdown
Collaborator

I just did my first pull after this merge. It seems that Apple's M1 architecture is not supported?

acton> make
/Library/Developer/CommandLineTools/usr/bin/make dist/zig
make[1]: `dist/zig' is up to date.
/Library/Developer/CommandLineTools/usr/bin/make distribution
rm -rf builder/zig-cache builder/zig-out
(echo 'const root = @import("build.zig");'; tail -n +2 deps/zig/lib/build_runner.zig) > builder/build_runner.zig
cd builder && ../deps/zig/zig build-exe build_runner.zig -femit-bin=builder -mcpu=aarch64
info: available CPUs for architecture 'aarch64':
a64fx
ampere1
ampere1a
apple_a10
apple_a11
apple_a12
apple_a13
apple_a14
apple_a15
apple_a16
apple_a7
apple_a8
apple_a9
apple_latest
apple_m1
apple_m2
apple_s4
apple_s5
carmel
cortex_a34
cortex_a35
cortex_a510
cortex_a53
cortex_a55
cortex_a57
cortex_a65
cortex_a65ae
cortex_a710
cortex_a715
cortex_a72
cortex_a73
cortex_a75
cortex_a76
cortex_a76ae
cortex_a77
cortex_a78
cortex_a78c
cortex_r82
cortex_x1
cortex_x1c
cortex_x2
cortex_x3
cyclone
emag
exynos_m1
exynos_m2
exynos_m3
exynos_m4
exynos_m5
falkor
generic
kryo
neoverse_512tvb
neoverse_e1
neoverse_n1
neoverse_n2
neoverse_v1
neoverse_v2
saphira
thunderx
thunderx2t99
thunderx3t110
thunderxt81
thunderxt83
thunderxt88
tsv110
xgene1

error: unknown CPU: 'aarch64'
make[1]: *** [builder/builder] Error 1
make: *** [all] Error 2

@plajjan

plajjan commented May 31, 2023

Copy link
Copy Markdown
Contributor Author

@sydow haha, get a real machine ;)

No sorry, it was meant to work but I never did verify it.

Can you open a new issue on it though, don't want to drag around an old PR for tracking this. I'm stopping work right now but will be back later and see if I can have a look. I do have a macbook with an m2 cpu here, so I should be able to reproduce and fix! Sorry again

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.

Figure out how to run zig build in a fast and portable way

2 participants