diff options
| author | Mads Marquart <mads@marquart.dk> | 2025-03-01 03:10:05 +0100 |
|---|---|---|
| committer | Mads Marquart <mads@marquart.dk> | 2025-08-08 13:29:46 +0200 |
| commit | d434cae18f92d8a5ef8996fb579e2c11efbaa2cb (patch) | |
| tree | da703904dd9303338262092b848e2d122b0e4d42 /src/doc/rustc | |
| parent | 2886b36df4a646dd8d82fb65bf0c9d8d96c1f71a (diff) | |
| download | rust-d434cae18f92d8a5ef8996fb579e2c11efbaa2cb.tar.gz rust-d434cae18f92d8a5ef8996fb579e2c11efbaa2cb.zip | |
Add target_env = "macabi" and target_env = "sim"
Diffstat (limited to 'src/doc/rustc')
| -rw-r--r-- | src/doc/rustc/src/platform-support/apple-ios-macabi.md | 11 | ||||
| -rw-r--r-- | src/doc/rustc/src/platform-support/apple-ios.md | 14 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/doc/rustc/src/platform-support/apple-ios-macabi.md b/src/doc/rustc/src/platform-support/apple-ios-macabi.md index d4b71dbd4f4..c6f68f7a1e8 100644 --- a/src/doc/rustc/src/platform-support/apple-ios-macabi.md +++ b/src/doc/rustc/src/platform-support/apple-ios-macabi.md @@ -56,6 +56,17 @@ Rust programs can be built for these targets by specifying `--target`, if $ rustc --target aarch64-apple-ios-macabi your-code.rs ``` +The target can be differentiated from the iOS targets with the +`target_env = "macabi"` cfg (or `target_abi = "macabi"` before Rust CURRENT_RUSTC_VERSION). + +```rust +if cfg!(target_env = "macabi") { + // Do something only on Mac Catalyst. +} +``` + +This is similar to the `TARGET_OS_MACCATALYST` define in C code. + ## Testing Mac Catalyst binaries can be run directly on macOS 10.15 Catalina or newer. diff --git a/src/doc/rustc/src/platform-support/apple-ios.md b/src/doc/rustc/src/platform-support/apple-ios.md index 64325554ab6..586afa65226 100644 --- a/src/doc/rustc/src/platform-support/apple-ios.md +++ b/src/doc/rustc/src/platform-support/apple-ios.md @@ -66,6 +66,20 @@ Rust programs can be built for these targets by specifying `--target`, if $ rustc --target aarch64-apple-ios your-code.rs ``` +The simulator variants can be differentiated from the variants running +on-device with the `target_env = "sim"` cfg (or `target_abi = "sim"` before +Rust CURRENT_RUSTC_VERSION). + +```rust +if cfg!(all(target_vendor = "apple", target_env = "sim")) { + // Do something on the iOS/tvOS/visionOS/watchOS Simulator. +} { + // Everything else, like Windows and non-Simulator iOS. +} +``` + +This is similar to the `TARGET_OS_SIMULATOR` define in C code. + ## Testing There is no support for running the Rust or standard library testsuite at the |
