Build error with very simple benchmark package

I wanted to add benchmarks to my project, but could not get it to run.

Source code is here

Here is what I see when running swift package benchmark:

  • a plain new benchmark target with a dummy benchmark works just fine
  • once I add the dependency to my library Elementary to the target I get this wonderful build error (see below)
  • running the benchmark target with swift run -c release works just fine (with the Elementary dependency)

I am not sure if this is an issue with how the benchmark package calls into swift, or "just" a plain swift compiler bug - happy to move this into another category accordingly.

swift -v
Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0

Here is the error:

1.      Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
2.      Compiling with the current language version
3.      While evaluating request ExecuteSILPipelineRequest(Run pipelines { PrepareOptimizationPasses, EarlyModulePasses, HighLevel,Function+EarlyLoopOpt, HighLevel,Module+StackPromote, MidLevel,Function, ClosureSpecialize, LowLevel,Function, LateLoopOpt, SIL Debug Info Generator } on SIL for Elementary)
4.      While running pass #116648 SILModuleTransform "CrossModuleOptimization".
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           0x0000000109ca7f3c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000109ca70f8 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000109ca8544 SignalHandler(int) + 360
3  libsystem_platform.dylib 0x0000000187b03584 _sigtramp + 56
4  swift-frontend           0x0000000104e20fb4 swift::SILCloner<(anonymous namespace)::InstructionVisitor>::doesOpTupleDisappear(swift::CanTypeWrapper<swift::TupleType>) + 300
5  swift-frontend           0x0000000104e1b89c (anonymous namespace)::InstructionVisitor::makeTypesUsableFromInline(swift::SILInstruction*, (anonymous namespace)::CrossModuleOptimization&) + 4276
6  swift-frontend           0x0000000104e18fb0 (anonymous namespace)::CrossModuleOptimization::serializeFunction(swift::SILFunction*, llvm::DenseMap<swift::SILFunction*, bool, llvm::DenseMapInfo<swift::SILFunction*, void>, llvm::detail::DenseMapPair<swift::SILFunction*, bool>> const&) + 228
7  swift-frontend           0x0000000104e187f8 (anonymous namespace)::CrossModuleOptimizationPass::run() + 468
8  swift-frontend           0x0000000104fe0978 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 16476
9  swift-frontend           0x0000000105019354 swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::__1::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) + 56
10 swift-frontend           0x0000000104ffd184 llvm::Expected<swift::ExecuteSILPipelineRequest::OutputType> swift::Evaluator::getResultUncached<swift::ExecuteSILPipelineRequest>(swift::ExecuteSILPipelineRequest const&) + 476
11 swift-frontend           0x0000000104fffe94 swift::runSILOptimizationPasses(swift::SILModule&) + 504
12 swift-frontend           0x00000001047b516c swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 1224
13 swift-frontend           0x00000001045a5f98 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 1128
14 swift-frontend           0x00000001045a5a18 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 2100
15 swift-frontend           0x00000001045a9694 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1448
16 swift-frontend           0x00000001045a76d0 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4968
17 swift-frontend           0x0000000104536e8c swift::mainEntry(int, char const**) + 2612
18 dyld                     0x000000018774a0e0 start + 2360

Benchmark failed to run due to build error.
Full command output
% swift package benchmark
Building for debugging...
[1/1] Write swift-version--58304C5D6DBC2206.txt
Build complete! (0.21s)
Building for debugging...
[1/1] Write swift-version--58304C5D6DBC2206.txt
Build complete! (0.42s)
Build complete!
Building BenchmarkTool in release mode...
Building benchmark targets in release mode for benchmark run...
Building ElementaryBenchmarks
Building for production...
[0/2] Write swift-version--58304C5D6DBC2206.txt
Build complete! (0.13s)
Building for production...
[0/3] Write swift-version--58304C5D6DBC2206.txt
error: compile command failed due to signal 11 (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: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c /Users/simon/dev/swift-projects/Elementary/Sources/Elementary/Core/AttributeStorage.swift /Users/simon/dev/swift-projects/Elementary/Sources/Elementary/Core/CoreModel.swift /Users/simon/dev/swift-projects/Elementary/Sources/Elementary/Core/Html+Attributes.swift /Users/simon/dev/swift-projects/Elementary/Sources/Elementary/Core/Html+Elements.swift /Users/simon/dev/swift-projects/Elementary/Sources/Elementary/Core/Html+Rendering.swift /Users/simon/dev/swift-projects/Elementary/Sources/Elementary/Core/HtmlBuilder.swift /Users/simon/dev/swift-projects/Elementary/Sources/Elementary/Core/HtmlTextRenderer.swift /Users/simon/dev/swift-projects/Elementary/Sources/Elementary/HtmlAttributes.swift /Users/simon/dev/swift-projects/Elementary/Sources/Elementary/HtmlDocument.swift /Users/simon/dev/swift-projects/Elementary/Sources/Elementary/HtmlElements.swift /Users/simon/dev/swift-projects/Elementary/Sources/Elementary/HtmlTags.swift -supplementary-output-file-map /var/folders/7w/fd5kdmmj5mqd5j5yjznxs5g40000gn/T/TemporaryDirectory.w4EY27/supplementaryOutputs-1 -target arm64-apple-macosx14.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -I /Users/simon/dev/swift-projects/Elementary/Benchmarks/.build/arm64-apple-macosx/release -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -enable-testing -g -module-cache-path /Users/simon/dev/swift-projects/Elementary/Benchmarks/.build/arm64-apple-macosx/release/ModuleCache -swift-version 5 -O -D SWIFT_PACKAGE -new-driver-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -enable-experimental-feature StrictConcurrency=complete -enable-upcoming-feature ExistentialAny -enable-upcoming-feature ConciseMagicFile -enable-upcoming-feature ImplicitOpenExistentials -empty-abi-descriptor -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -Xcc -isysroot -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -Xcc -F -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -Xcc -fPIC -Xcc -g -module-name Elementary -package-name elementary -disable-clang-spi -target-sdk-version 14.5 -target-sdk-name macosx14.5 -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/bin/swift-plugin-server -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 -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins -enable-default-cmo -parse-as-library -num-threads 10 -o /Users/simon/dev/swift-projects/Elementary/Benchmarks/.build/arm64-apple-macosx/release/Elementary.build/AttributeStorage.swift.o -o /Users/simon/dev/swift-projects/Elementary/Benchmarks/.build/arm64-apple-macosx/release/Elementary.build/CoreModel.swift.o -o /Users/simon/dev/swift-projects/Elementary/Benchmarks/.build/arm64-apple-macosx/release/Elementary.build/Html+Attributes.swift.o -o /Users/simon/dev/swift-projects/Elementary/Benchmarks/.build/arm64-apple-macosx/release/Elementary.build/Html+Elements.swift.o -o /Users/simon/dev/swift-projects/Elementary/Benchmarks/.build/arm64-apple-macosx/release/Elementary.build/Html+Rendering.swift.o -o /Users/simon/dev/swift-projects/Elementary/Benchmarks/.build/arm64-apple-macosx/release/Elementary.build/HtmlBuilder.swift.o -o /Users/simon/dev/swift-projects/Elementary/Benchmarks/.build/arm64-apple-macosx/release/Elementary.build/HtmlTextRenderer.swift.o -o /Users/simon/dev/swift-projects/Elementary/Benchmarks/.build/arm64-apple-macosx/release/Elementary.build/HtmlAttributes.swift.o -o /Users/simon/dev/swift-projects/Elementary/Benchmarks/.build/arm64-apple-macosx/release/Elementary.build/HtmlDocument.swift.o -o /Users/simon/dev/swift-projects/Elementary/Benchmarks/.build/arm64-apple-macosx/release/Elementary.build/HtmlElements.swift.o -o /Users/simon/dev/swift-projects/Elementary/Benchmarks/.build/arm64-apple-macosx/release/Elementary.build/HtmlTags.swift.o
1.      Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
2.      Compiling with the current language version
3.      While evaluating request ExecuteSILPipelineRequest(Run pipelines { PrepareOptimizationPasses, EarlyModulePasses, HighLevel,Function+EarlyLoopOpt, HighLevel,Module+StackPromote, MidLevel,Function, ClosureSpecialize, LowLevel,Function, LateLoopOpt, SIL Debug Info Generator } on SIL for Elementary)
4.      While running pass #116648 SILModuleTransform "CrossModuleOptimization".
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           0x0000000109ca7f3c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000109ca70f8 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000109ca8544 SignalHandler(int) + 360
3  libsystem_platform.dylib 0x0000000187b03584 _sigtramp + 56
4  swift-frontend           0x0000000104e20fb4 swift::SILCloner<(anonymous namespace)::InstructionVisitor>::doesOpTupleDisappear(swift::CanTypeWrapper<swift::TupleType>) + 300
5  swift-frontend           0x0000000104e1b89c (anonymous namespace)::InstructionVisitor::makeTypesUsableFromInline(swift::SILInstruction*, (anonymous namespace)::CrossModuleOptimization&) + 4276
6  swift-frontend           0x0000000104e18fb0 (anonymous namespace)::CrossModuleOptimization::serializeFunction(swift::SILFunction*, llvm::DenseMap<swift::SILFunction*, bool, llvm::DenseMapInfo<swift::SILFunction*, void>, llvm::detail::DenseMapPair<swift::SILFunction*, bool>> const&) + 228
7  swift-frontend           0x0000000104e187f8 (anonymous namespace)::CrossModuleOptimizationPass::run() + 468
8  swift-frontend           0x0000000104fe0978 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 16476
9  swift-frontend           0x0000000105019354 swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::__1::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) + 56
10 swift-frontend           0x0000000104ffd184 llvm::Expected<swift::ExecuteSILPipelineRequest::OutputType> swift::Evaluator::getResultUncached<swift::ExecuteSILPipelineRequest>(swift::ExecuteSILPipelineRequest const&) + 476
11 swift-frontend           0x0000000104fffe94 swift::runSILOptimizationPasses(swift::SILModule&) + 504
12 swift-frontend           0x00000001047b516c swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 1224
13 swift-frontend           0x00000001045a5f98 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 1128
14 swift-frontend           0x00000001045a5a18 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 2100
15 swift-frontend           0x00000001045a9694 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1448
16 swift-frontend           0x00000001045a76d0 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4968
17 swift-frontend           0x0000000104536e8c swift::mainEntry(int, char const**) + 2612
18 dyld                     0x000000018774a0e0 start + 2360

Benchmark failed to run due to build error.
error: buildFailed

Any ideas?

What's the corresponding GitHub issue for this? If you haven't created one yet, I recommend filing a GitHub issue first, that makes it easier to track, and Swift Forums is not really suitable as a bug tracking system.

this is a strong indicator that this is a swift compiler crash and not directly attributable to the benchmark package.

I think I found an existing issue of the same bug:

I'll add my reproducer there.

edit: not sure actually, I posted a new issue: