feat(build): add a macOS cross-architecture dev shell#724
Conversation
Add a `cross` flake dev shell that supplies the target-arch zlib + libgit2 (fetched as prebuilt substitutes), so `nix develop .#cross` + `scripts/build.sh --arch x86_64` links a working x86_64 binary on an arm64 host (and vice versa). The native clang cross-emits object code via -arch (see ARCHFLAGS in scripts/env.sh); this shell only provides the target-arch dependency libraries the link needs. Running the produced binary on Apple Silicon still requires Rosetta. Depends on the env.sh / Makefile.cbm arch changes (the build fix for this issue). Refs DeusData#705. Signed-off-by: Kris Williams <115474+kriswill@users.noreply.github.com>
|
Huge thanks for opening this PR and for the work you put into it. This touches the Nix flake / build environment, so it will need the usual careful build-infra review before merge. The maintainer shop is currently full, so this may sit for a bit before it gets a proper review, but we will come back with real feedback as soon as possible. |
|
Thanks. Because this changes the Nix build shell and target-arch dependency resolution, maintainers need to verify it after #723. Could you add the exact |
|
@DeusData I added this cross-architecture bit to test #723 under my MacOS+Nix config, to prove that the compiler architecture probe works. I personally am not really interested in compiling The purpose of the probe change is ONLY to enable an engineer to follow the instructions in CONTRIBUTING.md about running the build toolchain when using a nix devshell on Apple Silicon, which currently does NOT work see #705 |
What does this PR do?
Adds a
crossflake dev shell so macOS users can build the other arch locally:nix develop .#crossthenscripts/build.sh --arch x86_64(on Apple Silicon) produces a working x86_64 binary — and vice versa on Intel.The native clang already cross-emits object code via
-arch(set up by the build fix in #723 —scripts/env.shexportsARCHFLAGS). The only thing missing for a cross link is the target-arch dependency libraries, because the dev shell'szlib/libgit2are host-arch only. This shell puts the target-archzlib(a hard-lzdependency) andlibgit2(optional, via pkg-config) on the link path; they're fetched as prebuilt substitutes, so building needs no Rosetta — only running an x86_64 binary on Apple Silicon does.Scope is deliberately minimal:
flake.nixonly, an addedcrossDevShellshelper plus one merged attribute. The existingdefaultshell is untouched, and there are noflake.lock/.envrcchanges.Validation (host aarch64-darwin, targeting x86_64)
The binary links the x86_64 slices of libgit2 + zlib (no stale host-arch references). Constraint, as flagged on #705: a working x86_64 build needs x86_64
zlib(mandatory) +libgit2, which this shell provides as substitutes.Depends on #723 (
ARCHFLAGS+ the compiler capability probe) — the cross shell is only useful once that lands, so please merge this after #723.Refs #705.Checklist
git commit -s) — required, CI rejectsunsigned commits (DCO, see CONTRIBUTING.md)
make -f Makefile.cbm test)make -f Makefile.cbm lint-ci)