Skip to content

Commit 90ecad0

Browse files
committed
Update minimum required Apple versions
The versions supported by Rust was updated in rust-lang/rust#104385 to: - macOS: 10.12 Sierra - iOS: 10.0 - tvOS: 10.0 - watchOS: 5.0 Additionally, the armv7-apple-ios target was removed. Finally, since v1.0.84 of `cc` (has been yanked, but 1.0.85 will include it as well), there is much better support for specifying the deployment target for Apple targets, so I've removed the corresponding code from objc-sys.
1 parent b9fc9f3 commit 90ecad0

File tree

29 files changed

+55
-3488
lines changed

29 files changed

+55
-3488
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ env:
2525
# Faster compilation, error on warnings and only document current crate
2626
RUSTFLAGS: "--codegen=debuginfo=0 --deny=warnings"
2727
RUSTDOCFLAGS: "--deny=warnings"
28-
# Minimum deployment target
29-
MACOSX_DEPLOYMENT_TARGET: 10.7
30-
IPHONEOS_DEPLOYMENT_TARGET: 7.0
28+
# Minimum deployment targets.
29+
# Follows `rustc --target=x86_64-apple-darwin --print deployment-target`
30+
MACOSX_DEPLOYMENT_TARGET: 10.12
31+
# Follows `rustc --target=x86_64-apple-ios --print deployment-target`
32+
IPHONEOS_DEPLOYMENT_TARGET: 10.0
3133
# We only support compiling Objective-C code with clang
3234
CC: clang
3335
CXX: clang++
@@ -102,7 +104,7 @@ jobs:
102104
--features=$INTERESTING_FEATURES
103105
--features=unstable-frameworks-macos-12
104106
- name: iOS 32bit
105-
target: armv7-apple-ios
107+
target: armv7s-apple-ios
106108
build-std: true
107109
args: >-
108110
-Zbuild-std
@@ -362,7 +364,7 @@ jobs:
362364
frameworks: macos-11
363365
- name: Test macOS old SDK
364366
# Oldest macOS version we support
365-
sdk: "10.7"
367+
sdk: "10.12"
366368
frameworks: macos-10-7
367369
- name: Test macOS nightly
368370
nightly: true
@@ -380,11 +382,6 @@ jobs:
380382
- name: Build iOS ARM64
381383
target: aarch64-apple-ios
382384
frameworks: ios
383-
- name: Build iOS ARMv7
384-
target: armv7-apple-ios
385-
nightly: true
386-
build-std: true
387-
frameworks: ios
388385
- name: Build iOS ARMv7s
389386
target: armv7s-apple-ios
390387
nightly: true

crates/block-sys/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ targets = [
7575
# iOS
7676
"aarch64-apple-ios",
7777
"x86_64-apple-ios",
78-
# "armv7-apple-ios",
7978
# "i386-apple-ios",
8079
# GNUStep
8180
"x86_64-unknown-linux-gnu",

crates/block2/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ targets = [
4949
# iOS
5050
"aarch64-apple-ios",
5151
"x86_64-apple-ios",
52-
# "armv7-apple-ios",
5352
# "i386-apple-ios",
5453
# GNUStep
5554
"x86_64-unknown-linux-gnu",

crates/header-translator/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ fn main() -> Result<(), BoxError> {
9292
],
9393
Platform::IPhoneOs => &[
9494
// "arm64-apple-ios7.0.0",
95-
// "armv7-apple-ios7.0.0",
9695
// "armv7s-apple-ios",
9796
// "arm64-apple-ios14.0-macabi",
9897
// "x86_64-apple-ios13.0-macabi",

crates/icrate/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ targets = [
3939
# iOS
4040
"aarch64-apple-ios",
4141
"x86_64-apple-ios",
42-
# "armv7-apple-ios",
4342
# "i386-apple-ios",
4443
# GNUStep
4544
"x86_64-unknown-linux-gnu",

crates/icrate/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ These bindings are automatically generated from the SDKs in Xcode 14.3.1 (will
1616
be periodically updated).
1717

1818
Currently supports:
19-
- macOS: `10.7-13.1`
20-
- iOS/iPadOS: `7.0-16.2` (WIP)
21-
- tvOS: `9.0-16.1` (WIP)
22-
- watchOS: `1.0-9.1` (WIP)
19+
- macOS: `10.12-13.1`
20+
- iOS/iPadOS: `10.0-16.2` (WIP)
21+
- tvOS: `10.0-16.1` (WIP)
22+
- watchOS: `5.0-9.1` (WIP)

crates/objc-sys/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ unstable-exception = ["cc"]
6161
unstable-docsrs = []
6262

6363
[build-dependencies]
64-
cc = { version = "1", optional = true }
64+
cc = { version = "1.0.80", optional = true }
6565

6666
[package.metadata.docs.rs]
6767
default-target = "x86_64-apple-darwin"
@@ -76,7 +76,6 @@ targets = [
7676
# iOS
7777
"aarch64-apple-ios",
7878
"x86_64-apple-ios",
79-
# "armv7-apple-ios",
8079
# "i386-apple-ios",
8180
# GNUStep
8281
"x86_64-unknown-linux-gnu",

crates/objc-sys/README.md

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,14 @@ This is used by default, and has the highest support priority (all of
3636
The supported runtime version (higher versions lets the compiler enable newer
3737
optimizations, at the cost of not supporting older operating systems) can be
3838
chosen using the standard `X_DEPLOYMENT_TARGET` environment variables:
39-
- macOS: `MACOSX_DEPLOYMENT_TARGET`
40-
- Default: `10.7`, `11.0` on Aarch64
41-
- Minimum: `10.7`
42-
- iOS / iPadOS: `IPHONEOS_DEPLOYMENT_TARGET`
43-
- Default: `7.0`
44-
- Minimum: `5.0` (theoretically)
45-
- tvOS: `TVOS_DEPLOYMENT_TARGET`
46-
- Default: `7.0`
47-
- Minimum: `5.0` (theoretically)
48-
- watchOS: `WATCHOS_DEPLOYMENT_TARGET`
49-
- Default: `5.0`
50-
- Minimum: `1.0` (theoretically)
51-
52-
The default versions are the [same as those Rust itself has][rust-apple-spec].
53-
54-
[rust-apple-spec]: https://github.com/rust-lang/rust/blob/fd815a5091eb4d49cd317f8ad272f17b7a5f550d/compiler/rustc_target/src/spec/apple_base.rs
39+
- macOS: `MACOSX_DEPLOYMENT_TARGET`, default `10.12`, `11.0` on Aarch64.
40+
- iOS / iPadOS: `IPHONEOS_DEPLOYMENT_TARGET`, default `10.0`.
41+
- tvOS: `TVOS_DEPLOYMENT_TARGET`, default `10.0`.
42+
- watchOS: `WATCHOS_DEPLOYMENT_TARGET`, default `5.0`.
43+
44+
The default (and minimum) versions are the [same as those Rust itself has][rust-apple-spec].
45+
46+
[rust-apple-spec]: https://github.com/rust-lang/rust/blob/1.74.0/compiler/rustc_target/src/spec/apple_base.rs
5547

5648

5749
### GNUStep's [`libobjc2`](https://github.com/gnustep/libobjc2)

crates/objc-sys/build.rs

Lines changed: 26 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,13 @@
11
use std::{env, path::Path};
22

3-
/// TODO: Better validation of this
4-
///
5-
/// The version is used for providing different behaviour when:
6-
/// - CGException.cpp getObjCPersonality (GNUStep >= 1.7)
7-
/// - Clang.cpp Clang::AddObjCRuntimeArgs (GNUStep >= 2.0)
8-
/// - isLegacyDispatchDefaultForArch (macOS < 10.6, GNUStep < 1.6)
9-
/// - hasNativeARC (macOS < 10.7, iOS < 5)
10-
/// - shouldUseARCFunctionsForRetainRelease (macOS < 10.10, iOS < 8)
11-
/// - shouldUseRuntimeFunctionsForAlloc (macOS < 10.10, iOS < 8)
12-
/// - shouldUseRuntimeFunctionForCombinedAllocInit (macOS >= 10.14.4, iOS >= 12.2, watchOS >= 5.2)
13-
/// - hasOptimizedSetter (macOS >= 10.8, iOS >= 6, GNUStep >= 1.7)
14-
/// - hasSubscripting (macOS < 10.11, iOS < 9)
15-
/// - hasTerminate (macOS < 10.8, iOS < 5)
16-
/// - hasARCUnsafeClaimAutoreleasedReturnValue (macOS >= 10.11, iOS >= 9, watchOS >= 2)
17-
/// - hasEmptyCollections (macOS >= 10.11, iOS >= 9, watchOS >= 2)
18-
/// - ... (incomplete)
19-
///
20-
/// `macosx-fragile` and `gcc` was not considered in this analysis, made on
21-
/// clang version 13's source code:
22-
/// https://github.com/llvm/llvm-project/blob/llvmorg-13.0.0/clang/include/clang/Basic/ObjCRuntime.h
23-
///
24-
/// In short, it's not ultra important, but enables some optimizations if this
25-
/// is specified.
26-
type Version = String;
27-
28-
// For clang "-fobjc-runtime" support
29-
#[allow(clippy::upper_case_acronyms)]
30-
enum AppleRuntime {
31-
MacOS(Version),
32-
IOS(Version),
33-
TvOS(Version),
34-
WatchOS(Version),
35-
Unknown,
36-
// BridgeOS,
37-
}
38-
use AppleRuntime::*;
39-
3+
/// The selected runtime (and runtime version).
404
enum Runtime {
41-
Apple(AppleRuntime),
5+
Apple,
426
GNUStep(u8, u8),
437
WinObjC,
448
#[allow(dead_code)]
459
ObjFW(Option<String>),
4610
}
47-
use Runtime::*;
48-
49-
fn get_env(env: &str) -> Option<String> {
50-
println!("cargo:rerun-if-env-changed={env}");
51-
match env::var(env) {
52-
Ok(var) => Some(var),
53-
Err(env::VarError::NotPresent) => None,
54-
Err(env::VarError::NotUnicode(var)) => panic!("Invalid unicode for {env}: {var:?}"),
55-
}
56-
}
5711

5812
fn main() {
5913
// The script doesn't depend on our code
@@ -102,39 +56,28 @@ fn main() {
10256

10357
let runtime = match (apple, gnustep, objfw) {
10458
// Same logic as in https://github.com/rust-lang/rust/blob/1.63.0/compiler/rustc_target/src/spec/apple_base.rs
105-
(true, false, false) => Apple(match &*target_os {
106-
"macos" if target_arch == "aarch64" => {
107-
MacOS(get_env("MACOSX_DEPLOYMENT_TARGET").unwrap_or_else(|| "11.0".into()))
108-
}
109-
"macos" => MacOS(get_env("MACOSX_DEPLOYMENT_TARGET").unwrap_or_else(|| "10.7".into())),
110-
"ios" => IOS(get_env("IPHONEOS_DEPLOYMENT_TARGET").unwrap_or_else(|| "7.0".into())),
111-
"tvos" => TvOS(get_env("TVOS_DEPLOYMENT_TARGET").unwrap_or_else(|| "7.0".into())),
112-
"watchos" => {
113-
WatchOS(get_env("WATCHOS_DEPLOYMENT_TARGET").unwrap_or_else(|| "5.0".into()))
114-
}
115-
_ => Unknown,
116-
}),
59+
(true, false, false) => Runtime::Apple,
11760
(false, true, false) => {
11861
// Choose defaults when generating docs
11962
if cfg!(feature = "unstable-docsrs") {
12063
if "windows" == target_os {
121-
WinObjC
64+
Runtime::WinObjC
12265
} else {
123-
GNUStep(1, 7)
66+
Runtime::GNUStep(1, 7)
12467
}
12568
} else if env::var_os("CARGO_FEATURE_UNSTABLE_WINOBJC").is_some() {
126-
WinObjC
69+
Runtime::WinObjC
12770
} else if env::var_os("CARGO_FEATURE_GNUSTEP_2_1").is_some() {
128-
GNUStep(2, 1)
71+
Runtime::GNUStep(2, 1)
12972
} else if env::var_os("CARGO_FEATURE_GNUSTEP_2_0").is_some() {
130-
GNUStep(2, 0)
73+
Runtime::GNUStep(2, 0)
13174
} else if env::var_os("CARGO_FEATURE_GNUSTEP_1_9").is_some() {
132-
GNUStep(1, 9)
75+
Runtime::GNUStep(1, 9)
13376
} else if env::var_os("CARGO_FEATURE_GNUSTEP_1_8").is_some() {
134-
GNUStep(1, 8)
77+
Runtime::GNUStep(1, 8)
13578
} else {
13679
// CARGO_FEATURE_GNUSTEP_1_7
137-
GNUStep(1, 7)
80+
Runtime::GNUStep(1, 7)
13881
}
13982
}
14083
(false, false, true) => {
@@ -148,50 +91,37 @@ fn main() {
14891

14992
// Add `#[cfg(RUNTIME)]` directive
15093
let runtime_cfg = match runtime {
151-
Apple(_) => "apple",
94+
Runtime::Apple => "apple",
15295
// WinObjC can be treated like GNUStep 1.8
153-
GNUStep(_, _) | WinObjC => "gnustep",
154-
ObjFW(_) => "objfw",
96+
Runtime::GNUStep(_, _) | Runtime::WinObjC => "gnustep",
97+
Runtime::ObjFW(_) => "objfw",
15598
};
15699
println!("cargo:rustc-cfg={runtime_cfg}");
157100

158-
if let Apple(runtime) = &runtime {
101+
if let Runtime::Apple = &runtime {
159102
// A few things are defined differently depending on the __OBJC2__
160103
// variable, which is set for all platforms except 32-bit macOS.
161-
if let (MacOS(_), "x86") = (runtime, &*target_arch) {
104+
if target_os == "macos" && target_arch == "x86" {
162105
println!("cargo:rustc-cfg=apple_old");
163106
} else {
164107
println!("cargo:rustc-cfg=apple_new");
165108
}
166109
}
167110

168-
let clang_runtime = match &runtime {
169-
Apple(runtime) => {
170-
match (runtime, &*target_arch) {
171-
// The fragile runtime is expected on i686-apple-darwin, see:
172-
// https://github.com/llvm/llvm-project/blob/release/13.x/clang/lib/Driver/ToolChains/Darwin.h#L228-L231
173-
// https://github.com/llvm/llvm-project/blob/release/13.x/clang/lib/Driver/ToolChains/Clang.cpp#L3639-L3640
174-
// https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtVersionsPlatforms.html
175-
(MacOS(version), "x86") => format!("macosx-fragile-{version}"),
176-
(MacOS(version), _) => format!("macosx-{version}"),
177-
(IOS(version), _) => format!("ios-{version}"),
178-
(WatchOS(version), _) => format!("watchos-{version}"),
179-
// tvOS doesn't have its own -fobjc-runtime string
180-
(TvOS(version), _) => format!("ios-{version}"),
181-
// Choose a sensible default for other platforms that
182-
// specified `apple`; this is likely not going to work anyhow
183-
(Unknown, _) => "macosx".into(),
184-
}
185-
}
111+
let clang_objc_runtime = match &runtime {
112+
// Default to `clang`'s own heuristics.
113+
//
114+
// Note that the `cc` crate forwards the correct deployment target to clang as well.
115+
Runtime::Apple => "".into(),
186116
// Default in clang is 1.6
187117
// GNUStep's own default is 1.8
188-
GNUStep(major, minor) => format!("gnustep-{major}.{minor}"),
118+
Runtime::GNUStep(major, minor) => format!(" -fobjc-runtime=gnustep-{major}.{minor}"),
189119
// WinObjC's libobjc2 is a fork of gnustep's from version 1.8
190-
WinObjC => "gnustep-1.8".into(),
191-
ObjFW(version) => {
120+
Runtime::WinObjC => " -fobjc-runtime=gnustep-1.8".into(),
121+
Runtime::ObjFW(version) => {
192122
// Default in clang
193123
let version = version.as_deref().unwrap_or("0.8");
194-
format!("objfw-{version}")
124+
format!(" -fobjc-runtime=objfw-{version}")
195125
}
196126
};
197127

@@ -204,14 +134,8 @@ fn main() {
204134
// Assume the compiler is clang; if it isn't, this is probably going to
205135
// fail anyways, since we're using newer runtimes than GCC supports.
206136
//
207-
// TODO: Should add we these, or is it someone else's responsibility?
208-
// - `-mios-simulator-version-min={}`
209-
// - `-miphoneos-version-min={}`
210-
// - `-mmacosx-version-min={}`
211-
// - ...
212-
//
213137
// TODO: -fobjc-weak ?
214-
let mut cc_args = format!("-fobjc-exceptions -fobjc-runtime={clang_runtime}");
138+
let mut cc_args = format!("-fobjc-exceptions{clang_objc_runtime}");
215139

216140
if let Runtime::ObjFW(_) = &runtime {
217141
// Add compability headers to make `#include <objc/objc.h>` work.

crates/objc2-encode/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ targets = [
3737
# iOS
3838
"aarch64-apple-ios",
3939
"x86_64-apple-ios",
40-
# "armv7-apple-ios",
4140
# "i386-apple-ios",
4241
# GNUStep
4342
"x86_64-unknown-linux-gnu",

crates/objc2/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ targets = [
125125
# iOS
126126
"aarch64-apple-ios",
127127
"x86_64-apple-ios",
128-
# "armv7-apple-ios",
129128
# "i386-apple-ios",
130129
# GNUStep
131130
"x86_64-unknown-linux-gnu",

crates/test-assembly/crates/test_autorelease_return/expected/apple-armv7.s

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)