swiftlang / swift-foundation

The Foundation project
Apache License 2.0
2.36k stars 150 forks source link

Unable to build repo with the 6.0 release toolchain #920

Open sbhat98 opened 3 days ago

sbhat98 commented 3 days ago

Hello all,

I am trying to build the repo with the hopes of contributing, but I have been unable to successfully run swift build using the instructions provided. According the to README, this repo requires the in-development nightly toolchain to run, but neither the latest nightly or the latest stable release on swift.org are able to build this repository without erroring out.

I did try to build with the XCode version of Swift and it works fine there.

Platform: MacBook Pro 2019 16" (x86) OS: Seqouia XCode Version: 16.0 Swift toolchain versions tried: swift-6.0-DEVELOPMENT-SNAPSHOT-2024-09-11-a swift-6.0-RELEASE

swift build partial output:

error: 'swift-syntax': Invalid manifest (compiled with: ["/Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/bin/swiftc", "-vfsoverlay", "/var/folders/cj/0w4bb6k17375x2djs9w7k0x80000gn/T/TemporaryDirectory.Znc2Dl/vfs.yaml", "-L", "/Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/lib/swift/pm/ManifestAPI", "-lPackageDescription", "-Xlinker", "-rpath", "-Xlinker", "/Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/lib/swift/pm/ManifestAPI", "-target", "x86_64-apple-macosx13.0", "-I", "/Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/lib/swift/macosx/testing", "-L", "/Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/lib/swift/macosx/testing", "-plugin-path", "/Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/lib/swift/host/plugins/testing", "-sdk", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk", "-F", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks", "-I", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib", "-L", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib", "-swift-version", "5", "-I", "/Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/lib/swift/pm/ManifestAPI", "-sdk", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk", "-package-description-version", "5.8.0", "/Users/shishir/code/swift-foundation/.build/checkouts/swift-syntax/Package.swift", "-o", "/var/folders/cj/0w4bb6k17375x2djs9w7k0x80000gn/T/TemporaryDirectory.Z949DP/swift-syntax-manifest"])
error: compile command failed due to signal 6 (use -v to see invocation)
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file /Users/shishir/code/swift-foundation/.build/checkouts/swift-syntax/Package.swift -target x86_64-apple-macosx13.0 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk -I /Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/lib/swift/macosx/testing -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -I /Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/lib/swift/pm/ManifestAPI -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -vfsoverlay /var/folders/cj/0w4bb6k17375x2djs9w7k0x80000gn/T/TemporaryDirectory.Znc2Dl/vfs.yaml -swift-version 5 -package-description-version 5.8.0 -empty-abi-descriptor -plugin-path /Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/lib/swift/host/plugins/testing -resource-dir /Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/lib/swift -module-name main -plugin-path /Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/local/lib/swift/host/plugins -target-sdk-version 15.0 -target-sdk-name macosx15.0 -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -o /var/folders/cj/0w4bb6k17375x2djs9w7k0x80000gn/T/TemporaryDirectory.1YH68I/Package-1.o
1.  Apple Swift version 6.0 (swift-6.0-RELEASE)
2.  Compiling with effective version 5.10
3.  While evaluating request ExecuteSILPipelineRequest(Run pipelines { Mandatory Diagnostic Passes + Enabling Optimization Passes } on SIL for Darwin)
4.  While running pass #3472 SILModuleTransform "MandatorySILLinker".
5.  While deserializing SIL function "$s6Darwin14POSIXErrorCodeO8rawValueACSgs5Int32V_tcfC"
6.  *** DESERIALIZATION FAILURE ***
*** If any module named here was modified in the SDK, please delete the ***
*** new swiftmodule files from the SDK and keep only swiftinterfaces.   ***
module '_errno', builder version '6.0(6.0)/Apple Swift version 6.0 (swift-6.0-RELEASE)', built from swiftinterface, resilient, loaded from '/var/folders/cj/0w4bb6k17375x2djs9w7k0x80000gn/C/clang/ModuleCache/_errno-CG91D9IBL6N9.swiftmodule'
SILFunction type mismatch for '$s6Darwin14POSIXErrorCodeO8rawValueACSgs5Int32V_tcfC': '$@convention(method) (Int32, @thin POSIXErrorCode.Type) -> Optional<POSIXErrorCode>' != '$@convention(method) (Int32, @thin POSIXErrorCode.Type) -> Optional<POSIXErrorCode>'

Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x000000010bdf50c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 40
1  swift-frontend           0x000000010bdf35b5 llvm::sys::RunSignalHandlers() + 85
2  swift-frontend           0x000000010bdf571e SignalHandler(int) + 270
3  libsystem_platform.dylib 0x00007ff802876e9d _sigtramp + 29
4  libsystem_platform.dylib 0x6f636e6520726f72 _sigtramp + 8026239638348431602
5  libsystem_c.dylib        0x00007ff802762b19 abort + 126
6  swift-frontend           0x0000000106af8762 swift::ModuleFileSharedCore::fatal(llvm::Error) const + 1426
7  swift-frontend           0x0000000106a78395 swift::ModuleFile::diagnoseFatal(llvm::Error) const + 1221
8  swift-frontend           0x0000000106ac9741 swift::SILDeserializer::readSILFunctionChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, swift::SILFunction*, llvm::StringRef, bool, bool) + 2481
9  swift-frontend           0x0000000106adeedb swift::SILDeserializer::lookupSILFunction(swift::SILFunction*, bool) + 427
10 swift-frontend           0x0000000106b8c3db swift::SerializedSILLoader::lookupSILFunction(swift::SILFunction*, bool) + 123
11 swift-frontend           0x0000000106bca62b swift::SILLinkerVisitor::process() + 491
12 swift-frontend           0x0000000106bca40a swift::SILLinkerVisitor::processFunction(swift::SILFunction*) + 90
13 swift-frontend           0x0000000106c58c37 swift::SILModule::linkFunction(swift::SILFunction*, swift::SILModule::LinkingMode) + 135
14 swift-frontend           0x0000000106883aee (anonymous namespace)::SILLinker::run() + 158
15 swift-frontend           0x0000000106715ce1 swift::SILPassManager::runModulePass(unsigned int) + 945
16 swift-frontend           0x0000000106718c1b swift::SILPassManager::execute() + 619
17 swift-frontend           0x00000001067120e8 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 72
18 swift-frontend           0x0000000106712061 swift::ExecuteSILPipelineRequest::evaluate(swift::Evaluator&, swift::SILPipelineExecutionDescriptor) const + 65
19 swift-frontend           0x0000000106758e3d swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::__1::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) + 29
20 swift-frontend           0x0000000106730d63 swift::ExecuteSILPipelineRequest::OutputType swift::Evaluator::getResultUncached<swift::ExecuteSILPipelineRequest, swift::ExecuteSILPipelineRequest::OutputType swift::evaluateOrFatal<swift::ExecuteSILPipelineRequest>(swift::Evaluator&, swift::ExecuteSILPipelineRequest)::'lambda'()>(swift::ExecuteSILPipelineRequest const&, swift::ExecuteSILPipelineRequest::OutputType swift::evaluateOrFatal<swift::ExecuteSILPipelineRequest>(swift::Evaluator&, swift::ExecuteSILPipelineRequest)::'lambda'()) + 195
21 swift-frontend           0x00000001067122fd swift::executePassPipelinePlan(swift::SILModule*, swift::SILPassPipelinePlan const&, bool, swift::irgen::IRGenModule*) + 61
22 swift-frontend           0x0000000106733379 swift::runSILDiagnosticPasses(swift::SILModule&) + 185
23 swift-frontend           0x0000000105e0f5cc swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 60
24 swift-frontend           0x0000000105e1bd43 swift::ExplicitModuleInterfaceBuilder::buildSwiftModuleFromInterface(llvm::StringRef, llvm::StringRef, bool, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>*, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, llvm::StringRef) + 2675
25 swift-frontend           0x0000000105e1d9d6 std::__1::error_code llvm::function_ref<std::__1::error_code (swift::SubCompilerInstanceInfo&)>::callback_fn<swift::ImplicitModuleInterfaceBuilder::buildSwiftModuleInternal(llvm::StringRef, bool, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>*, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>)::$_3::operator()() const::'lambda'(swift::SubCompilerInstanceInfo&)>(long, swift::SubCompilerInstanceInfo&) + 278
26 swift-frontend           0x0000000105e2b8b0 swift::InterfaceSubContextDelegateImpl::runInSubCompilerInstance(llvm::StringRef, llvm::StringRef, llvm::StringRef, llvm::StringRef, swift::SourceLoc, bool, llvm::function_ref<std::__1::error_code (swift::SubCompilerInstanceInfo&)>) + 3040
27 swift-frontend           0x0000000105e1d6a5 void llvm::function_ref<void ()>::callback_fn<swift::ImplicitModuleInterfaceBuilder::buildSwiftModuleInternal(llvm::StringRef, bool, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>*, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>)::$_3>(long) + 405
28 swift-frontend           0x000000010bd5ddf2 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 130
29 swift-frontend           0x000000010bd5df00 RunSafelyOnThread_Dispatch(void*) + 48
30 swift-frontend           0x000000010bd5df1f void* llvm::thread::ThreadProxy<std::__1::tuple<void (*)(void*), (anonymous namespace)::RunSafelyOnThreadInfo*>>(void*) + 15
31 libsystem_pthread.dylib  0x00007ff802842253 _pthread_start + 99
32 libsystem_pthread.dylib  0x00007ff80283dbef thread_start + 15
sbhat98 commented 3 days ago

I seem to be able to build the repo fine with the nightly 6.0 release on Windows.

jmschonfeld commented 2 days ago

This appears to be a general issue with using the OSS toolchains on Darwin platforms while importing the Darwin module and not specific to Foundation (although this is related to Foundation since Foundation imports the Darwin module). I'm going to transfer this issue over to the main swift repo to track the fix in the compiler. I believe @ian-twilightcoder and some other folks have been looking into this

jmschonfeld commented 1 day ago

This was resolved on release/6.0 with https://github.com/swiftlang/swift/pull/76552. It should land in the nightly toolchain snapshots within the next few days. There's also https://github.com/swiftlang/swift/issues/76534 which is tracking this general issue on the swift repo, so I think this is a dupe of that issue if you'd like to close this in favor of that one. Feel free to report back on the swift repo if you still encounter issues after that fix has landed in a nightly snapshot