Can't build Swift on Catalina 10.15.2

Hey!

I am currently trying to build Swift using the instructions provided on https://github.com/apple/swift. Before I build Swift I activate my anaconda environment to be able to use python2 for the scripts.

conda activate py2

When I then run ./utils/build-script --release-debuginfo I get the following output:

(py2) MacBook-Pro:swift lh$ ./utils/build-script --release-debuginfo

./utils/build-script: note: Using toolchain default

  • mkdir -p /Users/lh/swift-source/build/Ninja-RelWithDebInfoAssert

Building the standard library for: swift-test-stdlib-macosx-x86_64

  • /usr/local/bin/cmake --build /Users/lh/swift-source/build/Ninja-RelWithDebInfoAssert/cmark-macosx-x86_64 -- -j8 all

ninja: no work to do.

symlinking the system headers (/Library/Developer/CommandLineTools/usr/bin/../../usr/include/c++) into the local clang build directory (/Users/lh/swift-source/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/include).

  • ln -s -f /Library/Developer/CommandLineTools/usr/bin/../../usr/include/c++ /Users/lh/swift-source/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/include

  • /usr/local/bin/cmake --build /Users/lh/swift-source/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64 -- -j8 all

[0/5][ 0%][0.000s] Performing configure step for 'compiler-rt'

-- Found libtool - /Library/Developer/CommandLineTools/usr/bin/libtool

-- Checking DARWIN_iphonesimulator_SYSROOT - ''

-- Checking DARWIN_iphoneos_SYSROOT - ''

-- Checking DARWIN_watchsimulator_SYSROOT - ''

-- Checking DARWIN_watchos_SYSROOT - ''

-- Checking DARWIN_appletvsimulator_SYSROOT - ''

-- Checking DARWIN_appletvos_SYSROOT - ''

-- Got ld supported ARCHES: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em

-- Toolchain supported arches: armv6;armv7;armv7s;arm64;arm64e;arm64_32;i386;x86_64;x86_64h;armv6m;armv7k;armv7m;armv7em

-- Finding valid architectures for osx...

CMake Error at cmake/Modules/CompilerRTDarwinUtils.cmake:67 (message):

Failed to determine SDK version for "macosx" SDK

Call Stack (most recent call first):

cmake/Modules/CompilerRTDarwinUtils.cmake:124 (find_darwin_sdk_version)

cmake/config-ix.cmake:395 (darwin_test_archs)

CMakeLists.txt:235 (include)

-- Configuring incomplete, errors occurred!

See also "/Users/lh/swift-source/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/tools/clang/runtime/compiler-rt-bins/CMakeFiles/CMakeOutput.log".

See also "/Users/lh/swift-source/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/tools/clang/runtime/compiler-rt-bins/CMakeFiles/CMakeError.log".

FAILED: tools/clang/runtime/compiler-rt-stamps/compiler-rt-configure

cd /Users/lh/swift-source/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/tools/clang/runtime/compiler-rt-bins && /usr/local/Cellar/cmake/3.15.5/bin/cmake -DCMAKE_C_COMPILER=/Users/lh/swift-source/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/./bin/clang -DCMAKE_CXX_COMPILER=/Users/lh/swift-source/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/./bin/clang++ -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_MAKE_PROGRAM=/usr/local/bin/ninja -DLLVM_CONFIG_PATH=/Users/lh/swift-source/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/./bin/llvm-config "-DLLVM_LIT_ARGS=-sv -j 8" -DCOMPILER_RT_OUTPUT_DIR=/Users/lh/swift-source/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/./lib/clang/7.0.0 -DCOMPILER_RT_EXEC_OUTPUT_DIR=/Users/lh/swift-source/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/./bin -DCOMPILER_RT_INSTALL_PATH:STRING=lib/clang/7.0.0 -DCOMPILER_RT_INCLUDE_TESTS=ON -DCMAKE_INSTALL_PREFIX=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr -DLLVM_LIBDIR_SUFFIX= -DLLVM_RUNTIME_OUTPUT_INTDIR=/Users/lh/swift-source/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/./bin -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 -DCMAKE_OSX_SYSROOT:PATH=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -DCOMPILER_RT_ENABLE_IOS=FALSE -DCOMPILER_RT_ENABLE_TVOS=FALSE -DCOMPILER_RT_ENABLE_WATCHOS=FALSE -DCOMPILER_RT_INTERCEPT_LIBDISPATCH=ON -DCOMPILER_RT_PREFIX=/Users/lh/swift-source/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/projects/compiler-rt -DCOMPILER_RT_SRC_ROOT=/Users/lh/swift-source/llvm-project/llvm/../compiler-rt -GNinja /Users/lh/swift-source/llvm-project/llvm/../compiler-rt && /usr/local/Cellar/cmake/3.15.5/bin/cmake -E touch /Users/lh/swift-source/build/Ninja-RelWithDebInfoAssert/llvm-macosx-x86_64/tools/clang/runtime/compiler-rt-stamps//compiler-rt-configure

ninja: build stopped: subcommand failed.

./utils/build-script: fatal error: command terminated with a non-zero exit status 1, aborting

Does anyone know what the problem might be?

Have you checked the CMakeOutput.log and CMakeError.log mentioned in the output?

This error message is from the find_darwin_sdk_version function.

On swift/master and swift/swift-5.2-branch, it is running:

xcodebuild -version -sdk macosx SDKVersion

On swift/master-next, with commit 52beec7, it is running:

xcrun --sdk macosx --show-sdk-version

You could try running the above commands manually. If the first one fails, you might need to install Xcode, or switch from CommandLineTools to Xcode using one of the following:

xcode-select --switch /Applications/Xcode.app/Contents/Developer
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer

And then add the --reconfigure flag as another argument to swift/utils/build-script.