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 |
|
Thank you for this, and apologies for the wait — the delay is entirely on us, and unfortunately What is genuinely well done here. It also fills a real gap rather than duplicating one. #723 landed the compile half ( The trim: please drop the libgit2 and pkg-config parts. On 5 July — five days after you opened this — commit So on current
Nothing detects or links libgit2 any longer, so merging as-is would silently reintroduce a GPL-adjacent reference into a tree we scrubbed on purpose. GitHub will still merge it cleanly, which is precisely why it is worth catching by eye. What remains after the trim — gnumake plus the target-arch zlib include and lib exports — is the genuinely missing piece, since One more small thing: the And thank you for being straight that no CI runner exercises the cross shell. Agreed, and we would rather keep it that way than grow the matrix for a developer convenience — the honest disclosure is worth more to us than the coverage would be. |
|
Thank you for this — and thank you especially for the reason you gave for writing it. You said you didn't personally need x86_64-darwin builds and were doing it to exercise the arch probe from #723. Contributions that exist to make someone else's change verifiable are the ones maintainers quietly depend on and rarely get. It has shipped as #1761, with I'm closing this rather than merging it, and the reason is entirely on my side: the libgit2 trim I asked for turned out to be larger than "delete two lines". Since you branched, What survived unchanged, because it was right:
What changed: libgit2 and One honest limitation I've recorded on the new PR: there's no Nix toolchain on my machine, so I validated by parsing the flake with #705 stays open until this lands, then closes with it. Thanks again — for the shell, and for testing someone else's PR on your own time. |
`nix develop .#cross` on macOS exposes the OTHER darwin architecture's zlib, so `scripts/build.sh --arch <target>` can link an x86_64 binary on Apple Silicon and vice versa. The native clang already cross-emits object code via -arch; zlib is the product's single link-time dependency, and the host-arch copy cannot satisfy a cross link, which is the whole gap. Darwin-gated and opt-in: the attribute set is empty on Linux, the default shell is untouched, flake.lock is unchanged and no new flake input is introduced. The shell deliberately does not use inputsFrom, since that would put the host-arch zlib back on the link path. Distilled from DeusData#724 by Kris Williams. That version also wired libgit2 via pkg-config, which is now dead weight: libgit2 was removed project-wide for GPL-licensing reasons and appears nowhere in the tree, so both it and pkg-config are dropped here — leaving zlib as the only library the cross shell needs to place. Validated by parsing the flake with nix-instantiate in a nixos/nix container (no Nix toolchain on the maintainer host), which also confirms the shellHook's ''${...} escaping resolves to literal shell expansions. Evaluating or entering the shell needs a macOS host with Nix; no CI leg exercises it, as noted on the original PR. Addresses DeusData#705. Co-authored-by: Kris Williams <115474+kriswill@users.noreply.github.com> Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
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)