Skip to content

Commit 8a85837

Browse files
committed
fix: support musl on Linux
1 parent f71bc9c commit 8a85837

File tree

8 files changed

+128
-4
lines changed

8 files changed

+128
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- .NET MAUI integration with CommunityToolkit.Mvvm Async Relay Commands can now be auto spanned with the new package Sentry.Maui.CommunityToolkit.Mvvm ([#4125](https://github.com/getsentry/sentry-dotnet/pull/4125))
88

9+
### Fixes
10+
11+
- Support musl on Linux ([#4188](https://github.com/getsentry/sentry-dotnet/pull/4188))
12+
913
### Dependencies
1014

1115
- Bump Native SDK from v0.8.4 to v0.8.5 ([#4189](https://github.com/getsentry/sentry-dotnet/pull/4189))

Sentry-CI-Build-Linux-musl.slnf

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"solution": {
3+
"path": "Sentry.sln",
4+
"projects": [
5+
"benchmarks\\Sentry.Benchmarks\\Sentry.Benchmarks.csproj",
6+
"samples\\Sentry.Samples.AspNetCore.Basic\\Sentry.Samples.AspNetCore.Basic.csproj",
7+
"samples\\Sentry.Samples.AspNetCore.Blazor.Server\\Sentry.Samples.AspNetCore.Blazor.Server.csproj",
8+
"samples\\Sentry.Samples.AspNetCore.Blazor.Wasm\\Sentry.Samples.AspNetCore.Blazor.Wasm.csproj",
9+
"samples\\Sentry.Samples.AspNetCore.Grpc\\Sentry.Samples.AspNetCore.Grpc.csproj",
10+
"samples\\Sentry.Samples.AspNetCore.Mvc\\Sentry.Samples.AspNetCore.Mvc.csproj",
11+
"samples\\Sentry.Samples.AspNetCore.Serilog\\Sentry.Samples.AspNetCore.Serilog.csproj",
12+
"samples\\Sentry.Samples.AspNetCore.WebAPI.Profiling\\Sentry.Samples.AspNetCore.WebAPI.Profiling.csproj",
13+
"samples\\Sentry.Samples.Aws.Lambda.AspNetCoreServer\\Sentry.Samples.Aws.Lambda.AspNetCoreServer.csproj",
14+
"samples\\Sentry.Samples.Azure.Functions.Worker\\Sentry.Samples.Azure.Functions.Worker.csproj",
15+
"samples\\Sentry.Samples.Console.Basic\\Sentry.Samples.Console.Basic.csproj",
16+
"samples\\Sentry.Samples.Console.Customized\\Sentry.Samples.Console.Customized.csproj",
17+
"samples\\Sentry.Samples.Console.HeapDump\\Sentry.Samples.Console.HeapDump.csproj",
18+
"samples\\Sentry.Samples.Console.Native\\Sentry.Samples.Console.Native.csproj",
19+
"samples\\Sentry.Samples.Console.Profiling\\Sentry.Samples.Console.Profiling.csproj",
20+
"samples\\Sentry.Samples.EntityFramework\\Sentry.Samples.EntityFramework.csproj",
21+
"samples\\Sentry.Samples.GenericHost\\Sentry.Samples.GenericHost.csproj",
22+
"samples\\Sentry.Samples.Google.Cloud.Functions\\Sentry.Samples.Google.Cloud.Functions.csproj",
23+
"samples\\Sentry.Samples.GraphQL.Client.Http\\Sentry.Samples.GraphQL.Client.Http.csproj",
24+
"samples\\Sentry.Samples.GraphQL.Server\\Sentry.Samples.GraphQL.Server.csproj",
25+
"samples\\Sentry.Samples.Hangfire\\Sentry.Samples.Hangfire.csproj",
26+
"samples\\Sentry.Samples.Log4Net\\Sentry.Samples.Log4Net.csproj",
27+
"samples\\Sentry.Samples.ME.Logging\\Sentry.Samples.ME.Logging.csproj",
28+
"samples\\Sentry.Samples.NLog\\Sentry.Samples.NLog.csproj",
29+
"samples\\Sentry.Samples.OpenTelemetry.AspNetCore\\Sentry.Samples.OpenTelemetry.AspNetCore.csproj",
30+
"samples\\Sentry.Samples.OpenTelemetry.Console\\Sentry.Samples.OpenTelemetry.Console.csproj",
31+
"samples\\Sentry.Samples.Serilog\\Sentry.Samples.Serilog.csproj",
32+
"src\\Sentry.Analyzers\\Sentry.Analyzers.csproj",
33+
"src\\Sentry.AspNetCore.Blazor.WebAssembly\\Sentry.AspNetCore.Blazor.WebAssembly.csproj",
34+
"src\\Sentry.AspNetCore.Grpc\\Sentry.AspNetCore.Grpc.csproj",
35+
"src\\Sentry.AspNetCore\\Sentry.AspNetCore.csproj",
36+
"src\\Sentry.Azure.Functions.Worker\\Sentry.Azure.Functions.Worker.csproj",
37+
"src\\Sentry.DiagnosticSource\\Sentry.DiagnosticSource.csproj",
38+
"src\\Sentry.EntityFramework\\Sentry.EntityFramework.csproj",
39+
"src\\Sentry.Extensions.Logging\\Sentry.Extensions.Logging.csproj",
40+
"src\\Sentry.Google.Cloud.Functions\\Sentry.Google.Cloud.Functions.csproj",
41+
"src\\Sentry.Hangfire\\Sentry.Hangfire.csproj",
42+
"src\\Sentry.Log4Net\\Sentry.Log4Net.csproj",
43+
"src\\Sentry.NLog\\Sentry.NLog.csproj",
44+
"src\\Sentry.OpenTelemetry\\Sentry.OpenTelemetry.csproj",
45+
"src\\Sentry.Profiling\\Sentry.Profiling.csproj",
46+
"src\\Sentry.Serilog\\Sentry.Serilog.csproj",
47+
"src\\Sentry.SourceGenerators\\Sentry.SourceGenerators.csproj",
48+
"src\\Sentry\\Sentry.csproj",
49+
"test\\Sentry.Analyzers.Tests\\Sentry.Analyzers.Tests.csproj",
50+
"test\\Sentry.AspNet.Tests\\Sentry.AspNet.Tests.csproj",
51+
"test\\Sentry.AspNetCore.Grpc.Tests\\Sentry.AspNetCore.Grpc.Tests.csproj",
52+
"test\\Sentry.AspNetCore.Tests\\Sentry.AspNetCore.Tests.csproj",
53+
"test\\Sentry.AspNetCore.TestUtils\\Sentry.AspNetCore.TestUtils.csproj",
54+
"test\\Sentry.Azure.Functions.Worker.Tests\\Sentry.Azure.Functions.Worker.Tests.csproj",
55+
"test\\Sentry.DiagnosticSource.IntegrationTests\\Sentry.DiagnosticSource.IntegrationTests.csproj",
56+
"test\\Sentry.DiagnosticSource.Tests\\Sentry.DiagnosticSource.Tests.csproj",
57+
"test\\Sentry.EntityFramework.Tests\\Sentry.EntityFramework.Tests.csproj",
58+
"test\\Sentry.Extensions.Logging.Tests\\Sentry.Extensions.Logging.Tests.csproj",
59+
"test\\Sentry.Google.Cloud.Functions.Tests\\Sentry.Google.Cloud.Functions.Tests.csproj",
60+
"test\\Sentry.Hangfire.Tests\\Sentry.Hangfire.Tests.csproj",
61+
"test\\Sentry.Log4Net.Tests\\Sentry.Log4Net.Tests.csproj",
62+
"test\\Sentry.NLog.Tests\\Sentry.NLog.Tests.csproj",
63+
"test\\Sentry.OpenTelemetry.Tests\\Sentry.OpenTelemetry.Tests.csproj",
64+
"test\\Sentry.Profiling.Tests\\Sentry.Profiling.Tests.csproj",
65+
"test\\Sentry.Serilog.Tests\\Sentry.Serilog.Tests.csproj",
66+
"test\\Sentry.SourceGenerators.Tests\\Sentry.SourceGenerators.Tests.csproj",
67+
"test\\Sentry.Testing.CrashableApp\\Sentry.Testing.CrashableApp.csproj",
68+
"test\\Sentry.Testing\\Sentry.Testing.csproj",
69+
"test\\Sentry.Tests\\Sentry.Tests.csproj",
70+
"test\\SingleFileTestApp\\SingleFileTestApp.csproj"
71+
]
72+
}
73+
}

integration-test/cli.Tests.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Set-StrictMode -Version Latest
33
$ErrorActionPreference = 'Stop'
44
. $PSScriptRoot/common.ps1
5+
$IsLinuxMusl = $IsLinux -and (ldd --version 2>&1) -match 'musl'
56

67
Describe 'Console apps (<framework>) - normal build' -ForEach @(
78
@{ framework = "net8.0" }
@@ -107,7 +108,7 @@ Describe 'Console apps (<framework>) - native AOT publish' -ForEach @(
107108

108109
Describe 'MAUI' -ForEach @(
109110
@{ framework = "net8.0" }
110-
) {
111+
) -Skip:$IsLinuxMusl {
111112
BeforeAll {
112113
RegisterLocalPackage 'Sentry.Android.AssemblyReader'
113114
RegisterLocalPackage 'Sentry.Bindings.Android'

integration-test/runtime.Tests.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ internal class FakeTransport : ITransport
5151
{
5252
return "./console-app/bin/Release/$framework/win-x64/publish/console-app.exe"
5353
}
54+
elseif ((ldd --version 2>&1) -match 'musl')
55+
{
56+
return "./console-app/bin/Release/$framework/linux-musl-x64/publish/console-app"
57+
}
5458
else
5559
{
5660
return "./console-app/bin/Release/$framework/linux-x64/publish/console-app"

scripts/build-sentry-native.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,14 @@ try
2929
}
3030
elseif ($IsLinux)
3131
{
32-
$outDir += '/linux-x64'
32+
if ((ldd --version 2>&1) -match 'musl')
33+
{
34+
$outDir += '/linux-musl-x64'
35+
}
36+
else
37+
{
38+
$outDir += '/linux-x64'
39+
}
3340
}
3441
else
3542
{

scripts/generate-solution-filters-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,21 @@ filterConfigs:
4949
- "**/*DeviceTests*.csproj"
5050
- "**/*Maui.Device.TestApp.csproj"
5151

52+
- outputPath: Sentry-CI-Build-Linux-musl.slnf
53+
include:
54+
groups:
55+
- "allProjects"
56+
exclude:
57+
groups:
58+
- "macOnly"
59+
- "windowsOnly"
60+
- "artefacts"
61+
- "trimTests"
62+
patterns:
63+
- "**/*Android*.csproj"
64+
- "**/*DeviceTests*.csproj"
65+
- "**/*Maui*.csproj"
66+
5267
- outputPath: Sentry-CI-Build-macOS.slnf
5368
include:
5469
groups:

src/Sentry/Platforms/Native/Sentry.Native.targets

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@
1111
<SentryNativeOutputDirectory-win-x64>$(SentryNativeOutputDirectory)$(NativeLibRelativePath-win-x64)\</SentryNativeOutputDirectory-win-x64>
1212
<NativeLibRelativePath-linux-x64>linux-x64</NativeLibRelativePath-linux-x64>
1313
<SentryNativeOutputDirectory-linux-x64>$(SentryNativeOutputDirectory)$(NativeLibRelativePath-linux-x64)\</SentryNativeOutputDirectory-linux-x64>
14+
<NativeLibRelativePath-linux-musl-x64>linux-musl-x64</NativeLibRelativePath-linux-musl-x64>
15+
<SentryNativeOutputDirectory-linux-musl-x64>$(SentryNativeOutputDirectory)$(NativeLibRelativePath-linux-musl-x64)\</SentryNativeOutputDirectory-linux-musl-x64>
1416
<NativeLibRelativePath-osx>osx</NativeLibRelativePath-osx>
1517
<SentryNativeOutputDirectory-osx>$(SentryNativeOutputDirectory)$(NativeLibRelativePath-osx)\</SentryNativeOutputDirectory-osx>
1618
<SentryNativeBuildOutputs Condition="$([MSBuild]::IsOsPlatform('Windows'))">$(SentryNativeOutputDirectory-win-x64)$(SentryNativeLibraryName).lib</SentryNativeBuildOutputs>
17-
<SentryNativeBuildOutputs Condition="$([MSBuild]::IsOsPlatform('Linux'))">$(SentryNativeOutputDirectory-linux-x64)lib$(SentryNativeLibraryName).a</SentryNativeBuildOutputs>
19+
<SentryNativeBuildOutputs Condition="'$(RuntimeIdentifier)' == 'linux-x64'">$(SentryNativeOutputDirectory-linux-x64)lib$(SentryNativeLibraryName).a</SentryNativeBuildOutputs>
20+
<SentryNativeBuildOutputs Condition="'$(RuntimeIdentifier)' == 'linux-musl-x64'">$(SentryNativeOutputDirectory-linux-musl-x64)lib$(SentryNativeLibraryName).a</SentryNativeBuildOutputs>
1821
<SentryNativeBuildOutputs Condition="$([MSBuild]::IsOsPlatform('OSX'))">$(SentryNativeOutputDirectory-osx)lib$(SentryNativeLibraryName).a</SentryNativeBuildOutputs>
1922
</PropertyGroup>
2023

@@ -32,13 +35,20 @@
3235
</None>
3336
</ItemGroup>
3437

35-
<ItemGroup Condition="'$(CI_PUBLISHING_BUILD)' == 'true' or $([MSBuild]::IsOsPlatform('Linux'))">
38+
<ItemGroup Condition="'$(CI_PUBLISHING_BUILD)' == 'true' or '$(RuntimeIdentifier)' == 'linux-x64'">
3639
<None Include="$(SentryNativeOutputDirectory-linux-x64)lib$(SentryNativeLibraryName).a">
3740
<Pack>true</Pack>
3841
<PackagePath>\sentry-native\$(NativeLibRelativePath-linux-x64)</PackagePath>
3942
</None>
4043
</ItemGroup>
4144

45+
<ItemGroup Condition="'$(CI_PUBLISHING_BUILD)' == 'true' or '$(RuntimeIdentifier)' == 'linux-musl-x64'">
46+
<None Include="$(SentryNativeOutputDirectory-linux-musl-x64)lib$(SentryNativeLibraryName).a">
47+
<Pack>true</Pack>
48+
<PackagePath>\sentry-native\$(NativeLibRelativePath-linux-musl-x64)</PackagePath>
49+
</None>
50+
</ItemGroup>
51+
4252
<ItemGroup Condition="'$(CI_PUBLISHING_BUILD)' == 'true' or $([MSBuild]::IsOsPlatform('OSX'))">
4353
<None Include="$(SentryNativeOutputDirectory-osx)lib$(SentryNativeLibraryName).a">
4454
<Pack>true</Pack>

src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@
4040
<NativeSystemLibrary Include="curl" />
4141
</ItemGroup>
4242

43+
<ItemGroup Condition="'$(FrameworkSupportsNative)' == 'true' and '$(RuntimeIdentifier)' == 'linux-musl-x64'">
44+
<DirectPInvoke Include="sentry-native" />
45+
<!-- When musl is detected, static sentry-native links to static libunwind -->
46+
<LinkerArg Include="-Wl,-Bstatic -Wl,--whole-archive -lunwind -Wl,--no-whole-archive -Wl,-Bdynamic" />
47+
<NativeSystemLibrary Include="lzma" />
48+
<NativeLibrary Include="$(MSBuildThisFileDirectory)..\sentry-native\linux-musl-x64\libsentry-native.a" />
49+
<!-- See: https://github.com/dotnet/runtime/issues/97414 -->
50+
<NativeSystemLibrary Include="curl" />
51+
</ItemGroup>
52+
4353
<ItemGroup Condition="'$(FrameworkSupportsNative)' == 'true' and ('$(RuntimeIdentifier)' == 'osx-x64' or '$(RuntimeIdentifier)' == 'osx-arm64')">
4454
<DirectPInvoke Include="sentry-native" />
4555
<NativeLibrary Include="$(MSBuildThisFileDirectory)..\sentry-native\osx\libsentry-native.a" />

0 commit comments

Comments
 (0)