cc-rs icon indicating copy to clipboard operation
cc-rs copied to clipboard

Can we please have full control over the minimum iOS version?

Open ForceBru opened this issue 5 years ago • 3 comments

I was trying to see why my build of rustc for iOS was trying to pass -miphoneos-version-min=7.0 to the compiler, even though I specifically set the following flags before compilation:

CFLAGS_aarch64_apple_ios="-miphoneos-version-min=12.0" CRATE_CC_NO_DEFAULTS=1

The output of the compilation process is the following:

TARGET = Some("aarch64-apple-ios")
OPT_LEVEL = Some("2")
HOST = Some("x86_64-apple-darwin")
CXX_aarch64-apple-ios = Some("/Users/forcebru/Desktop/Test/TOOLCHAIN/bin/clang++")
CXXFLAGS_aarch64-apple-ios = Some("-fPIC -miphoneos-version-min=12.0 --target=aarch64-apple-ios -arch arm64 -miphoneos-version-min=7.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk -fembed-bitcode")
DEBUG = Some("false")
Detecting iOS SDK path for iphoneos

As one can see, the -miphoneos-version-min=12.0 flag is included in CXXFLAGS_aarch64-apple-ios, but it's immediately discarded by the auto-inserted -miphoneos-version-min=7.0 flag that comes right after it.

I think it should be possible to have control over that flag because some features, like thread-local storage (which apparently requires iOS 8.0+ or __IPHONE_OS_VERSION_MIN_REQUIRED > 70100 to be true) are not available with this setting.

This setting is hard-coded here: https://github.com/alexcrichton/cc-rs/blob/caf78d56c7101847304724cca229ad0b14eec26b/src/lib.rs#L1601

It may be better to first check if the IPHONEOS_DEPLOYMENT_TARGET environment variable is set or CFLAGS contains -miphoneos-version-min=<stuff> before switching to default behaviour.

ForceBru avatar Mar 21 '19 21:03 ForceBru

I think these were hardcoded once and simply never changed, seems reasonable to read env vars and add a method too!

alexcrichton avatar Mar 22 '19 14:03 alexcrichton

@alexcrichton when you say

and add a method too!

...what were you thinking there? Something as explicit as

// On `Tool`
pub fn ios_version_min(&self, min_version: &str) -> Result<(), Error> {
    // etc
}

?

turboladen avatar Aug 08 '19 00:08 turboladen

Sounds reasonable to me yeah!

alexcrichton avatar Aug 08 '19 14:08 alexcrichton