about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2020-07-02 00:16:40 -0700
committerGitHub <noreply@github.com>2020-07-02 00:16:40 -0700
commit061f1c6863f837e5cc11abe98243a93fa866c273 (patch)
tree81bcae7b3f987055816889e144c4a866aa0b4e44 /src
parent4593e9f49fad904541fddaefd1719869a7573831 (diff)
parent67b162f043e7e52e71b7ae8bbbdb0a732ec85eb1 (diff)
Rollup merge of #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)
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/native.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
index 106db90b2d0..cceb7941650 100644
--- a/src/bootstrap/native.rs
+++ b/src/bootstrap/native.rs
@@ -175,6 +175,17 @@ impl Step for Llvm {
             cfg.define("LLVM_ENABLE_ZLIB", "OFF");
         }
 
+        // Are we compiling for iOS/tvOS?
+        if target.contains("apple-ios") || target.contains("apple-tvos") {
+            // These two defines prevent CMake from automatically trying to add a MacOSX sysroot, which leads to a compiler error.
+            cfg.define("CMAKE_OSX_SYSROOT", "/");
+            cfg.define("CMAKE_OSX_DEPLOYMENT_TARGET", "");
+            // Prevent cmake from adding -bundle to CFLAGS automatically, which leads to a compiler error because "-bitcode_bundle" also gets added.
+            cfg.define("LLVM_ENABLE_PLUGINS", "OFF");
+            // Zlib fails to link properly, leading to a compiler error.
+            cfg.define("LLVM_ENABLE_ZLIB", "OFF");
+        }
+
         if builder.config.llvm_thin_lto {
             cfg.define("LLVM_ENABLE_LTO", "Thin");
             if !target.contains("apple") {
@@ -412,6 +423,14 @@ fn configure_cmake(
     if let Some(ref s) = builder.config.llvm_cflags {
         cflags.push_str(&format!(" {}", s));
     }
+    // Some compiler features used by LLVM (such as thread locals) will not work on a min version below iOS 10.
+    if target.contains("apple-ios") {
+        if target.contains("86-") {
+            cflags.push_str(" -miphonesimulator-version-min=10.0");
+        } else {
+            cflags.push_str(" -miphoneos-version-min=10.0");
+        }
+    }
     cfg.define("CMAKE_C_FLAGS", cflags);
     let mut cxxflags = builder.cflags(target, GitRepo::Llvm).join(" ");
     if builder.config.llvm_static_stdcpp && !target.contains("msvc") && !target.contains("netbsd") {