From 44f76fc4395e76238673764f5aca6d1267f92d1e Mon Sep 17 00:00:00 2001 From: Marc Prud'hommeaux Date: Sun, 16 Mar 2025 19:05:50 -0400 Subject: [PATCH] Fixes for platforms that do not have RTLD_FIRST (e.g., Android) --- Sources/swiftpm-testing-helper/Entrypoint.swift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Sources/swiftpm-testing-helper/Entrypoint.swift b/Sources/swiftpm-testing-helper/Entrypoint.swift index 94698af1a95..93d27cb70de 100644 --- a/Sources/swiftpm-testing-helper/Entrypoint.swift +++ b/Sources/swiftpm-testing-helper/Entrypoint.swift @@ -10,7 +10,11 @@ // //===----------------------------------------------------------------------===// +#if canImport(Darwin) import Darwin.C +#elseif canImport(Android) +import Android +#endif @main struct Entrypoint { @@ -18,7 +22,12 @@ struct Entrypoint { let args = CommandLine.arguments if args.count >= 3, args[1] == "--test-bundle-path" { let bundlePath = args[2] - guard let image = dlopen(bundlePath, RTLD_LAZY | RTLD_FIRST) else { + #if canImport(Darwin) + let flags = RTLD_LAZY | RTLD_FIRST + #else + let flags = RTLD_LAZY + #endif + guard let image = dlopen(bundlePath, flags) else { let errorMessage: String = dlerror().flatMap { String(validatingCString: $0) } ?? "An unknown error occurred."