Skip to content

ci(macos): drop -stack_size rustflag (breaks proc-macro dylib links)#294

Merged
smunini merged 1 commit into
mainfrom
fix/macos-stack-size-proc-macro
Jul 17, 2026
Merged

ci(macos): drop -stack_size rustflag (breaks proc-macro dylib links)#294
smunini merged 1 commit into
mainfrom
fix/macos-stack-size-proc-macro

Conversation

@smunini

@smunini smunini commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #293

#293 removed -undefined dynamic_lookup (which caused the dyld syscall to map cache into shared region failed / SIGABRT crash) and replaced it with -Wl,-stack_size,0x800000 to preserve the Linux side's 8 MB stack intent. That replacement introduced a new build failure on macOS:

ld: -stack_size option can only be used when linking a main executable
error: could not compile `serde_derive` (lib) due to 1 previous error

Cause

ld64 rejects -stack_size on any link target that isn't a main executable. Cargo applies rustflags to every link invocation — including proc-macro and cdylib crates like serde_derive, which link as -dynamiclib. So the flag fails the build before a single test runs. On Linux the equivalent -zstack-size is silently accepted for shared objects, which is why the same pattern was never a problem there.

Fix

Drop the custom rustflags on macOS entirely. The macOS main-thread stack already defaults to 8 MB — the exact value the Linux side sets explicitly via -zstack-size=8388608 — so no override is needed. (The -stack_size linker arg only affects the main thread anyway; cargo test runs tests on spawned worker threads, so it never influenced the test suite.)

The step now writes only linker = "clang" (the macOS default) plus a comment documenting both flags that must not come back.

Verification

Confirmed on PR #244's runner: with #293 merged, the dyld crash is gone and the build now fails only on this -stack_size error — this PR removes that last flag. The same fix is already pushed to the #244 branch, which is re-running CI now.

https://claude.ai/code/session_01Vnu2A87mWaKnbeFuWZSwkd

Follow-up to #293. Replacing `-undefined dynamic_lookup` with
`-Wl,-stack_size,0x800000` fixed the dyld crash but introduced a new
build failure: ld64 rejects `-stack_size` on any link that is not a
main executable —

    ld: -stack_size option can only be used when linking a main executable

cargo applies rustflags to every link invocation, including
proc-macro/cdylib crates (e.g. serde_derive, linked `-dynamiclib`),
so the flag fails the build before any test runs. On Linux the
equivalent `-zstack-size` is silently accepted for shared objects,
which is why it was never caught there.

macOS already defaults the main-thread stack to 8 MB — the same value
the Linux side sets explicitly — so no override is needed. Drop the
custom rustflags on macOS entirely.

Claude-Session: https://claude.ai/code/session_01Vnu2A87mWaKnbeFuWZSwkd
@claude

claude Bot commented Jul 17, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@smunini
smunini merged commit e21569d into main Jul 17, 2026
20 of 21 checks passed
@smunini
smunini deleted the fix/macos-stack-size-proc-macro branch July 17, 2026 19:21
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

1 participant