Realtime threads with Swift

It took quite a bit of practice to get swift compiling for me. I’m using a Mac, which means it’s tied Tolbert tightly to your xcode version. I have an older laptop where the build works and I pretty much don’t touch it! My new M1 Mac mini I started to get it working but got stuck and it was too much effort. The readme on swift is more or less right but I think there are many cases where it doesn’t work.

One particular thing I think is nowhere near made clear enough, each branch and build of swift requires a specific version of Xcode to build. Some versions either side will work. But for example I would bet if you get the latest head release of swift from GitHub - apple/swift: The Swift Programming Language it will probably only build if you have the latest version of xcode from the store. And sometimes it even needs the latest xcode beta to build!

This should be much more clear.

To some extent it can bootstrap. So I know it’s sometimes capable of checking out and building ninja as a first step. But it seems unreliable to me.

See my webpage: https://www.swiftforarduino.com/openSource.php for some partial instructions and ideas but it’s not a proper set of instructions, more like ores and ideas.

The only way I’ve got it working is…
0) get Cmakeand set it up

  1. make a folder and open a terminal session in that folder
  2. checkout a branch of swift (eg Swift 5.3) into a sub folder
  3. using swift/utilise/update-checkout —clone —scheme X (see my page for examples)
  4. that should check out llvm, ninja, etc at the right versions needed next to your swift folder
  5. use Swift/Utils/build-script to control the build. I use -S so the build script creates all the build files for ninja but doesn’t do the build
  6. go into your build folder, Ninja si directory then go into each of cmake, llvm and lastly Swift and do a ninja in each. It takes an hour on my machine!