ordo-one / package-benchmark

Swift benchmark runner with many performance metrics and great CI support
Apache License 2.0
326 stars 25 forks source link

Newly created benchmark link error "symbol(s) not found for architecture arm64" #294

Open valeriyvan opened 1 month ago

valeriyvan commented 1 month ago

I have followed steps from README:

Then I try running newly created benchmark with swift package benchmark --target MyNewBenchmarkTarget but it fails with link error:

Build complete!
Building BenchmarkTool in release mode...
Building for debugging...
[0/3] Write swift-version--58304C5D6DBC2206.txt
Build of product 'BenchmarkBoilerplateGenerator' complete! (0.66s)
Building for production...
[0/4] Write swift-version--58304C5D6DBC2206.txt
error: link command failed with exit code 1 (use -v to see invocation)
ld: warning: object file (/Users/valeriyvan/Documents/blurhash/swift-blurhash/.build/arm64-apple-macosx/release/Benchmark.build/benchmark.swift.o) was built for newer 'macOS' version (13.3) than being linked (13.0)
Undefined symbols for architecture arm64:
  "static Benchmark.Benchmark.benchmarks : [Benchmark.Benchmark]", referenced from:
      (1) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
      (1) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
      (1) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
      (3) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
      (3) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
      (6) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
      (6) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
      ...
  "one-time initialization function for benchmarks", referenced from:
      (1) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
  "static Benchmark.Benchmark.startupHook : (() async throws -> ())?", referenced from:
      (1) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
      (3) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
      (6) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
  "static Benchmark.Benchmark.shutdownHook : (() async throws -> ())?", referenced from:
      (1) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
      (3) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
      (6) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
  "Benchmark.Benchmark.defaultConfiguration.unsafeMutableAddressor : Benchmark.Benchmark.Configuration", referenced from:
      closure #1 () -> Benchmark.Benchmark? in variable initialization expression of benchmark.benchmarks : () -> Benchmark.Benchmark? in benchmark.swift.o
      merged function signature specialization <Arg[0] = [Closure Propagated : closure #4 (BenchmarkTool.BenchmarkIdentifier) -> () in BenchmarkTool.BenchmarkTool.postProcessBenchmarkResults() throws -> (), Argument Types : [BenchmarkTool.BenchmarkTool]> of generic specialization <[BenchmarkTool.BenchmarkIdentifier : [Benchmark.BenchmarkResult]].Keys> of (extension in Swift):Swift.Sequence.forEach((A.Element) throws -> ()) throws -> () in BenchmarkTool+Operations.swift.o
  "static Benchmark.Benchmark.defaultConfiguration : Benchmark.Benchmark.Configuration", referenced from:
      variable initialization expression of Benchmark.Benchmark.configuration : Benchmark.Benchmark.Configuration in ARCStats.swift.o
  "one-time initialization function for defaultConfiguration", referenced from:
      variable initialization expression of Benchmark.Benchmark.configuration : Benchmark.Benchmark.Configuration in ARCStats.swift.o
  "static Benchmark.Benchmark.checkAbsoluteThresholds : Swift.Bool", referenced from:
      (1) suspend resume partial function for static (extension in Benchmark):Benchmark.BenchmarkRunnerHooks.main() async -> () in BenchmarkRunner.swift.o
      (1) suspend resume partial function for static Benchmark.BenchmarkRunner.setupBenchmarkRunner(registerBenchmarks: () -> ()) async -> () in BenchmarkRunner.swift.o
  "Benchmark.Benchmark.name.getter : Swift.String", referenced from:
      Benchmark.BenchmarkExecutor.run(Benchmark.Benchmark) -> [Benchmark.BenchmarkResult] in BenchmarkExecutor.swift.o
      Benchmark.BenchmarkExecutor.run(Benchmark.Benchmark) -> [Benchmark.BenchmarkResult] in BenchmarkExecutor.swift.o
      Benchmark.BenchmarkExecutor.run(Benchmark.Benchmark) -> [Benchmark.BenchmarkResult] in BenchmarkExecutor.swift.o
      closure #2 (Swift.Bool) -> () in Benchmark.BenchmarkExecutor.run(Benchmark.Benchmark) -> [Benchmark.BenchmarkResult] in BenchmarkExecutor.swift.o
      closure #3 (Swift.Bool) -> () in Benchmark.BenchmarkExecutor.run(Benchmark.Benchmark) -> [Benchmark.BenchmarkResult] in BenchmarkExecutor.swift.o
      (1) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
      (1) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
      (1) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
      (1) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
      (1) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
      (1) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
      (1) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
      ...
  "static Benchmark.Benchmark.setup : (() async throws -> ())?", referenced from:
      (1) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
      (3) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
      (6) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
  "Benchmark.Benchmark.runAsync() -> ()", referenced from:
      Benchmark.BenchmarkExecutor.run(Benchmark.Benchmark) -> [Benchmark.BenchmarkResult] in BenchmarkExecutor.swift.o
  "closure #1 @Sendable () -> () in Benchmark.Benchmark.runAsync() -> ()", referenced from:
      partial apply forwarder for closure #1 @Sendable () -> () in Benchmark.Benchmark.runAsync() -> () in BenchmarkExecutor.swift.o
  "static Benchmark.Benchmark.teardown : (() async throws -> ())?", referenced from:
      (1) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
      (3) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
      (6) suspend resume partial function for Benchmark.BenchmarkRunner.run() async throws -> () in BenchmarkRunner.swift.o
  "type metadata accessor for Benchmark.Benchmark", referenced from:
      closure #1 () -> Benchmark.Benchmark? in variable initialization expression of benchmark.benchmarks : () -> Benchmark.Benchmark? in benchmark.swift.o
      Benchmark.BenchmarkCommandRequest.encode(to: Swift.Encoder) throws -> () in BenchmarkInternals.swift.o
      Benchmark.BenchmarkCommandReply.encode(to: Swift.Encoder) throws -> () in BenchmarkInternals.swift.o
      Benchmark.BenchmarkCommandReply.encode(to: Swift.Encoder) throws -> () in BenchmarkInternals.swift.o
      function signature specialization <Arg[1] = Dead> of Benchmark.BenchmarkCommandRequest.init(from: Swift.Decoder) throws -> Benchmark.BenchmarkCommandRequest in BenchmarkInternals.swift.o
      function signature specialization <Arg[1] = Dead> of Benchmark.BenchmarkCommandReply.init(from: Swift.Decoder) throws -> Benchmark.BenchmarkCommandReply in BenchmarkInternals.swift.o
      function signature specialization <Arg[1] = Dead> of Benchmark.BenchmarkCommandReply.init(from: Swift.Decoder) throws -> Benchmark.BenchmarkCommandReply in BenchmarkInternals.swift.o
      ...
  "nominal type descriptor for Benchmark.Benchmark", referenced from:
      _symbolic _____xIeggn_ 9BenchmarkAAC in Benchmark+ConvenienceInitializers.swift.o
      _symbolic _____ 9BenchmarkAAC in Benchmark+ConvenienceInitializers.swift.o
      _symbolic _____xIegHgn_ 9BenchmarkAAC in Benchmark+ConvenienceInitializers.swift.o
      _symbolic _____x______pIeggnzo_ 9BenchmarkAAC s5ErrorP in Benchmark+ConvenienceInitializers.swift.o
      _symbolic _____x______pIegHgnzo_ 9BenchmarkAAC s5ErrorP in Benchmark+ConvenienceInitializers.swift.o
      _symbolic _____IegHg_ 9BenchmarkAAC in BenchmarkExecutor.swift.o
      _symbolic _____9benchmark_t 9BenchmarkAAC in BenchmarkInternals.swift.o
      ...
  "protocol conformance descriptor for Benchmark.Benchmark : Swift.Encodable in Benchmark", referenced from:
      Benchmark.BenchmarkCommandRequest.encode(to: Swift.Encoder) throws -> () in BenchmarkInternals.swift.o
      Benchmark.BenchmarkCommandReply.encode(to: Swift.Encoder) throws -> () in BenchmarkInternals.swift.o
      Benchmark.BenchmarkCommandReply.encode(to: Swift.Encoder) throws -> () in BenchmarkInternals.swift.o
  "protocol conformance descriptor for Benchmark.Benchmark : Swift.Decodable in Benchmark", referenced from:
      function signature specialization <Arg[1] = Dead> of Benchmark.BenchmarkCommandRequest.init(from: Swift.Decoder) throws -> Benchmark.BenchmarkCommandRequest in BenchmarkInternals.swift.o
      function signature specialization <Arg[1] = Dead> of Benchmark.BenchmarkCommandReply.init(from: Swift.Decoder) throws -> Benchmark.BenchmarkCommandReply in BenchmarkInternals.swift.o
      function signature specialization <Arg[1] = Dead> of Benchmark.BenchmarkCommandReply.init(from: Swift.Decoder) throws -> Benchmark.BenchmarkCommandReply in BenchmarkInternals.swift.o
      lazy protocol witness table accessor for type [Benchmark.Benchmark] and conformance <A where A: Swift.Decodable> [A] : Swift.Decodable in Swift in BenchmarkTool.swift.o
  "Benchmark.Benchmark.init(_: Swift.String, configuration: Benchmark.Benchmark.Configuration, closure: (Benchmark.Benchmark) async -> (), setup: (() async throws -> ())?, teardown: (() async throws -> ())?) -> Benchmark.Benchmark?", referenced from:
      Benchmark.Benchmark.__allocating_init<A>(_: Swift.String, configuration: Benchmark.Benchmark.Configuration, closure: (Benchmark.Benchmark, A) async -> (), setup: () async throws -> A, teardown: (() async throws -> ())?) -> Benchmark.Benchmark? in Benchmark+ConvenienceInitializers.swift.o
      Benchmark.Benchmark.__allocating_init<A>(_: Swift.String, configuration: Benchmark.Benchmark.Configuration, closure: (Benchmark.Benchmark, A) async throws -> (), setup: () async throws -> A, teardown: (() async throws -> ())?) -> Benchmark.Benchmark? in Benchmark+ConvenienceInitializers.swift.o
  "Benchmark.Benchmark.init(_: Swift.String, configuration: Benchmark.Benchmark.Configuration, closure: (Benchmark.Benchmark) -> (), setup: (() async throws -> ())?, teardown: (() async throws -> ())?) -> Benchmark.Benchmark?", referenced from:
      Benchmark.Benchmark.__allocating_init<A>(_: Swift.String, configuration: Benchmark.Benchmark.Configuration, closure: (Benchmark.Benchmark, A) -> (), setup: () async throws -> A, teardown: (() async throws -> ())?) -> Benchmark.Benchmark? in Benchmark+ConvenienceInitializers.swift.o
      Benchmark.Benchmark.__allocating_init<A>(_: Swift.String, configuration: Benchmark.Benchmark.Configuration, closure: (Benchmark.Benchmark, A) throws -> (), setup: () async throws -> A, teardown: (() async throws -> ())?) -> Benchmark.Benchmark? in Benchmark+ConvenienceInitializers.swift.o
      closure #1 () -> Benchmark.Benchmark? in variable initialization expression of benchmark.benchmarks : () -> Benchmark.Benchmark? in benchmark.swift.o
      merged function signature specialization <Arg[0] = [Closure Propagated : closure #4 (BenchmarkTool.BenchmarkIdentifier) -> () in BenchmarkTool.BenchmarkTool.postProcessBenchmarkResults() throws -> (), Argument Types : [BenchmarkTool.BenchmarkTool]> of generic specialization <[BenchmarkTool.BenchmarkIdentifier : [Benchmark.BenchmarkResult]].Keys> of (extension in Swift):Swift.Sequence.forEach((A.Element) throws -> ()) throws -> () in BenchmarkTool+Operations.swift.o
  "reabstraction thunk helper from @escaping @callee_guaranteed @Sendable () -> () to @escaping @callee_unowned @convention(block) @Sendable () -> ()", referenced from:
      Benchmark.BenchmarkExecutor.run(Benchmark.Benchmark) -> [Benchmark.BenchmarkResult] in BenchmarkExecutor.swift.o
      function signature specialization <Arg[0] = Dead> of Benchmark.OperatingSystemStatsProducer.startSampling(Swift.Int) -> () in OperatingSystemStatsProducer+Darwin.swift.o
  "generic specialization <[Benchmark.BenchmarkMetric]> of (extension in Swift):Swift.Sequence< where A.Element: Swift.Equatable>.contains(A.Element) -> Swift.Bool", referenced from:
      Benchmark.BenchmarkExecutor.run(Benchmark.Benchmark) -> [Benchmark.BenchmarkResult] in BenchmarkExecutor.swift.o
      Benchmark.BenchmarkExecutor.run(Benchmark.Benchmark) -> [Benchmark.BenchmarkResult] in BenchmarkExecutor.swift.o
      Benchmark.BenchmarkExecutor.run(Benchmark.Benchmark) -> [Benchmark.BenchmarkResult] in BenchmarkExecutor.swift.o
      Benchmark.BenchmarkExecutor.run(Benchmark.Benchmark) -> [Benchmark.BenchmarkResult] in BenchmarkExecutor.swift.o
      Benchmark.BenchmarkExecutor.run(Benchmark.Benchmark) -> [Benchmark.BenchmarkResult] in BenchmarkExecutor.swift.o
      Benchmark.BenchmarkExecutor.run(Benchmark.Benchmark) -> [Benchmark.BenchmarkResult] in BenchmarkExecutor.swift.o
      Benchmark.BenchmarkExecutor.run(Benchmark.Benchmark) -> [Benchmark.BenchmarkResult] in BenchmarkExecutor.swift.o
      Benchmark.BenchmarkExecutor.run(Benchmark.Benchmark) -> [Benchmark.BenchmarkResult] in BenchmarkExecutor.swift.o
      Benchmark.BenchmarkExecutor.run(Benchmark.Benchmark) -> [Benchmark.BenchmarkResult] in BenchmarkExecutor.swift.o
      Benchmark.BenchmarkExecutor.run(Benchmark.Benchmark) -> [Benchmark.BenchmarkResult] in BenchmarkExecutor.swift.o
      Benchmark.BenchmarkExecutor.run(Benchmark.Benchmark) -> [Benchmark.BenchmarkResult] in BenchmarkExecutor.swift.o
      ...
  "generic specialization <Benchmark.BenchmarkResult.ThresholdDeviation> of Swift._ArrayBuffer._consumeAndCreateNew(bufferIsUnique: Swift.Bool, minimumCapacity: Swift.Int, growForAppend: Swift.Bool) -> Swift._ArrayBuffer<A>", referenced from:
      generic specialization <Benchmark.BenchmarkResult.ThresholdDeviation, [Benchmark.BenchmarkResult.ThresholdDeviation]> of Swift.Array.append<A where A == A1.Element, A1: Swift.Sequence>(contentsOf: __owned A1) -> () in BenchmarkResult.swift.o
      Benchmark.BenchmarkResult.appendDeviationResultsFor(Benchmark.BenchmarkMetric, Swift.Int, Swift.Int, Benchmark.BenchmarkResult.Percentile, Benchmark.BenchmarkThresholds, Benchmark.Statistics.Units, inout Benchmark.BenchmarkResult.ThresholdDeviations, Swift.String, Swift.String) -> () in BenchmarkResult.swift.o
      Benchmark.BenchmarkResult.appendDeviationResultsFor(Benchmark.BenchmarkMetric, Swift.Int, Swift.Int, Benchmark.BenchmarkResult.Percentile, Benchmark.BenchmarkThresholds, Benchmark.Statistics.Units, inout Benchmark.BenchmarkResult.ThresholdDeviations, Swift.String, Swift.String) -> () in BenchmarkResult.swift.o
      Benchmark.BenchmarkResult.appendDeviationResultsFor(Benchmark.BenchmarkMetric, Swift.Int, Swift.Int, Benchmark.BenchmarkResult.Percentile, Benchmark.BenchmarkThresholds, Benchmark.Statistics.Units, inout Benchmark.BenchmarkResult.ThresholdDeviations, Swift.String, Swift.String) -> () in BenchmarkResult.swift.o
      Benchmark.BenchmarkResult.appendDeviationResultsFor(Benchmark.BenchmarkMetric, Swift.Int, Swift.Int, Benchmark.BenchmarkResult.Percentile, Benchmark.BenchmarkThresholds, Benchmark.Statistics.Units, inout Benchmark.BenchmarkResult.ThresholdDeviations, Swift.String, Swift.String) -> () in BenchmarkResult.swift.o
      Benchmark.BenchmarkResult.appendDeviationResultsFor(Benchmark.BenchmarkMetric, Swift.Int, Swift.Int, Benchmark.BenchmarkResult.Percentile, Benchmark.BenchmarkThresholds, Benchmark.Statistics.Units, inout Benchmark.BenchmarkResult.ThresholdDeviations, Swift.String, Swift.String) -> () in BenchmarkResult.swift.o
      Benchmark.BenchmarkResult.appendDeviationResultsFor(Benchmark.BenchmarkMetric, Swift.Int, Swift.Int, Benchmark.BenchmarkResult.Percentile, Benchmark.BenchmarkThresholds, Benchmark.Statistics.Units, inout Benchmark.BenchmarkResult.ThresholdDeviations, Swift.String, Swift.String) -> () in BenchmarkResult.swift.o
      Benchmark.BenchmarkResult.appendDeviationResultsFor(Benchmark.BenchmarkMetric, Swift.Int, Swift.Int, Benchmark.BenchmarkResult.Percentile, Benchmark.BenchmarkThresholds, Benchmark.Statistics.Units, inout Benchmark.BenchmarkResult.ThresholdDeviations, Swift.String, Swift.String) -> () in BenchmarkResult.swift.o
      Benchmark.BenchmarkResult.appendDeviationResultsFor(Benchmark.BenchmarkMetric, Swift.Int, Swift.Int, Benchmark.BenchmarkResult.Percentile, Benchmark.BenchmarkThresholds, Benchmark.Statistics.Units, inout Benchmark.BenchmarkResult.ThresholdDeviations, Swift.String, Swift.String) -> () in BenchmarkResult.swift.o
      ...
  "generic specialization <Benchmark.Statistics> of Swift._ArrayBuffer._consumeAndCreateNew(bufferIsUnique: Swift.Bool, minimumCapacity: Swift.Int, growForAppend: Swift.Bool) -> Swift._ArrayBuffer<A>", referenced from:
      generic specialization <Benchmark.Statistics> of Swift._ArrayBuffer._consumeAndCreateNew() -> Swift._ArrayBuffer<A> in Statistics.swift.o
  "generic specialization <serialized, Swift.UInt> of Swift._ArrayBuffer._consumeAndCreateNew(bufferIsUnique: Swift.Bool, minimumCapacity: Swift.Int, growForAppend: Swift.Bool) -> Swift._ArrayBuffer<A>", referenced from:
      generic specialization <serialized, Swift.UInt> of Swift._ArrayBuffer._consumeAndCreateNew() -> Swift._ArrayBuffer<A> in Statistics.swift.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[1/3] Linking BenchmarkTool

Benchmark failed to build the BenchmarkTool in release mode.
MahdiBM commented 1 month ago

Have you installed jemalloc? If you try swift build --explicit-target-dependency-import-check error it should clearly mention that you're missing something, if my guess is correct.

valeriyvan commented 1 month ago

Have you installed jemalloc? If you try swift build --explicit-target-dependency-import-check error it should clearly mention that you're missing something, if my guess is correct.

Readme doesn't mention this step.

And I've had it:

Warning: jemalloc 5.3.0 is already installed and up-to-date.

Here's output of swift build --explicit-target-dependency-import-check error:

swift build --explicit-target-dependency-import-check error
warning: 'swift-algorithms': found 1 file(s) which are unhandled; explicitly declare them as resources or exclude from the target
    /Users/******/.build/checkouts/swift-algorithms/Sources/Algorithms/Documentation.docc
Building for debugging...
[4/4] Write swift-version--58304C5D6DBC2206.txt
Build complete! (0.74s)

Running swift package --allow-writing-to-package-directory benchmark init MyNewBenchmarkTarget still fails.

MahdiBM commented 1 month ago

@valeriyvan I'm out of guesses then. Perhaps you might get a better answer by filing an issue in the Swift repo. In any case I don't see why the linker should fail without a more helpful message so you can debug your problem easier.

valeriyvan commented 1 month ago

@valeriyvan I'm out of guesses then. Perhaps you might get a better answer by filing an issue in the Swift repo. In any case I don't see why the linker should fail without a more helpful message so you can debug your problem easier.

I don't think it's Swift issue. I was able manually adding benchmark target and this target runs normally. I think there's some problem with plugin.

hassila commented 2 weeks ago

@lehtihet do you think you could have a look at this one too?