a73x

acdaffb0

build: RELEASE_TARGET follows the host, and a Mac cuts a Mac release

a73x   2026-09-04 12:50

Commit message
build: RELEASE_TARGET follows the host, and a Mac cuts a Mac release

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SakwJEwD9dXBoRP5kWbemW

Makefile
Old New
@@ -15,10 +15,19 @@ ZIG ?= $(CURDIR)/deps/zig/zig
15 # which lives in the SDK) fails with "file not found" and `make install` on 15 # which lives in the SDK) fails with "file not found" and `make install` on
16 # a Mac cannot produce a binary. Found by test/xos.sh, which is the first 16 # a Mac cannot produce a binary. Found by test/xos.sh, which is the first
17 # thing in the tree to run `make install` on Darwin. 17 # thing in the tree to run `make install` on Darwin.
18 #
19 # RELEASE_TARGET and SHA256 follow the host for the same reason; the comment
20 # above `release` below says why that is now right. RELEASE_BUILD_TARGET is
21 # the `-Dtarget=` word and RELEASE_TARGET the tarball's NAME, because on a
22 # Mac those two differ: the artifact is `aarch64-macos` and the only spelling
23 # that builds it is `native`, per the paragraph above.
18 UNAME_S := $(shell uname -s) 24 UNAME_S := $(shell uname -s)
19 ifeq ($(UNAME_S),Darwin) 25 ifeq ($(UNAME_S),Darwin)
20 export PATH := $(CURDIR)/deps/mac-sdk/bin:/opt/homebrew/bin:$(PATH) 26 export PATH := $(CURDIR)/deps/mac-sdk/bin:/opt/homebrew/bin:$(PATH)
21 MUX_TARGET ?= native 27 MUX_TARGET ?= native
28 RELEASE_TARGET ?= aarch64-macos
29 RELEASE_BUILD_TARGET ?= native
30 SHA256 ?= shasum -a 256
22 endif 31 endif
23 MUX_TARGET ?= x86_64-linux-musl 32 MUX_TARGET ?= x86_64-linux-musl
24 33
@@ -86,20 +95,34 @@ install: mac-sdk
86 VERSION := $(shell sed -n 's/^[[:space:]]*const version = "\(.*\)";/\1/p' build.zig | head -1) 95 VERSION := $(shell sed -n 's/^[[:space:]]*const version = "\(.*\)";/\1/p' build.zig | head -1)
87 RELDIR ?= dist 96 RELDIR ?= dist
88 RELBIN = $(RELDIR)/v$(VERSION) 97 RELBIN = $(RELDIR)/v$(VERSION)
89 # Its OWN target, not MUX_TARGET: what a release IS must not follow the host 98 # The release DOES follow the host now, which reverses the rule this line
90 # that cuts it. MUX_TARGET follows the host so a Mac installs a Mac binary, 99 # used to carry: "what a release IS must not follow the host that cuts it".
91 # and hoisting it to the top of this file put `make release` on a Mac one 100 # That rule was written when there was one release, a Linux one, and the
92 # `?=` away from writing a Mach-O binary into mux-vN-aarch64-macos.tar.gz -- 101 # danger it named was a Mac quietly writing a Mach-O binary into the Linux
93 # an artifact the publish flow would take for the Linux one. Cutting a 102 # tarball. It cannot: the target is in the tarball's NAME, so a Mac cuts
94 # release stays a Linux job for a second reason anyway: the checksum line 103 # mux-vN-aarch64-macos.tar.gz and nothing downstream can mistake that file
95 # below spells sha256sum, which macOS does not ship. 104 # for mux-vN-x86_64-linux-musl.tar.gz. And now that mux runs on two
105 # operating systems, a release IS one tarball per OS, each cut on that OS —
106 # there is no cross-compiling the Mac one (README, "macOS"), so the choice
107 # is not between one host and another but between a Mac release existing and
108 # not existing. The old rule's second argument was that macOS ships no
109 # sha256sum; SHA256 at the top of this file answers that with `shasum -a
110 # 256` instead of making it a reason to refuse.
111 #
112 # RELEASE_BUILD_TARGET is the word handed to `-Dtarget=`, kept apart from
113 # the NAME because on Darwin the two differ: `native` is the only spelling
114 # that builds, and `aarch64-macos` is what the artifact must be called. On
115 # Linux they are the same string, so this recipe is byte-for-byte what it
116 # was.
96 RELEASE_TARGET ?= x86_64-linux-musl 117 RELEASE_TARGET ?= x86_64-linux-musl
118 RELEASE_BUILD_TARGET ?= $(RELEASE_TARGET)
119 SHA256 ?= sha256sum
97 RELTAR = $(RELDIR)/mux-v$(VERSION)-$(RELEASE_TARGET).tar.gz 120 RELTAR = $(RELDIR)/mux-v$(VERSION)-$(RELEASE_TARGET).tar.gz
98 # The version guard below asks the STRIPPED artifact what it is, so a 121 # The version guard below asks the STRIPPED artifact what it is, so a
99 # stale stage directory cannot ship under a bumped number. 122 # stale stage directory cannot ship under a bumped number.
100 release: 123 release:
101 @test -n "$(VERSION)" || { echo "release: no version found in build.zig"; exit 1; } 124 @test -n "$(VERSION)" || { echo "release: no version found in build.zig"; exit 1; }
102 $(ZIG) build -Dtarget=$(RELEASE_TARGET) -Doptimize=ReleaseSafe -p $(RELDIR)/stage 125 $(ZIG) build -Dtarget=$(RELEASE_BUILD_TARGET) -Doptimize=ReleaseSafe -p $(RELDIR)/stage
103 rm -rf $(RELBIN) $(RELTAR) 126 rm -rf $(RELBIN) $(RELTAR)
104 install -d $(RELBIN) 127 install -d $(RELBIN)
105 install -m755 $(RELDIR)/stage/bin/mux $(RELBIN)/ 128 install -m755 $(RELDIR)/stage/bin/mux $(RELBIN)/
@@ -109,7 +132,7 @@ release:
109 echo "release: mux reports $$got, expected $(VERSION)"; exit 1; } 132 echo "release: mux reports $$got, expected $(VERSION)"; exit 1; }
110 tar czf $(RELTAR) -C $(RELBIN) mux 133 tar czf $(RELTAR) -C $(RELBIN) mux
111 @echo 134 @echo
112 @sha256sum $(RELTAR) 135 @$(SHA256) $(RELTAR)
113 @echo "install: tar xzf $(RELTAR) -C ~/.local/bin" 136 @echo "install: tar xzf $(RELTAR) -C ~/.local/bin"
114 @echo "remote: ssh HOST 'mkdir -p ~/.local/bin && tar xzf - -C ~/.local/bin' < $(RELTAR)" 137 @echo "remote: ssh HOST 'mkdir -p ~/.local/bin && tar xzf - -C ~/.local/bin' < $(RELTAR)"
115 @echo "publish: git collab release publish v$(VERSION) $(RELTAR)" 138 @echo "publish: git collab release publish v$(VERSION) $(RELTAR)"