fix: use lld linker for macOS builds to support Sequoia (15.x)#50
fix: use lld linker for macOS builds to support Sequoia (15.x)#50jpmcb merged 1 commit intopapercomputeco:mainfrom
Conversation
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.
|
This fix is clearly entirely Claude but I did run locally and it appears to have resolved the abort error I was getting. |
|
Very nice: not surprised there's CGO build edge cases. Will validate and get this in today. |
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: You wouldn't happen to be on the OSX beta on Regardless, probably a good idea to move over to LLVM's linker which is supported on osxcross's |
jpmcb
left a comment
There was a problem hiding this comment.
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!
Summary
dyld: __DATA_CONST segment missing SG_READ_ONLY flagProblem
macOS 15 (Sequoia) enforces that
__DATA_CONSTsegments have theSG_READ_ONLYflag (0x10) set. The osxcross ld64 linker (from cctools-port) doesn't set this flag, causing all darwin binaries to fail immediately on launch:Fix
Use
-fuse-ld=lldin CGO_LDFLAGS to invoke LLVM's lld linker (already installed in the build container) instead of osxcross's ld64. LLD properly sets theSG_READ_ONLYflag on__DATA_CONSTsegments.Compatibility
The minimum deployment target remains macOS 10.13 (verified via
otool -l).Verification
Built with Dagger and verified segment flags with
otool:Tested binary runs successfully on macOS 15.2:
Test locally