Skip to content

Commit d3710cd

Browse files
shoumikhinmergennachin
authored andcommitted
Update the runtime build doc. (#973)
Summary: Pull Request resolved: #973 . Reviewed By: mergennachin, dbort Differential Revision: D50346219 fbshipit-source-id: af5309c1c8a257f060e0ddf11f10cfc30277dd6f
1 parent 4bc3833 commit d3710cd

File tree

1 file changed

+24
-45
lines changed

1 file changed

+24
-45
lines changed

docs/source/runtime-build-and-cross-compilation.md

Lines changed: 24 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
Although buck2 is the main build system for the ExecuTorch project, it's also
44
possible to build core pieces of the runtime using [CMake](https://cmake.org/)
55
for easier integration with other build systems. Even if you don't use CMake
6-
directly, CMake can emit scripts for other format like Make or Ninja. For information, see
7-
[cmake-generators(7)](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html).
6+
directly, CMake can emit scripts for other format like Make, Ninja or Xcode.
7+
For information, see [cmake-generators(7)](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html).
88

99
## Targets Built by the CMake Build System
1010

@@ -31,7 +31,7 @@ useful to embedded systems users.
3131

3232
Follow the steps below to have the tools ready before using CMake to build on your machine.
3333

34-
1. Clone the repo and install buck2 as described in the "Runtime Setup" section
34+
1. Clone the repo and install buck2 as described in the "Building a Runtime" section
3535
of [Setting Up ExecuTorch](getting-started-setup.md#building-a-runtime)
3636
- `buck2` is necessary because the CMake build system runs `buck2` commands
3737
to extract source lists from the primary build system. It will be possible
@@ -40,10 +40,10 @@ Follow the steps below to have the tools ready before using CMake to build on yo
4040
- Run `pip install tomli`
4141
- This provides an import required by a script that the CMake build system
4242
calls to extract source lists from `buck2`. Consider doing this `pip
43-
install` inside your conda environment if you created one during ExecuTorch setup. see [Setting up
44-
ExecuTorch](getting-started-setup.md).
45-
3. Install CMake version 3.19 or later
46-
- conda install cmake
43+
install` inside your Python or Conda virtual environment if you created
44+
one already by following [Setting up ExecuTorch](getting-started-setup.md#setting-up-executorch).
45+
3. Install CMake version 3.19 or later:
46+
- Run `conda install cmake` or `pip install cmake`.
4747

4848

4949
## Configure the CMake Build
@@ -140,52 +140,31 @@ adb shell "/data/local/tmp/executorch/executor_runner --model_path /data/local/
140140
```
141141

142142
### iOS
143-
```{note}
144-
While we're working on making it a smoother experience, here is an early workflow to try out cross compilation for iOS.
145-
```
146-
Only supported in macOS:
147-
148-
Prerequisites:
149-
- [XCode](https://developer.apple.com/xcode/)
150-
151-
After XCode is installed,
152-
153-
1. Get the iOS cmake toolchain by using one of the following options:
154-
- Option 1 [recommended] : use the `ios.toolchain.cmake` from the following github repo:
155-
156-
```bash
157-
git clone https://github.com/leetal/ios-cmake.git
158-
```
159143

160-
- Option2 [wip], use the `iOS.cmake` from PyTorch, the
161-
toolchain is located in `executorch/third-party/pytorch/pytorch/blob/main/cmake/iOS.cmake`
144+
For iOS we'll build [frameworks](https://developer.apple.com/documentation/xcode/creating-a-multi-platform-binary-framework-bundle) instead of static libraries, that will also contain the public headers inside.
162145

146+
1. Install Xcode from the
147+
[Mac App Store](https://apps.apple.com/app/xcode/id497799835) and then install
148+
the Command Line Tools using the terminal:
163149

164-
2. Use the tool chain provided in the repro to build the ExecuTorch library.
165-
```bash
166-
rm -rf cmake-ios-out && mkdir cmake-ios-out && cd cmake-ios-out
167-
168-
# change the platform accordingly, please refer to the table listed in Readme
169-
cmake . -G Xcode -DCMAKE_TOOLCHAIN_FILE=~/ios-cmake/ios.toolchain.cmake -DPLATFORM=SIMULATOR
150+
```bash
151+
xcode-select --install
152+
```
170153

171-
# Create an include folder in cmake-ios-out to include all header files
172-
mkdir include
173-
cp -r ../runtime include
174-
cp -r ../extension include
175-
cp -r ../utils include
176-
```
154+
2. Build the frameworks:
177155

156+
```bash
157+
./build/build_apple_frameworks.sh
158+
```
178159

179-
3. XCode setup
160+
Run the above command with `--help` flag to learn more on how to build additional backends
161+
(like [Core ML](build-run-coreml.md), [MPS](build-run-mps.md) or XNNPACK), etc.
162+
Note, some backends may require additional dependencies and certain versions of Xcode and iOS.
180163

181-
If using the iOS cmake tool chain from `https://github.com/leetal/ios-cmake.git`, after build is complete, perform the following steps:
164+
3. Copy over the generated `.xcframework` bundles to your Xcode project, link them against
165+
your targets and don't forget to add an extra linker flag `-all_load`.
182166

183-
1. Open the project in XCode, drag the `executorch.xcodeproj` generated from Step 2 to `Frameworks`.
184-
1. Go to project Target’s `Build Phases` - `Link Binaries With Libraries`, click the **+** sign and add all the library files located in `cmake-ios-out/build`.
185-
1. Navigate to the project `Build Settings`:
186-
- Set the value **Header Search Paths** to `cmake-ios-out/include`.
187-
- Set **Library Search Paths** to `cmake-ios-out/build`.
188-
- In **other linker flags**, add a custom linker flag `-all_load.`
167+
Check out the [iOS Demo App](demo-apps-ios.md) tutorial for more info.
189168

190169

191170
## Next steps

0 commit comments

Comments
 (0)