We already introduced you to our new Silicon compiler in a previous blog post. This new compiler will be used to build Silicon native applications and will be available only in project mode.
Intel native applications (on Windows and Mac) will continue to use the classic compiler.
Let’s dig deeper and see exactly how it works.
The 4D Silicon compiler is special: It’s a 2-step compiler.
First, it translates 4D code into C++ source files. And then it compiles the C++ code using Clang, a state-of-the-art open-source compiler on Mac.
This approach has a lot of advantages:
– Optimized: The resulting application is compiled using the best optimizations, as fast as pure C++ code.
– Up to date: Apple gives only scarce information about their processors, so we have to use their compilers to get native Silicon applications. This limitation is also an advantage, as with every new processor will come a new version of Clang. As such, your applications will benefit from the latest improvements and stay compatible with any new generation of Silicon machines.
What’s changed?
This new approach comes with a few changes.
First, you now have the option to compile for Silicon and/or Intel processors. In the Compiler tab of the Application Settings, there’s a new parameter called Compilation Target.
You can set it to your processor (Silicon on Silicon Mac, Intel otherwise) or all processors (Silicon and Intel). As a side note, you can compile for Silicon on any Mac (Intel or Silicon) but not on a Windows machine:
To compile for Silicon, you will need Clang. Clang comes with the latest version of XCode. If you don’t have it, 4D will guide you to the AppStore to install XCode.
Incremental compilation
The Silicon compiler uses incremental compilation. It means that the first time you compile an application, or just after clearing the compiled code, the compilation time will be significantly longer as 4D will compile everything. But subsequent compilations will only compile the files you have changed and as such should be roughly as fast as usual.
Once the compilation is over, you will see a new directory in your package folder called Libraries. Inside, the system library lib4d-arm64.dylib will contain your application compiled code.
That’s it. Just restart in compiled mode and you can use your application natively on Silicon.
If you have comments or questions, come ask us on the 4D forum.
Happy compilation!