From d4f33e71ca1849f98616cadca12423583d07337f Mon Sep 17 00:00:00 2001 From: Euan Harris Date: Thu, 13 Jun 2024 13:32:14 +0100 Subject: [PATCH] Do not build Demangle on Swift 5.9 or above Pull request #68 prevents Backtrace from being built on Swift 5.9 and above, but Demangle is still built and fails when the importing project uses musl. --- Sources/Backtrace/Demangle.swift | 6 ++++++ Sources/Sample/main.swift | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Sources/Backtrace/Demangle.swift b/Sources/Backtrace/Demangle.swift index 5993e41..1ae7962 100644 --- a/Sources/Backtrace/Demangle.swift +++ b/Sources/Backtrace/Demangle.swift @@ -12,6 +12,10 @@ // //===----------------------------------------------------------------------===// +// Swift 5.9 has its own built-in backtracing support in the runtime; +// we don't want to activate this library if we're using 5.9 or above. +#if !(swift(>=5.9) && !os(Windows)) + #if os(Linux) import Glibc #elseif os(Windows) @@ -55,3 +59,5 @@ internal func _stdlib_demangleName(_ mangledName: String) -> String { } } #endif + +#endif diff --git a/Sources/Sample/main.swift b/Sources/Sample/main.swift index 994bf55..2f3c31b 100644 --- a/Sources/Sample/main.swift +++ b/Sources/Sample/main.swift @@ -15,8 +15,10 @@ import Backtrace #if canImport(Darwin) import Darwin -#elseif os(Linux) +#elseif canImport(Glibc) import Glibc +#elseif canImport(Musl) +import Musl #endif #if swift(<5.9) || os(Windows)