From fc63f0cf4e55a4597407a9fc95b16a2bc44b4982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregor=20Milos=20=28Grzegorz=20Mi=C5=82o=C5=9B=29?= Date: Wed, 6 Mar 2024 14:46:50 +0000 Subject: [PATCH] Fix memory allocations counters on macOS. (#2673) Motivation: Allocation counters are broken on macOS as described [here](https://github.com/apple/swift-nio/issues/2672). This PR fixes it. Modifications: `AtomicCounter` library is made `.dynamic`. This deduplicates the two (static) copies that used to exist. One embedded in the main binary, and the other in `HookedFunctions` dylib. This deplication fixes the issue, because there is just one copy of the counters in the process address space. Result: All the tests counting allocations and related statistics work on macOS. --- .../template/AtomicCounter/Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IntegrationTests/allocation-counter-tests-framework/template/AtomicCounter/Package.swift b/IntegrationTests/allocation-counter-tests-framework/template/AtomicCounter/Package.swift index 3e2edbf48..c1872d9e6 100644 --- a/IntegrationTests/allocation-counter-tests-framework/template/AtomicCounter/Package.swift +++ b/IntegrationTests/allocation-counter-tests-framework/template/AtomicCounter/Package.swift @@ -19,7 +19,7 @@ import PackageDescription let package = Package( name: "AtomicCounter", products: [ - .library(name: "AtomicCounter", targets: ["AtomicCounter"]), + .library(name: "AtomicCounter", type: .dynamic, targets: ["AtomicCounter"]), ], dependencies: [ ], targets: [