Skip to content

feat: Set MACOSX_DEPLOYMENT_TARGET#202

Merged
yutannihilation merged 1 commit intomainfrom
feat/set-MACOSX_DEPLOYMENT_TARGET
Apr 13, 2026
Merged

feat: Set MACOSX_DEPLOYMENT_TARGET#202
yutannihilation merged 1 commit intomainfrom
feat/set-MACOSX_DEPLOYMENT_TARGET

Conversation

@yutannihilation
Copy link
Copy Markdown
Owner

Problem

On macOS, R CMD check produces this linker warning:

ld: warning: object file (...unwind_protect_wrapper.o) was built for newer 'macOS'
version (26.2) than being linked (15.0)

unwind_protect_wrapper.o is compiled by the Rust cc crate (in savvy's build.rs).
Although we export CC and CFLAGS to cargo, the cc crate does not derive the
deployment target from these flags. It has its own lookup chain:
MACOSX_DEPLOYMENT_TARGET env var, then xcrun --show-sdk-version as fallback. Since
MACOSX_DEPLOYMENT_TARGET was not set, it fell back to the SDK version (26.2), while R's
clang defaulted to 15.0 (from its target triple arm64-apple-darwin24).

Fix

Detect the macOS deployment target in configure and export it via BEFORE_CARGO_BUILD
so the cc crate picks it up. Detection order:

  1. MACOSX_DEPLOYMENT_TARGET env var (if already set)
  2. -mmacosx-version-min= flag in R's CC/CFLAGS
  3. __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ preprocessor macro from R's compiler

References

@yutannihilation yutannihilation merged commit 332b21c into main Apr 13, 2026
7 checks passed
@yutannihilation yutannihilation deleted the feat/set-MACOSX_DEPLOYMENT_TARGET branch April 13, 2026 00:24
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