swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.3k stars 10.34k forks source link

[SR-11978] CMake error `... target "sourcekitd" that is not in any export set` when trying to compile the Swift compiler on macOS #54410

Open swift-ci opened 4 years ago

swift-ci commented 4 years ago
Previous ID SR-11978
Radar rdar://problem/58455054
Original Reporter eladn (JIRA User)
Type Bug
Environment ``` java TERM_PROGRAM=Apple_Terminal SHELL=/bin/zsh TERM=xterm-256color TERM_PROGRAM_VERSION=433 USER=eladn PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/Library/TeX/texbin:/opt/X11/bin PWD=/Users/eladn/swift-with-atomic-arc/swift-source/swift XPC_FLAGS=0x0 XPC_SERVICE_NAME=0 SHLVL=1 HOME=/Users/eladn LOGNAME=eladn OLDPWD=/Users/eladn/swift-with-atomic-arc/swift-source/swift CLICOLOR=1 LC_CTYPE=UTF-8 _=/usr/bin/env ``` The latest Xcode (11.3) is installed, and Xcode's command-line tools are installed using \`xcode-select --install\`. I made sure cmake & ninja are updated (installed via homebrew).
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 1 | |Component/s | Compiler | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 1b5a1d2d798a58d41a88509247f6c3c2

Issue Description:

I'm trying to compile the Swift compiler (latest release) on macOS, using these commands:

mkdir swift-source
cd swift-source
git clone https://github.com/apple/swift.git
cd swift
git checkout tags/swift-5.1.3-RELEASE
cd ..
./swift/utils/update-checkout --clone
./swift/utils/update-checkout --tag swift-5.1.3-RELEASE
cd swift
./utils/build-script --release --assertions --skip-build-benchmarks --build-ninja

Here is the error message:

-- Configuring done
CMake Error in cmake/modules/CMakeLists.txt:
  export called with target "swiftSwiftLang-macosx-x86_64" which requires
  target "sourcekitd" that is not in any export set.

-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.
utils/build-script: fatal error: command terminated with a non-zero exit status 1, aborting

I also tried additional multiple build parameters that also yielded the same error (with/without assertions, debug/release-debuginfo/release, make/build-ninja, with/without libdispatch and/or sourcekit-lsp and/or foundation). I made sure to use reconfigure&clean (or manually remove the build dir) between tries. I tried removing the whole project and re-clone it.

During the build execution I get the following warnings:

CMake Warning:
  Manually-specified variables were not used by the project:

    CLANG_VERSION_PATCH
    LLVM_TOOL_COMPILER_RT_BUILD
    LLVM_TOOL_SWIFT_BUILD
    SANITIZER_MIN_OSX_VERSION

Every build attempt I get these warings with different variables (depending on the build parameters).

beccadax commented 4 years ago

@swift-ci create

swift-ci commented 4 years ago

Comment by Chris Hamons (JIRA)

We ran into this as well. We were able to track it down to an updated cmake:

cmake 3.13.3 - Builds Fine
cmake 3.16.2 - Reproduce Error

So consider downgrading if you hit this, until it is fixed.

swift-ci commented 4 years ago

Comment by Elad Nachmias (JIRA)

Thanks Chris! Your observation is very helpful.

41412bb9-c79a-4f5a-8a7f-383cb40aa74b commented 4 years ago

Elad, do you see this error even in master scheme?

$ utils/update-checkout --scheme master
swift-ci commented 4 years ago

Comment by Elad Nachmias (JIRA)

@rintaro No, the error does not occur when using the master scheme as you suggested. The compilation completed successfully. (last commit on master: 3423ee107418e635182f768f3d6160a212eed846; cmake version: 3.16.3)

swift-ci commented 4 years ago

Comment by Elad Nachmias (JIRA)

The `master` branch is under development and not stable (currently even doesn't pass tests). So how can I find a recent commit from `master` that actually works?