feat(flake): darwin host support for genvm builds#291
Draft
MuncleUscles wants to merge 3 commits intolocal/v0.2.11-nix-fixfrom
Draft
feat(flake): darwin host support for genvm builds#291MuncleUscles wants to merge 3 commits intolocal/v0.2.11-nix-fixfrom
MuncleUscles wants to merge 3 commits intolocal/v0.2.11-nix-fixfrom
Conversation
Restructures the flake so every genvm component is built under the current host system (aarch64-darwin, x86_64-linux, etc.) instead of the hardcoded x86_64-linux. On linux hosts the output is unchanged; on darwin hosts `nix build .#all-for-platform.arm64-macos` now advances past the gtt/glibc/wasi-sdk evaluation errors and successfully fetches + builds rust + zig toolchains natively. Changes: - flake.nix: wrap genvm-release in flake-utils.lib.eachSystem for x86_64-linux/aarch64-linux/aarch64-darwin/x86_64-darwin. Move all-for-platform + components under legacyPackages.<system> so they thread per-system while keeping the shorthand `.#all-for-platform.X` working. Gate glibc in devShell packages and LD_LIBRARY_PATH on isLinux. - runners/default.nix + runners/support/all/head.nix: accept pkgs as an arg so runners evaluate under the caller's nixpkgs pin instead of creating their own x86_64-linux one. - support/rust.nix: default system to pkgs.stdenv.hostPlatform.system so the rust toolchain matches the build host. Gate glibc + patchelf fixupPhase behind isLinux. - support/compile-rust.nix: gate glibc in nativeBuildInputs behind isLinux. Replace hardcoded /build/libs with $TMPDIR/__libs so the staging path is writable on darwin sandboxes. - support/zig.nix: default system to host, add x86_64-darwin and aarch64-darwin (via name-mapping to zig's 'aarch64-macos' key). Replace /build/.zig-cache with $TMPDIR/.zig-cache. - runners/support/wasi-sdk.nix: per-host wasi-sdk tarball selection. Gate autoPatchelfHook behind isLinux; darwin Mach-O needs no ELF patching. STILL FAILING on darwin at link stage: the zig-cc wrapper filters Darwin-specific flags (-framework etc.) but strips `-Wl,-exported_symbols_list` which rustc emits for native aarch64-darwin builds. Likely fix: skip zig-cc when host == target (use the stdenv's native cc instead, since cross-compilation is only needed when host != target). Linux CI path is unaffected — eachSystem["x86_64-linux"] follows the same code path as before (same pkgs, same components).
When building aarch64-apple-darwin from an aarch64-darwin host the toolchain is native — rustc emits darwin-specific linker flags (`-Wl,-exported_symbols_list`, `-framework`, ...) that the zig-cc wrapper can't forward. Route native darwin targets straight through rustc's default cc instead; only install the zig-cc aarch64-darwin cargo env on non-darwin hosts where we're actually cross-compiling.
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The v0.2.11 release commit (b4406e5) committed flake-config.json with the patched `v0.2.11 / a605f30` values while flake-config.orig.json stayed on the canonical `vTEST / fake` placeholders. pre-commit's check-flake-config-identical hook fails on that divergence. Resetting .json to match .orig.json — release builds patch these on the fly (see genlayer-dev-env StepBuildGenVM), so the committed state should be the placeholder, not a specific release.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes the genvm flake evaluate and build under
aarch64-darwin/x86_64-darwinhosts, not justx86_64-linux. Linux path is unchanged.Stacked on top of
local/v0.2.11-nix-fix(= PR #290's predecessor branch, same scope + a couple of version fixups). Draft because that base isn't the public main — a rebase onto currentmainwill be needed before this can land; opening it now for early review per the user's ask.What changed
Two commits:
wip(flake): parameterise build host by system for darwin support— most of the structural work.flake.nixwrapsgenvm-releaseinflake-utils.lib.eachSystemfor{x86_64-linux, aarch64-linux, aarch64-darwin, x86_64-darwin}, movesall-for-platform/components underlegacyPackages.<system>, and gatesglibc+LD_LIBRARY_PATHin the devShell behindisLinux.runners/default.nix+runners/support/all/head.nixacceptpkgsas an arg, so runners evaluate against the caller's nixpkgs pin instead of creating a freshx86_64-linuxone internally.support/rust.nixdefaultssystemtopkgs.stdenv.hostPlatform.system, gatesglibc+ thepatchelffixupPhasebehindisLinux.support/compile-rust.nixgatesglibcinnativeBuildInputsbehindisLinux. Replaces hardcoded/build/libswith$TMPDIR/__libsso the staging path is writable inside darwin sandboxes.support/zig.nixdefaultssystemto host, addsx86_64-darwinandaarch64-darwin(the zig upstream key isaarch64-macos, so we name-map), replaces/build/.zig-cachewith$TMPDIR/.zig-cache.runners/support/wasi-sdk.nixper-host wasi-sdk tarball selection; gatesautoPatchelfHookbehindisLinux(Mach-O needs no ELF patching).fix(rust): skip zig-cc when host == target (native darwin builds)— the link-stage follow-up.aarch64-apple-darwinfrom anaarch64-darwinhost the toolchain is native — rustc emits darwin-specific linker flags (-Wl,-exported_symbols_list,-framework, …) that thezig-ccwrapper can't forward. Route native darwin targets straight through rustc's defaultcc.zig-ccstill wraps non-darwin→darwin cross-compiles.Validated
nix build .#all-for-platform.arm64-macos— ✅ Mach-Oarm64binary (genvm-modules)nix build .#all-for-platform.arm64-macos-executor— ✅ Mach-Oarm64binarynix build .#all-for-platform.universal— ❌ fails with cpython-determinism hash mismatch (separately being fixed upstream by JM)nix build .#all-for-platform.amd64-linux/amd64-linux-executorstill reproduce the same output paths as before this branch (confirmed by evaluating with ax86_64-linuxhost).Known gaps
universal/universal-manifestbuilds (python + WASM runners) still fail on darwin because the cpython fixed-output hashes aren't deterministic across hosts yet — that's a separate line of work. The darwin fix here lets you buildall-for-platform.arm64-macos{,-executor}natively, which is what dev-env needs to bring up the stack on Mac.mainis ~50 commits old. Before landing: rebase this onto currentmainand revalidate eachnix buildtarget. Expected conflicts are inflake.nix(structural) plussupport/*.nix(localized).Why the PR is split this way
Keeping the base as
local/v0.2.11-nix-fixshows just the darwin-specific delta (~300 LOC across 7 files) instead of the 98KB diff vsmainthat a fresh cherry-pick onto main would include. Once the base merges or this gets rebased, the PR can be retargeted.