macOS-only Toolchain


I’m wondering if it’s possible to build a custom Swift toolchain for just macOS. I’m trying to create a minimal toolchain for use with Xcode Playgrounds and want to disable other SDKs (iOS, tvOS, watchOS).

Does it make sense to create a macOS-only toolchain? Is there a standard way to do this using utils/build-toolchain or related scripts? Currently, I’m commenting out flags for other SDKs in build-presets.ini and running build-toolchain.

Yes, you can certainly do this by creating a preset that only builds the macOS libraries and overlays. In theory one could slim down further if you’re willing to hack out code more aggressively to, e.g., remove the ARM backends… but that would only affect the binary size of the compiler.

I see, thanks!

I see that build-toolchain uses the buildbot_osx_package overlay, which in turn uses the mixin_osx_package_base overlay. I tried commenting out ios/tvos/watchos there but encountered an issue when building overlays:

CMake Error at stdlib/public/SDK/Accelerate/cmake_install.cmake:55 (file):
  file INSTALL cannot find
Call Stack (most recent call first):
  stdlib/public/SDK/cmake_install.cmake:37 (include)
  stdlib/public/cmake_install.cmake:45 (include)
  stdlib/cmake_install.cmake:37 (include)
  cmake_install.cmake:41 (include)

I see that Accelerate/CMakeLists.txt lists many TARGET_SDKS in addition to OSX - could that perhaps be the source of the problem? I thought that removing the SDK flags in build_presets.ini would propagate through the build.

@dan-zheng After you commented out the iOS/tvOS/watchOS, did you do a clean build? Also, can you provide the full command the preset expanded to.