Starting in 2019.4, we introduced IL2CPP support for Linux, which allows developers that build on Linux to gain the performance and scalability benefits of IL2CPP compilation rather than having to rely on Mono. However, this support relied upon building from the Linux editor and it relied upon a developer configuring their own C++ toolchain. That means that it was not suitable for developers that were building for Linux but were not using the Linux editor. It also was challenging for developers to set up a compilation toolchain that was compatible with Unityâs.
Because Linux is a diverse ecosystem with a wide variety of environments and distributions, we wanted to provide developers with a way to guarantee a consistent runtime no matter which supported Unity platform they chose to build from. To help address this, weâve created a new package that contains our own verified sysroot. While you can still choose to leverage your own systemâs sysroot if you so choose, building against ours will ensure a consistent, compatible end result on all supported Linux distributions.
In addition to our sysroot package we have supplied a toolchain package that provides a standard toolchain (compiler, linker and related tools) to build the player. This split of the sysroot and toolchain allows us to support cross-compilation of Linux players. With the appropriate toolchain package for the host platform (Editor) and target platform (Player), we can support building of Linux targets (players) on macOS and Windows hosts.
Our goal with these features is to provide you with a versatile set of plug-and-play solutions that you can pick and choose from to fit your own unique needs, whether thatâs using your local machine to build for Linux or whether youâre building target binaries for your Linux servers. We want developers to be able to build and deploy as quickly as possible without having to worry about unnecessary complexities getting it to run. This will ultimately reduce their iteration times and let them get back to whatâs really important: shipping amazing products.
Package Installation
To make using these packages as simple to use as possible, we have created a series of platform-specific toolchain packages that include the necessary build tools and load the sysroot package as a dependency. You simply add the appropriate toolchain package based on the host platform/architecture and target platform/architecture:
- Linux: com.unity.toolchain.linux-x86_64@0.1.13-preview
- macOS: com.unity.toolchain.macos-x86_64-linux-x86_64@0.1.15-preview
- Windows: com.unity.toolchain.win-x86_64-linux-x86_64@0.1.14-preview
Note that the format of the name is host platform, host architecture, target platform, and target architecture. You can shorten the name if the host and the target are the same.
For the moment, these packages are not discoverable through the Package Manager UI search function. You can add them by clicking on the â+â in the Package Manager toolbar, selecting âAdd package from git URLâ, and then typing the name of the package as listed in the table above.
Once the package is installed, you are set to build on Linux.
To build on macOS or Windows, you will need the Linux-IL2CPP module to be installed. This module can be installed from the Hub. (Youâll need Hub 2.4.0 or newer.)
Set the ScriptingBackend in PlayerSettings / Other Settings / Configuration to IL2CPP, select the Linux target, and build.
The sysroot package and toolchain require approximately 164 MB on Linux and about 1.4GB on macOS and Windows. The bulk of the data is stored in the local application data directory as shown below:
- Linux: ~/.local/share/unity3d/cache/sysroots
- macOS: ~/Library/Unity/cache/sysroots
- Windows: %LocalApplicationData%\unity3d\cache\sysroots
If necessary, the uncompressed sysroot and toolchain can be relocated by setting the environment variable UNITY_SYSROOT_CACHE to another directory.
Requirements
In summary, these are the requirements to build Linux targets:
- Recent version of Editor: 2019.4.11f1, 2020.1.6f1, 2020.2.0b3
- Hub 2.4
- On macOS and Windows, Linux-IL2CPP module installed
- Correct toolchain for host platform installed
- ScriptingBackend set to IL2CPP
Known issues
On macOS there was an issue with early versions of the Linux-IL2CPP module being installed in the wrong directory, which results in the Linux build target not being found. To fix this, you will need to uninstall the editor and reinstall with the Linux-IL2CPP module. This will pick up the fixed version of the module.
There is an issue with IL2CPP not handling paths with spaces in them. This will be fixed in a future release.
Feedback
Weâre looking for feedback on these new packages, so if you have any questions or want to share notes on your experience using them, please feel free to leave us a comment!