Skip to content

Commit 061f1c6

Browse files
authored
Rollup merge of rust-lang#73903 - luxxxxy:ios-rustc, r=nikomatsakis
Changes required for rustc/cargo to build for iOS targets cargo, rustc, clippy, rust-src, and rust-analysis successfully build for `aarch64-apple-ios` with these changes. NOTE: cargo required arm64-ios openssl/libcurl to be linked. ![image](https://user-images.githubusercontent.com/65794972/86178510-75d78080-baf6-11ea-9c17-b74bd6c85272.png) ![image](https://user-images.githubusercontent.com/65794972/86178525-7bcd6180-baf6-11ea-9974-f99980cbdb24.png)
2 parents 4593e9f + 67b162f commit 061f1c6

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/bootstrap/native.rs

+19
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,17 @@ impl Step for Llvm {
175175
cfg.define("LLVM_ENABLE_ZLIB", "OFF");
176176
}
177177

178+
// Are we compiling for iOS/tvOS?
179+
if target.contains("apple-ios") || target.contains("apple-tvos") {
180+
// These two defines prevent CMake from automatically trying to add a MacOSX sysroot, which leads to a compiler error.
181+
cfg.define("CMAKE_OSX_SYSROOT", "/");
182+
cfg.define("CMAKE_OSX_DEPLOYMENT_TARGET", "");
183+
// Prevent cmake from adding -bundle to CFLAGS automatically, which leads to a compiler error because "-bitcode_bundle" also gets added.
184+
cfg.define("LLVM_ENABLE_PLUGINS", "OFF");
185+
// Zlib fails to link properly, leading to a compiler error.
186+
cfg.define("LLVM_ENABLE_ZLIB", "OFF");
187+
}
188+
178189
if builder.config.llvm_thin_lto {
179190
cfg.define("LLVM_ENABLE_LTO", "Thin");
180191
if !target.contains("apple") {
@@ -412,6 +423,14 @@ fn configure_cmake(
412423
if let Some(ref s) = builder.config.llvm_cflags {
413424
cflags.push_str(&format!(" {}", s));
414425
}
426+
// Some compiler features used by LLVM (such as thread locals) will not work on a min version below iOS 10.
427+
if target.contains("apple-ios") {
428+
if target.contains("86-") {
429+
cflags.push_str(" -miphonesimulator-version-min=10.0");
430+
} else {
431+
cflags.push_str(" -miphoneos-version-min=10.0");
432+
}
433+
}
415434
cfg.define("CMAKE_C_FLAGS", cflags);
416435
let mut cxxflags = builder.cflags(target, GitRepo::Llvm).join(" ");
417436
if builder.config.llvm_static_stdcpp && !target.contains("msvc") && !target.contains("netbsd") {

0 commit comments

Comments
 (0)