-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Always set MACOSX_DEPLOYMENT_TARGET in build scripts #13115
Copy link
Copy link
Open
Labels
A-build-scriptsArea: build.rs scriptsArea: build.rs scriptsC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`O-macosOS: macOSOS: macOSS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Metadata
Metadata
Assignees
Labels
A-build-scriptsArea: build.rs scriptsArea: build.rs scriptsC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`O-macosOS: macOSOS: macOSS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Problem
The environment variables
MACOSX_DEPLOYMENT_TARGET,IPHONEOS_DEPLOYMENT_TARGET,TVOS_DEPLOYMENT_TARGETandWATCHOS_DEPLOYMENT_TARGETare standard environment variables on Apple targets, and are used by compilers to get the desired minimum supported operating system version.When not specified, compilers usually choose some default. The default that
rustcchooses can be retrieved withrustc --target x86_64-apple-darwin --print deployment-target, and e.g. thecccrate has support for detecting this, and passing it on to a C compiler.The problem(s) is that:
cchas, has to be implemented by everybuild.rsscript that wants to call an external compiler.rustcprocess to determine this is inefficient (although probably negligible).Proposed Solution
Cargo always sets these in build scripts when building for the relevant Apple targets.
That is, it sets
MACOSX_DEPLOYMENT_TARGETwhen building for macOS,IPHONEOS_DEPLOYMENT_TARGETwhen building for iOS, and so on.As an example, as an author of a
build.rsscript, I would like to be able to do the following (once a version of Cargo that supports this is in my MSRV):(Note: In contrast to all other environment variables that Cargo sets for build scripts, these are explicitly target dependent).
Notes
CC @BlackHoleFox whom implemented the
rustc --print deployment-targetflag.I'd volunteer to do the implementation work if this feature is desired?