Skip to content

Commit

Permalink
Rollup merge of rust-lang#88072 - kit-981:feature/build-ios-toolchain…
Browse files Browse the repository at this point in the history
…-on-linux, r=Mark-Simulacrum

Allow the iOS toolchain to be built on Linux

The iOS toolchain can be built on Linux with minor changes. The compilation will invoke `xcrun` to find the path to the iPhone SDK but a fake `xcrun` executable can be used.

```
#!/bin/sh
echo "/path/to/sdk"
```

The iOS toolchain can then be built and linked with rustup.

```
$ ./x.py build --stage 2 --host x86_64-unknown-linux-gnu \
  	 --target aarch64-apple-ios
$ rustup toolchain link stage1 build/x86_64-unknown-linux-gnu/stage1
```

It's possible to take this toolchain and compile an iOS executable with it. This requires the ld64 linker and an iOS SDK. The ld64 linker can be taken from [cctools](https://github.com/tpoechtrager/cctools-port). A project's .cargo/config can then be edited to use the linker for this target.

```
[target.aarch64-apple-ios]
linker = "/path/to/cctools/bin/arm-apple-darwin-ld"
rustflags = [
    "-C",
    """
link-args=
    -F/path/to/sdk/System/Library/Frameworks
    -L/path/to/sdk/usr/lib
    -L/path/to/sdk/usr/lib/system/
    -adhoc_codesign
    """,
]
```
  • Loading branch information
camsteffen authored Aug 19, 2021
2 parents 6a81d56 + 79e402e commit 2c8afef
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions src/bootstrap/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,6 @@ pub fn check(build: &mut Build) {
}

for target in &build.targets {
// Can't compile for iOS unless we're on macOS
if target.contains("apple-ios") && !build.build.contains("apple-darwin") {
panic!("the iOS target is only supported on macOS");
}

build
.config
.target_config
Expand Down

0 comments on commit 2c8afef

Please sign in to comment.