Cross-compiling to armv7 linux from x86_64 linux

I'd like to cross compile a program for armv7 linux.

To be clear I do not want to cross-compile the compiler, I just want to cross compile a piece of code. Is this currently possible? Could someone please point me to directions about how to do it? I've been experimenting with trying to do it from Swift 4.2.1, but I'd be open to trying it with a different version.


Yeah this is possible as long as you have both the standard library for the target built and installed as well as have a sysroot for the underlying system. Unfortunately, doing this with the current build-script is not particularly easy as it does not allow for you to easily build just the standard library for the target.

I don't know if anyone is currently shipping a Linux hosted toolchain that can target Linux armv7. I have done that in the past for myself though. If you don't mind building up the various pieces, you can probably use some of my existing work to setup such an environment. You will want to take a look at my build infrastructure. You should be able to modify the cache file to build the arm variant instead of x86_64 for Linux (take a look at cmake/cache/swift-stdlib-linux.cmake).

I do have an attempt to perform multiple simultaneous builds for the standard library that needs a little bit of work still. Feel free to take a look at that if you like; that should allow you to cross-compile the arm standard library with build script as well.

1 Like

It appears that cmake/cache/swift-stdlib-linux.cmake is currently an empty file. Do you have another variation you haven't committed and pushed yet? Thanks

Oops, I did have a variation of it, but it did depend on my linux distribution. I would suggest taking a look at the windows one as a starting point. You will need to add a couple of other variables, primarily the CMAKE_C_FLAGS and CMAKE_CXX_FLAGS will need to be adjusted to get the path to the sysroot.