How to compile Swift for Armv6k

Hi there!

I want to compile swift for armv6k cpu. I found that I can use LLVM IR to cross-compile swift, but also, some guy from swift forum said that IR isn't stable and I should use it on my own risk.

So, currently I tried to use this code:

	swiftc -emit-ir -parse-as-library -o app.ll app.swift
	clang -target arm-none-eabihf -ffreestanding -Wno-override-module -o app.o -c app.ll

and then I get this error

Error
swiftc -emit-ir -parse-as-library -I /Users/v.prusakov/Developer/project/modules /Users/v.prusakov/Developer/projectS/source/app -o app.ll
clang -target arm-none-eabihf -ffreestanding -Wno-override-module -o app.o -c app.ll
'penryn' is not a recognized processor for this target (ignoring processor)
'+cx16' is not a recognized feature for this target (ignoring feature)
'+cx8' is not a recognized feature for this target (ignoring feature)
'+fxsr' is not a recognized feature for this target (ignoring feature)
'+mmx' is not a recognized feature for this target (ignoring feature)
'+sahf' is not a recognized feature for this target (ignoring feature)
'+sse' is not a recognized feature for this target (ignoring feature)
'+sse2' is not a recognized feature for this target (ignoring feature)
'+sse3' is not a recognized feature for this target (ignoring feature)
'+sse4.1' is not a recognized feature for this target (ignoring feature)
'+ssse3' is not a recognized feature for this target (ignoring feature)
'+x87' is not a recognized feature for this target (ignoring feature)
'penryn' is not a recognized processor for this target (ignoring processor)
'penryn' is not a recognized processor for this target (ignoring processor)
'+cx16' is not a recognized feature for this target (ignoring feature)
'+cx8' is not a recognized feature for this target (ignoring feature)
'+fxsr' is not a recognized feature for this target (ignoring feature)
'+mmx' is not a recognized feature for this target (ignoring feature)
'+sahf' is not a recognized feature for this target (ignoring feature)
'+sse' is not a recognized feature for this target (ignoring feature)
'+sse2' is not a recognized feature for this target (ignoring feature)
'+sse3' is not a recognized feature for this target (ignoring feature)
'+sse4.1' is not a recognized feature for this target (ignoring feature)
'+ssse3' is not a recognized feature for this target (ignoring feature)
'+x87' is not a recognized feature for this target (ignoring feature)
'penryn' is not a recognized processor for this target (ignoring processor)
'penryn' is not a recognized processor for this target (ignoring processor)
'penryn' is not a recognized processor for this target (ignoring processor)
fatal error: error in backend: invalid llvm.linker.options
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Apple clang version 14.0.0 (clang-1400.0.29.102)
Target: arm-none-unknown-eabihf
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
clang: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.
make[1]: *** [main.o] Error 70
make: *** [build] Error 2

Any suggestion how to avoid LLVM IR and compile swift for specific arch?

1 Like

I have an Android CI that builds all Swift releases and dev snapshots for armv7, take a look at my scripts and doc for how to build Swift for a 32-bit platform. You may need to port Swift for your platform too, in which case you might find @andyliu's experience and changes for Zephyr to be useful.

3 Likes