swift-server / swift-backtrace

💥 Backtraces for Swift on Linux and Windows
Apache License 2.0
295 stars 35 forks source link

Support compiling against Musl #71

Closed simonjbeaumont closed 4 months ago

simonjbeaumont commented 4 months ago

Motivation

When building for Linux, we would like to be able to build this package on top of Musl, as well as the usual Glibc.

Modifications

Replace imports of Glibc with conditional imports using the following pattern:

- import Glibc
+ #if canImport(Glibc)
+ import Glibc
+ #elseif canImport(Musl)
+ import Musl
+ #else
+ #error("Unsupported runtime")
+ #endif

Result

Can compile against Musl.

FranzBusch commented 4 months ago

@swift-server-bot test this please

FranzBusch commented 4 months ago

I am happy to get this in but we should see that projects start to drop this dependency since it is no longer needed.

simonjbeaumont commented 4 months ago

@FranzBusch Agreed. But it would still be useful in the short term as it is used in a few places where I'm sprinkling this change around.

simonjbeaumont commented 4 months ago

Actually, I think we don't need this one after all :)