Swift doesn't build on the Mac


(Eben Up) #1

Hi all,
Before I jump into using Swift on Linux I thought I'd do the experiment of compiling it on MacOS Mojave 10.14.2 (18C54) compiling with Xcode Version 10.1 (10B61). I always prefer to compile programs rather than download binaries.
At first things were going well but alas the build failed after perhaps a half hour.
Below's the trailing end of the output.
How to fix?
Thanks!

$ swift/utils/build-script -R
swift/utils/build-script: note: Using toolchain default

  • mkdir -p /Users/swiftly/Desktop/s/build/Ninja-ReleaseAssert
  • env HOST_VARIABLE_macosx_x86_64__SWIFT_BENCHMARK_TARGETS=swift-benchmark-macosx-x86_64 HOST_VARIABLE_macosx_x86_64__SWIFT_RUN_BENCHMARK_TARGETS= 'HOST_VARIABLE_macosx_x86_64__SWIFT_SDKS=IOS IOS_SIMULATOR OSX TVOS TVOS_SIMULATOR WATCHOS WATCHOS_SIMULATOR' HOST_VARIABLE_macosx_x86_64__SWIFT_STDLIB_TARGETS=swift-test-stdlib-macosx-x86_64 HOST_VARIABLE_macosx_x86_64__SWIFT_TEST_TARGETS= caffeinate /Users/swiftly/Desktop/s/swift/utils/build-script-impl --workspace /Users/swiftly/Desktop/s --build-dir /Users/swiftly/Desktop/s/build/Ninja-ReleaseAssert --install-prefix /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr --host-target macosx-x86_64 --stdlib-deployment-targets 'macosx-x86_64 iphonesimulator-i386 iphonesimulator-x86_64 appletvsimulator-x86_64 watchsimulator-i386 iphoneos-armv7 iphoneos-armv7s iphoneos-arm64 appletvos-arm64 watchos-armv7k' --host-cc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang --host-cxx /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ --darwin-xcrun-toolchain default --darwin-deployment-version-osx=10.9 --darwin-deployment-version-ios=7.0 --darwin-deployment-version-tvos=9.0 --darwin-deployment-version-watchos=2.0 --cmake /usr/local/bin/cmake --cmark-build-type Release --llvm-build-type Release --swift-build-type Release --swift-stdlib-build-type Release --lldb-build-type Release --lldb-build-with-xcode 1 --foundation-build-type Release --libdispatch-build-type Release --libicu-build-type Release --xctest-build-type Release --swiftpm-build-type Release --swiftsyntax-build-type Release --skstresstester-build-type Release --llbuild-build-type Release --swift-enable-assertions true --swift-stdlib-enable-assertions true --swift-analyze-code-coverage false --llbuild-enable-assertions true --lldb-assertions true --cmake-generator Ninja --build-jobs 4 '--common-cmake-options=-G Ninja -DCMAKE_C_COMPILER:PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -DCMAKE_CXX_COMPILER:PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -DCMAKE_LIBTOOL:PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -DLLVM_VERSION_MAJOR:STRING=7 -DLLVM_VERSION_MINOR:STRING=0 -DLLVM_VERSION_PATCH:STRING=0 -DCLANG_VERSION_MAJOR:STRING=7 -DCLANG_VERSION_MINOR:STRING=0 -DCLANG_VERSION_PATCH:STRING=0 -DCMAKE_MAKE_PROGRAM=/Users/swiftly/bin/ninja' --build-args=-j4 --cmark-cmake-options= '--llvm-cmake-options=-DLLVM_ENABLE_ASSERTIONS=TRUE -DLLVM_TARGETS_TO_BUILD=X86;ARM;AArch64;PowerPC;SystemZ;Mips' '--swift-cmake-options=-DSWIFT_STDLIB_ENABLE_SIL_OWNERSHIP=FALSE -DSWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS=TRUE -DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE -DSWIFT_FORCE_OPTIMIZED_TYPECHECKER=FALSE -DSWIFT_STDLIB_ENABLE_STDLIBCORE_EXCLUSIVITY_CHECKING=FALSE' --build-stdlib-deployment-targets all --ninja-bin=/Users/swiftly/bin/ninja --skip-build-foundation --skip-build-xctest --skip-build-lldb --skip-build-llbuild --skip-build-libdispatch --skip-build-libicu --skip-build-swiftpm --skip-build-swiftsyntax --skip-build-skstresstester --skip-build-playgroundsupport --build-swift-dynamic-stdlib --build-swift-dynamic-sdk-overlay --skip-build-ios-device --skip-build-ios-simulator --skip-build-tvos-device --skip-build-tvos-simulator --skip-build-watchos-device --skip-build-watchos-simulator --skip-build-android --skip-test-swift --skip-test-cmark --skip-test-lldb --skip-test-llbuild --skip-test-swiftpm --skip-test-swiftsyntax --skip-test-skstresstester --skip-test-xctest --skip-test-foundation --skip-test-libdispatch --skip-test-libicu --skip-test-playgroundsupport --skip-test-linux --skip-test-freebsd --skip-test-cygwin --skip-test-osx --skip-test-ios-host --skip-test-ios-simulator --skip-test-tvos-host --skip-test-tvos-simulator --skip-test-watchos-host --skip-test-watchos-simulator --skip-test-android-host --skip-test-benchmarks --skip-test-optimized --skip-test-optimize-for-size --android-deploy-device-path /data/local/tmp --toolchain-prefix /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain --host-lipo /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo --host-libtool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool --llvm-lit-args=-sv
    Building the standard library for: swift-test-stdlib-macosx-x86_64
  • /usr/local/bin/cmake --build /Users/swiftly/Desktop/s/build/Ninja-ReleaseAssert/cmark-macosx-x86_64 -- -j4 all
    ninja: no work to do.
    symlinking the system headers (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../../usr/include/c++) into the local clang build directory (/Users/swiftly/Desktop/s/build/Ninja-ReleaseAssert/llvm-macosx-x86_64/include).
  • ln -s -f /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../../usr/include/c++ /Users/swiftly/Desktop/s/build/Ninja-ReleaseAssert/llvm-macosx-x86_64/include
  • /usr/local/bin/cmake --build /Users/swiftly/Desktop/s/build/Ninja-ReleaseAssert/llvm-macosx-x86_64 -- -j4 all
    ninja: no work to do.
  • mkdir -p /Users/swiftly/Desktop/s/build/Ninja-ReleaseAssert/swift-macosx-x86_64
  • pushd /Users/swiftly/Desktop/s/build/Ninja-ReleaseAssert/swift-macosx-x86_64
    ~/Desktop/s/build/Ninja-ReleaseAssert/swift-macosx-x86_64 ~/Desktop/s
  • env /usr/local/bin/cmake -G Ninja -DCMAKE_C_COMPILER:PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -DCMAKE_CXX_COMPILER:PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -DCMAKE_LIBTOOL:PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -DLLVM_VERSION_MAJOR:STRING=7 -DLLVM_VERSION_MINOR:STRING=0 -DLLVM_VERSION_PATCH:STRING=0 -DCLANG_VERSION_MAJOR:STRING=7 -DCLANG_VERSION_MINOR:STRING=0 -DCLANG_VERSION_PATCH:STRING=0 -DCMAKE_MAKE_PROGRAM=/Users/swiftly/bin/ninja -DSWIFT_STDLIB_ENABLE_SIL_OWNERSHIP=FALSE -DSWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS=TRUE -DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE -DSWIFT_FORCE_OPTIMIZED_TYPECHECKER=FALSE -DSWIFT_STDLIB_ENABLE_STDLIBCORE_EXCLUSIVITY_CHECKING=FALSE -DSWIFT_LIPO:PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo '-DCMAKE_C_FLAGS= -Wno-unknown-warning-option -Werror=unguarded-availability-new -fno-stack-protector' '-DCMAKE_CXX_FLAGS= -Wno-unknown-warning-option -Werror=unguarded-availability-new -fno-stack-protector' '-DCMAKE_C_FLAGS_RELWITHDEBINFO=-O2 -DNDEBUG' '-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=-O2 -DNDEBUG' -DCMAKE_BUILD_TYPE:STRING=Release -DLLVM_ENABLE_ASSERTIONS:BOOL=TRUE -DSWIFT_ANALYZE_CODE_COVERAGE:STRING=FALSE -DSWIFT_STDLIB_BUILD_TYPE:STRING=Release -DSWIFT_STDLIB_ASSERTIONS:BOOL=TRUE -DSWIFT_STDLIB_USE_NONATOMIC_RC:BOOL=FALSE -DSWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS:BOOL=TRUE -DSWIFT_NATIVE_LLVM_TOOLS_PATH:STRING= -DSWIFT_NATIVE_CLANG_TOOLS_PATH:STRING= -DSWIFT_NATIVE_SWIFT_TOOLS_PATH:STRING= -DSWIFT_INCLUDE_TOOLS:BOOL=TRUE -DSWIFT_BUILD_REMOTE_MIRROR:BOOL=TRUE -DSWIFT_STDLIB_SIL_DEBUGGING:BOOL=FALSE -DSWIFT_CHECK_INCREMENTAL_COMPILATION:BOOL=FALSE -DSWIFT_REPORT_STATISTICS:BOOL=FALSE -DSWIFT_BUILD_DYNAMIC_STDLIB:BOOL=TRUE -DSWIFT_BUILD_STATIC_STDLIB:BOOL=FALSE -DSWIFT_BUILD_DYNAMIC_SDK_OVERLAY:BOOL=TRUE -DSWIFT_BUILD_STATIC_SDK_OVERLAY:BOOL=FALSE -DSWIFT_BUILD_PERF_TESTSUITE:BOOL=TRUE -DSWIFT_BUILD_EXTERNAL_PERF_TESTSUITE:BOOL=FALSE -DSWIFT_BUILD_EXAMPLES:BOOL=TRUE -DSWIFT_INCLUDE_TESTS:BOOL=TRUE -DSWIFT_INSTALL_COMPONENTS:STRING= -DSWIFT_EMBED_BITCODE_SECTION:BOOL=FALSE -DSWIFT_TOOLS_ENABLE_LTO:STRING= -DSWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER:BOOL=FALSE -DLIBDISPATCH_CMAKE_BUILD_TYPE:STRING=Release -DSWIFTLIB_DEPLOYMENT_VERSION_XCTEST_IOS=8.0 -DSWIFT_DARWIN_DEPLOYMENT_VERSION_OSX=10.9 -DSWIFT_DARWIN_DEPLOYMENT_VERSION_IOS=7.0 -DSWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS=9.0 -DSWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS=2.0 -DSWIFT_HOST_TRIPLE:STRING=x86_64-apple-macosx10.9 -DSWIFT_HOST_VARIANT=macosx -DSWIFT_HOST_VARIANT_SDK=OSX -DSWIFT_HOST_VARIANT_ARCH=x86_64 -DLLVM_LIT_ARGS=-sv -DCOVERAGE_DB= -DSWIFT_DARWIN_XCRUN_TOOLCHAIN:STRING=default -DSWIFT_AST_VERIFIER:BOOL=TRUE -DSWIFT_SIL_VERIFY_ALL:BOOL=FALSE -DSWIFT_RUNTIME_ENABLE_LEAK_CHECKER:BOOL=FALSE -DCMAKE_INSTALL_PREFIX:PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/ -DSWIFT_PATH_TO_CLANG_SOURCE:PATH=/Users/swiftly/Desktop/s/llvm/tools/clang -DSWIFT_PATH_TO_CLANG_BUILD:PATH=/Users/swiftly/Desktop/s/build/Ninja-ReleaseAssert/llvm-macosx-x86_64 -DSWIFT_PATH_TO_LLVM_SOURCE:PATH=/Users/swiftly/Desktop/s/llvm -DSWIFT_PATH_TO_LLVM_BUILD:PATH=/Users/swiftly/Desktop/s/build/Ninja-ReleaseAssert/llvm-macosx-x86_64 -DSWIFT_PATH_TO_CMARK_SOURCE:PATH=/Users/swiftly/Desktop/s/cmark -DSWIFT_PATH_TO_CMARK_BUILD:PATH=/Users/swiftly/Desktop/s/build/Ninja-ReleaseAssert/cmark-macosx-x86_64 -DSWIFT_PATH_TO_LIBDISPATCH_SOURCE:PATH=/Users/swiftly/Desktop/s/swift-corelibs-libdispatch -DSWIFT_CMARK_LIBRARY_DIR:PATH=/Users/swiftly/Desktop/s/build/Ninja-ReleaseAssert/cmark-macosx-x86_64/src '-DSWIFT_SDKS:STRING=IOS;IOS_SIMULATOR;OSX;TVOS;TVOS_SIMULATOR;WATCHOS;WATCHOS_SIMULATOR' -DSWIFT_EXEC:STRING=/Users/swiftly/Desktop/s/build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin/swiftc /Users/swiftly/Desktop/s/swift
    CMake Error: Error: generator : Ninja
    Does not match the generator used previously: Unix Makefiles
    Either remove the CMakeCache.txt file and CMakeFiles directory or choose a different binary directory.
    swift/utils/build-script: fatal error: command terminated with a non-zero exit status 1, aborting

(Jordan Rose) #2

This can happen if you have a bad configuration and then try to follow it up with a good one. That second-to-last line tells you what to do:

Either remove the CMakeCache.txt file and CMakeFiles directory [from the build directory] or choose a different binary directory.


(Eben Up) #3

That fixed it, thanks.