swiftlang / swift

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

Build failure: `ERROR: can't find source directory for ninja` #72458

Open royitaqi opened 3 months ago

royitaqi commented 3 months ago

Description

Ran SKIP_XCODE_VERSION_CHECK=1 ./swift/utils/build-toolchain com.example. It ended with an error.

++ date +%Y
+ YEAR=2024
++ date +%m
+ MONTH=03
++ date +%d
+ DAY=20
+ TOOLCHAIN_VERSION=5.0.20240320
+ TOOLCHAIN_NAME=swift-LOCAL-2024-03-20-a
+ DARWIN_TOOLCHAIN_VERSION=0.0.20240320
+ ARCHIVE=swift-LOCAL-2024-03-20-a-osx.tar.gz
+ SYM_ARCHIVE=swift-LOCAL-2024-03-20-a-osx-symbols.tar.gz
+ BUNDLE_PREFIX=com.example
+ BUNDLE_IDENTIFIER=com.example.20240320
+ DISPLAY_NAME_SHORT='Local Swift Development Snapshot'
+ DISPLAY_NAME='Local Swift Development Snapshot 2024-03-20'
+ SWIFT_INSTALLABLE_PACKAGE=/Users/<username>/swift-LOCAL-2024-03-20-a-osx.tar.gz
+ SWIFT_INSTALL_DIR=/Users/<username>/swift-nightly-install
+ SWIFT_INSTALL_SYMROOT=/Users/<username>/swift-nightly-symroot
+ SWIFT_TOOLCHAIN_DIR=/Library/Developer/Toolchains/swift-LOCAL-2024-03-20-a.xctoolchain
+ SYMBOLS_PACKAGE=/Users/<username>/swift-LOCAL-2024-03-20-a-osx-symbols.tar.gz
+ DRY_RUN=
+ DISTCC_FLAG=
+ PRESET_FILE_FLAGS=
+ SCCACHE_FLAG=
+ ./utils/build-script --preset=buildbot_osx_package,no_test install_destdir=/Users/<username>/swift-nightly-install installable_package=/Users/<username>/swift-LOCAL-2024-03-20-a-osx.tar.gz install_toolchain_dir=/Library/Developer/Toolchains/swift-LOCAL-2024-03-20-a.xctoolchain install_symroot=/Users/<username>/swift-nightly-symroot symbols_package=/Users/<username>/swift-LOCAL-2024-03-20-a-osx-symbols.tar.gz darwin_toolchain_bundle_identifier=com.example.20240320 'darwin_toolchain_display_name=Local Swift Development Snapshot 2024-03-20' 'darwin_toolchain_display_name_short=Local Swift Development Snapshot' darwin_toolchain_xctoolchain_name=swift-LOCAL-2024-03-20-a darwin_toolchain_version=5.0.20240320 darwin_toolchain_alias=Local darwin_toolchain_require_use_os_runtime=
note: skipping Xcode version check
[./utils/build-script] NOTE: using preset "buildbot_osx_package,no_test", which expands to 

./utils/build-script '--swift-install-components=back-deployment;compiler;clang-resource-dir-symlink;stdlib;sdk-overlay;parser-lib;static-mirror-lib;toolchain-tools;license;sourcekit-xpc-service;swift-remote-mirror;swift-remote-mirror-headers' '--llvm-install-components=llvm-cov;llvm-profdata;IndexStore;clang;clang-resource-headers;compiler-rt;clangd;dsymutil;LTO;clang-features-file' --ios --tvos --watchos --lldb --llbuild --swiftpm --swift-driver --swiftsyntax --playgroundsupport --libcxx --indexstore-db --sourcekit-lsp --swiftdocc --back-deploy-concurrency --swiftsyntax-verify-generated-files --release-debuginfo --compiler-vendor=apple --cross-compile-hosts=macosx-arm64 --lldb-use-system-debugserver --lldb-build-type=Release --verbose-build --build-ninja --build-swift-stdlib-unittest-extra --skip-build-benchmarks '--extra-cmake-options=
-DLLDB_FRAMEWORK_COPY_SWIFT_RESOURCES=0
-DCMAKE_C_FLAGS="-gline-tables-only"
-DCMAKE_CXX_FLAGS="-gline-tables-only"' --install-llvm --install-swift --install-lldb --install-llbuild --install-swiftpm --install-swift-driver --install-swiftsyntax --install-playgroundsupport --install-libcxx --install-sourcekit-lsp --install-back-deploy-concurrency --install-swiftdocc --install-destdir=/Users/<username>/swift-nightly-install --darwin-install-extract-symbols --install-symroot=/Users/<username>/swift-nightly-symroot --install-prefix=/Library/Developer/Toolchains/swift-LOCAL-2024-03-20-a.xctoolchain/usr --test-installable-package --toolchain-benchmarks --reconfigure --installable-package=/Users/<username>/swift-LOCAL-2024-03-20-a-osx.tar.gz --symbols-package=/Users/<username>/swift-LOCAL-2024-03-20-a-osx-symbols.tar.gz --darwin-toolchain-bundle-identifier=com.example.20240320 '--darwin-toolchain-display-name=Local Swift Development Snapshot 2024-03-20' '--darwin-toolchain-display-name-short=Local Swift Development Snapshot' --darwin-toolchain-name=swift-LOCAL-2024-03-20-a --darwin-toolchain-version=5.0.20240320 --darwin-toolchain-alias=Local --darwin-toolchain-require-use-os-runtime=0 --build-subdir=buildbot_osx --ios --tvos --watchos --test --validation-test --long-test --stress-test --lldb-test-swift-only --installable-package=/Users/<username>/swift-LOCAL-2024-03-20-a-osx.tar.gz --assertions --swift-enable-ast-verifier=0 --no-swift-stdlib-assertions --skip-test-lldb --skip-test-swiftdocc --skip-test-playgroundsupport --skip-test-swift --skip-test-swiftpm --skip-test-swift-driver --skip-test-llbuild --skip-test-lldb --skip-test-cmark --skip-test-playgroundsupport --skip-test-swiftsyntax --skip-test-skstresstester --skip-test-swiftevolve --skip-test-swiftdocc

note: skipping Xcode version check
[./utils/build-script] NOTE: Using toolchain default
+ /usr/libexec/PlistBuddy -c 'Print :SupportedTargets:macosx:Archs' /Applications/Xcode_15.1.0_15C65_fb.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/SDKSettings.plist
+ /usr/libexec/PlistBuddy -c 'Print :SupportedTargets:iphonesimulator:Archs' /Applications/Xcode_15.1.0_15C65_fb.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.2.sdk/SDKSettings.plist
+ /usr/libexec/PlistBuddy -c 'Print :SupportedTargets:iphonesimulator:Archs' /Applications/Xcode_15.1.0_15C65_fb.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.2.sdk/SDKSettings.plist
+ /usr/libexec/PlistBuddy -c 'Print :SupportedTargets:iphoneos:Archs' /Applications/Xcode_15.1.0_15C65_fb.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.2.sdk/SDKSettings.plist
+ /usr/libexec/PlistBuddy -c 'Print :SupportedTargets:iphoneos:Archs' /Applications/Xcode_15.1.0_15C65_fb.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.2.sdk/SDKSettings.plist
+ /usr/libexec/PlistBuddy -c 'Print :SupportedTargets:appletvsimulator:Archs' /Applications/Xcode_15.1.0_15C65_fb.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator17.2.sdk/SDKSettings.plist
+ /usr/libexec/PlistBuddy -c 'Print :SupportedTargets:appletvsimulator:Archs' /Applications/Xcode_15.1.0_15C65_fb.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator17.2.sdk/SDKSettings.plist
+ /usr/libexec/PlistBuddy -c 'Print :SupportedTargets:appletvos:Archs' /Applications/Xcode_15.1.0_15C65_fb.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS17.2.sdk/SDKSettings.plist
+ /usr/libexec/PlistBuddy -c 'Print :SupportedTargets:watchsimulator:Archs' /Applications/Xcode_15.1.0_15C65_fb.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator10.2.sdk/SDKSettings.plist
+ /usr/libexec/PlistBuddy -c 'Print :SupportedTargets:watchsimulator:Archs' /Applications/Xcode_15.1.0_15C65_fb.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator10.2.sdk/SDKSettings.plist
+ /usr/libexec/PlistBuddy -c 'Print :SupportedTargets:watchsimulator:Archs' /Applications/Xcode_15.1.0_15C65_fb.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator10.2.sdk/SDKSettings.plist
+ /usr/libexec/PlistBuddy -c 'Print :SupportedTargets:watchos:Archs' /Applications/Xcode_15.1.0_15C65_fb.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS10.2.sdk/SDKSettings.plist
+ /usr/libexec/PlistBuddy -c 'Print :SupportedTargets:watchos:Archs' /Applications/Xcode_15.1.0_15C65_fb.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS10.2.sdk/SDKSettings.plist
+ mkdir -p /Users/<username>/build/buildbot_osx
[./utils/build-script] ERROR: can't find source directory for ninja (tried /Users/<username>/ninja)
ERROR: command terminated with a non-zero exit status 1, aborting

Searched on the internet. Some post mention "ninja-bin", but when I give it to the build command, it says "unexpected argument".

Environment:

Reproduction

SKIP_XCODE_VERSION_CHECK=1 ./swift/utils/build-toolchain com.example

Expected behavior

Successfully build.

Environment

Additional information

No response

DelphiWorlds commented 1 month ago

I'm having the same issue. Also surprised that it has been 2 months since this report, and no action?

DelphiWorlds commented 1 month ago

Some progress for me - I found I needed to clone the following into the parent folder of the swift repo:

https://github.com/commonmark/cmark https://github.com/apple/swift-llbuild (but rename the cloned folder to llbuild) https://github.com/llvm/llvm-project https://github.com/ninja-build/ninja https://github.com/apple/swift-argument-parser https://github.com/apple/swift-driver https://github.com/apple/swift-tools-support-core https://github.com/jpsim/Yams (but rename the folder to: yams i.e. lowercase y)

I am now stuck with this error:

--- Installing llvm ---
+ env DESTDIR=/Users/Shared/Source/ThirdParty/Apple/build/buildbot_osx/intermediate-install/macosx-arm64 /opt/homebrew/bin/cmake --build /Users/Shared/Source/ThirdParty/Apple/build/buildbot_osx/llvm-macosx-arm64 -- install-llvm-ar install-llvm-ranlib install-llvm-cov install-llvm-profdata install-IndexStore install-clang install-clang-resource-headers install-compiler-rt install-clangd install-dsymutil install-LTO install-clang-features-file install-lld
ninja: error: unknown target 'install-IndexStore'
ERROR: command terminated with a non-zero exit status 1, aborting

ERROR: command terminated with a non-zero exit status 1, aborting

Possibly more on this later...

tbkka commented 1 month ago

The "Cloning the Project" section of the Getting Started Guide explains how to use update-checkout to get all the sibling projects correctly set up.

DelphiWorlds commented 1 month ago

Thanks for the help! I've now completed a successful build. A couple of observations:

At this point, I'm just after swift-reflection-dump and it seems like overkill to build the entire toolchain. When I say stuff like that though, I almost always end up needing something else...