Skip to content

fix: use lld linker for macOS builds to support Sequoia (15.x)#50

Merged
jpmcb merged 1 commit intopapercomputeco:mainfrom
Patrick-Erichsen:main
Feb 3, 2026
Merged

fix: use lld linker for macOS builds to support Sequoia (15.x)#50
jpmcb merged 1 commit intopapercomputeco:mainfrom
Patrick-Erichsen:main

Conversation

@Patrick-Erichsen
Copy link
Contributor

Summary

  • Fixes darwin binaries crashing on macOS 15 (Sequoia) with dyld: __DATA_CONST segment missing SG_READ_ONLY flag
  • Switches from osxcross's ld64 to LLVM's lld linker for darwin cross-compilation

Problem

macOS 15 (Sequoia) enforces that __DATA_CONST segments have the SG_READ_ONLY flag (0x10) set. The osxcross ld64 linker (from cctools-port) doesn't set this flag, causing all darwin binaries to fail immediately on launch:

dyld[74978]: __DATA_CONST segment missing SG_READ_ONLY flag in /usr/local/bin/tapes
dyld[74978]: __DATA_CONST segment missing SG_READ_ONLY flag
Abort trap: 6

Fix

Use -fuse-ld=lld in CGO_LDFLAGS to invoke LLVM's lld linker (already installed in the build container) instead of osxcross's ld64. LLD properly sets the SG_READ_ONLY flag on __DATA_CONST segments.

Compatibility

macOS Version Before After
10.13 - 14.x
15.x (Sequoia)

The minimum deployment target remains macOS 10.13 (verified via otool -l).

Verification

Built with Dagger and verified segment flags with otool:

# Before (broken)
otool -l tapes | grep -A10 "__DATA_CONST"
#   flags 0x0  ❌

# After (fixed)  
otool -l tapes | grep -A10 "__DATA_CONST"
#   flags 0x10 ✅ (SG_READ_ONLY)

Tested binary runs successfully on macOS 15.2:

$ tapes version
Version: dev
Sha: HEAD
Built at: dev

Test locally

dagger call build --ldflags="-s -w" export --path ./test-build
./test-build/darwin/amd64/tapes version

macOS 15 (Sequoia) requires the SG_READ_ONLY flag (0x10) on __DATA_CONST
segments. The osxcross ld64 linker from cctools-port doesn't set this flag,
causing binaries to fail with:

  dyld: __DATA_CONST segment missing SG_READ_ONLY flag

Switch to LLVM's lld linker for darwin builds, which properly sets segment
flags for modern macOS versions.
@Patrick-Erichsen
Copy link
Contributor Author

This fix is clearly entirely Claude but I did run locally and it appears to have resolved the abort error I was getting.

@jpmcb
Copy link
Contributor

jpmcb commented Feb 2, 2026

Very nice: not surprised there's CGO build edge cases. Will validate and get this in today.

@jpmcb
Copy link
Contributor

jpmcb commented Feb 2, 2026

the abort error I was getting.

Can you give me a few more details on your system and how you ran into this error? Are you on an amd64 Mac (not one of the newer Mx series macs which builds for arm64)

Did you see this error off the install script or building locally? I'm not able to reproduce locally:

❯ make build
❯ ./build/darwin/arm64/tapes version
Version: nightly-2-g7052b0c-dirty
Sha: 7052b0cd610acfa45f935acee797f1413b478079
Built at: 2026-02-02 20:26:42.584342288 +0000 UTC m=+0.007636461
❯ curl -fsSL https://download.tapes.dev/install | bash
Downloading tapes latest for darwin/arm64 ...
Installing to /usr/local/bin ...
Password:
Installed tapes version:
Version: v0.0.1-rc.2
Sha: 88c7ec374b97196267a09a986aad273bd9253ffb
Built at: 2026-01-31 17:35:14.585361771 +0000 UTC m=+0.018049758
OS: macOS Sequoia 15.7.3 (24G419) arm64
Host: MacBook Pro (14-inch, 2023)
Kernel: Darwin 24.6.0
CPU: Apple M2 Max (12) @ 3.50 GHz
GPU: Apple M2 Max (38) @ 1.40 GHz [Integrated]
Memory: 28.17 GiB / 32.00 GiB (88%)

You wouldn't happen to be on the OSX beta on 15.7.4?

Regardless, probably a good idea to move over to LLVM's linker which is supported on osxcross's 2.0-llvm-based branch

Copy link
Contributor

@jpmcb jpmcb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get this in since it seems to be the recommended linker flags for Mac builds: @Patrick-Erichsen any more info on your setup you can provide would be extremely helpful!

@jpmcb jpmcb merged commit a95df21 into papercomputeco:main Feb 3, 2026
2 of 6 checks passed
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.

2 participants