rules_rust forwards Apple C++ toolchain linker args to rustc, including clang targets like:
-C link-arg=-target
-C link-arg=arm64-apple-macosx26.0
When developing on macOS, these linker arguments commonly come from the Xcode toolchain created by apple_support. With apple_support, the minimum deployment version defaults to whatever the installed SDK version is.
That target argument encodes the Apple deployment target for clang. However, rustc does its own minimum deployment target detection. This is mediated through the MACOSX_DEPLOYMENT_TARGET env variable. If MACOSX_DEPLOYMENT_TARGET is unset, rustc uses its built-in default and injects its own -mmacosx-version-min (which defaults to 11.0.0 on arm64)
Source: https://doc.rust-lang.org/nightly/rustc/platform-support/apple-darwin.html#deployment-target
This can make clang receive conflicting deployment targets, for example:
-mmacosx-version-min=11.0.0
-target arm64-apple-macosx26.0
With Rust 1.97 surfacing linker stderr, this issue is now more visible, with the following warning printed for every rust target:
warning: linker stderr: clang: overriding '-mmacosx-version-min=11.0.0' option with '-target arm64-apple-macosx26.5' [-Woverriding-option]
|
= note: `#[warn(linker_messages)]` on by default
I believe rules_rust should continue to forward linker arguments from the C++ toolchain, but should also pass MACOSX_DEPLOYMENT_TARGET to rustc when compiling for macOS targets. Similar behavior should be done for other Apple platforms as well (e.g. IPHONEOS_DEPLOYMENT_TARGET).
rules_rust forwards Apple C++ toolchain linker args to rustc, including clang targets like:
When developing on macOS, these linker arguments commonly come from the Xcode toolchain created by
apple_support. Withapple_support, the minimum deployment version defaults to whatever the installed SDK version is.That target argument encodes the Apple deployment target for clang. However, rustc does its own minimum deployment target detection. This is mediated through the
MACOSX_DEPLOYMENT_TARGETenv variable. IfMACOSX_DEPLOYMENT_TARGETis unset, rustc uses its built-in default and injects its own-mmacosx-version-min(which defaults to 11.0.0 on arm64)Source: https://doc.rust-lang.org/nightly/rustc/platform-support/apple-darwin.html#deployment-target
This can make clang receive conflicting deployment targets, for example:
With Rust 1.97 surfacing linker stderr, this issue is now more visible, with the following warning printed for every rust target:
I believe rules_rust should continue to forward linker arguments from the C++ toolchain, but should also pass
MACOSX_DEPLOYMENT_TARGETtorustcwhen compiling for macOS targets. Similar behavior should be done for other Apple platforms as well (e.g.IPHONEOS_DEPLOYMENT_TARGET).