Using a fast bare metal compiler?

I would really like to use swift for embedded programming, as I feel that this is a much better replacement for C ++. The processor I use is ARM Cortex-M4F ( http://www.ti.com/tool/ek-tm4c123gxl ). Looking at the quick compiler page , he says that you can generate LLVM IR from a quick source, and then I was hoping to cross-compile LLVM. Is it possible?

+7
arm swift llvm llvm-clang llvm-ir
source share
2 answers

You can definitely generate machine code using Swift. In fact, by default when compiling a Swift program in Xcode or using the swiftc command-line compiler, the executable file consists of machine code.

LLVM bytecode is generated at some point during the build process, but the final executable that is created is machine code. There are compiler options that allow you to create LLVM bytecode only if you want, but LLVM bytecode is usually not executed directly, for example, Java bytecode that is run by the Java runtime.

Regarding cross-compiling for ARM, I'm not sure how this works with the swiftc tool, but if you create an iOS Xcode project, it creates an ARM executable. I am sure that swiftc complier has all the features needed to create ARM executables.

However, one of the catch I can think of is that many Swift features depend on Apple frameworks. However, now that Swift has been opened, cleaner, faster libraries for all kinds of things are gradually appearing.

+3
source share

I studied this feature (using Swift for embedded applications). Since Swift requires runtime, after the static compilation of "Hello, World!" (on Ubuntu, x86-64 using the latest version of Swift 3.0.2) the binary size of the result was more than 5 megabytes, which can be a problem for "small" ARM controllers (for example, Cortex-M0).

0
source share

All Articles