Skip to content

WIP: fix: support musl on Linux #4182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 15 commits into from
Closed
3 changes: 3 additions & 0 deletions .github/actions/environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ runs:

# Needed for Android SDK setup step
- uses: actions/setup-java@v3
if: ${{ !matrix.container }}
with:
distribution: 'temurin'
java-version: '17'

- name: Setup Android SDK
if: ${{ !matrix.container }}
uses: android-actions/setup-android@07976c6290703d34c16d382cb36445f98bb43b1f # v3.2.0
with:
log-accepted-android-sdk-licenses: false
Expand All @@ -41,6 +43,7 @@ runs:
cd -

- name: Set Java Version
if: ${{ !matrix.container }}
uses: actions/setup-java@v3
with:
distribution: 'temurin'
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/freediskspace/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ runs:
if: runner.os == 'Linux'
shell: bash
run: |
df -h /dev/root
df -h / # df: /dev/root: can't find mount point
sudo rm -rf /usr/local/.ghcup
sudo rm -rf /usr/local/julia1.10.5
sudo rm -rf /usr/lib/heroku
Expand All @@ -32,4 +32,4 @@ runs:
sudo apt-get remove -y '^mysql-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^mysql-.*' --fix-missing] failed to complete successfully. Proceeding..."
sudo apt-get autoremove -y || echo "::warning::The command [sudo apt-get autoremove -y] failed to complete successfully. Proceeding..."
sudo apt-get clean || echo "::warning::The command [sudo apt-get clean] failed to complete successfully. Proceeding..."
df -h /dev/root
df -h / # df: /dev/root: can't find mount point
70 changes: 48 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,20 @@ on:

jobs:
build-sentry-native:
name: sentry-native (${{ matrix.os }})
name: sentry-native (${{ matrix.container || matrix.os }})
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
strategy:
fail-fast: false
matrix:
# Pin ubuntu to ensure mono is installed
# Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703
os: [ubuntu-22.04, windows-latest, macos-15]
include:
- os: ubuntu-22.04 # Pin ubuntu to ensure mono is installed
target: Linux
- os: ubuntu-latest
container: ghcr.io/jpnurmi/alpine:3.19 # TODO: getsentry
target: Linux-musl
- os: windows-latest
- os: macos-15 # Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703

steps:
- name: Checkout
Expand All @@ -30,14 +36,14 @@ jobs:
id: cache
with:
path: src/Sentry/Platforms/Native/sentry-native
key: sentry-native-${{ runner.os }}-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
key: sentry-native-${{ matrix.target || runner.os }}-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
enableCrossOsArchive: true

- name: Remove unused applications
uses: ./.github/actions/freediskspace

- name: Install build dependencies
if: steps.cache.outputs.cache-hit != 'true' && runner.os == 'Linux'
if: steps.cache.outputs.cache-hit != 'true' && runner.os == 'Linux' && !matrix.container
run: |
sudo apt update
sudo apt install libcurl4-openssl-dev
Expand All @@ -48,15 +54,21 @@ jobs:

build:
needs: build-sentry-native
name: .NET (${{ matrix.os }})
name: .NET (${{ matrix.container || matrix.os }})
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}

strategy:
fail-fast: false
matrix:
# Pin ubuntu to ensure mono is installed
# Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703
os: [ubuntu-22.04, windows-latest, macos-15]
include:
- os: ubuntu-22.04 # Pin ubuntu to ensure mono is installed
target: Linux
- os: ubuntu-latest
container: ghcr.io/jpnurmi/alpine:3.21 # TODO: getsentry
target: Linux-musl
- os: windows-latest
- os: macos-15 # Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703

steps:
- name: Cancel Previous Runs
Expand All @@ -78,13 +90,21 @@ jobs:
run: echo "CI_PUBLISHING_BUILD=true" >> $GITHUB_ENV

- name: Download sentry-native (Linux)
if: ${{ (env.CI_PUBLISHING_BUILD == 'true') || (runner.os == 'Linux') }}
if: ${{ (env.CI_PUBLISHING_BUILD == 'true') || (matrix.target == 'Linux') }}
uses: actions/cache/restore@v4
with:
path: src/Sentry/Platforms/Native/sentry-native
key: sentry-native-Linux-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
fail-on-cache-miss: true

- name: Download sentry-native (Linux musl)
if: ${{ (env.CI_PUBLISHING_BUILD == 'true') || (matrix.target == 'Linux-musl') }}
uses: actions/cache/restore@v4
with:
path: src/Sentry/Platforms/Native/sentry-native
key: sentry-native-Linux-musl-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
fail-on-cache-miss: true

- name: Download sentry-native (macOS)
if: ${{ (env.CI_PUBLISHING_BUILD == 'true') || (runner.os == 'macOS') }}
uses: actions/cache/restore@v4
Expand All @@ -106,24 +126,25 @@ jobs:
uses: ./.github/actions/environment

- name: Build Native Dependencies
if: ${{ !matrix.container }}
uses: ./.github/actions/buildnative

- name: Restore .NET Dependencies
run: dotnet restore Sentry-CI-Build-${{ runner.os }}.slnf --nologo
run: dotnet restore Sentry-CI-Build-${{ matrix.target || runner.os }}.slnf --nologo

- name: Build
id: build
run: dotnet build Sentry-CI-Build-${{ runner.os }}.slnf -c Release --no-restore --nologo -v:minimal -flp:logfile=build.log -p:CopyLocalLockFileAssemblies=true -bl:build.binlog
run: dotnet build Sentry-CI-Build-${{ matrix.target || runner.os }}.slnf -c Release --no-restore --nologo -v:minimal -flp:logfile=build.log -p:CopyLocalLockFileAssemblies=true -bl:build.binlog

- name: Upload build logs
if: ${{ steps.build.outcome != 'skipped' }}
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-build-logs
name: ${{ matrix.target || runner.os }}-build-logs
path: build.binlog

- name: Test
run: dotnet test Sentry-CI-Build-${{ runner.os }}.slnf -c Release --no-build --nologo -l GitHubActions -l "trx;LogFilePrefix=testresults_${{ runner.os }}" --collect "XPlat Code Coverage"
run: dotnet test Sentry-CI-Build-${{ matrix.target || runner.os }}.slnf -c Release --no-build --nologo -l GitHubActions -l "trx;LogFilePrefix=testresults_${{ runner.os }}" --collect "XPlat Code Coverage"

- name: Upload code coverage
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d
Expand All @@ -132,14 +153,14 @@ jobs:
if: failure()
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-verify-test-results
name: ${{ matrix.target || runner.os }}-verify-test-results
path: "**/*.received.*"

# To save time and disk space, we only create and archive the Nuget packages when we're actually releasing.

- name: Create Nuget Packages
if: env.CI_PUBLISHING_BUILD == 'true'
run: dotnet pack Sentry-CI-Build-${{ runner.os }}.slnf -c Release --no-build --nologo
run: dotnet pack Sentry-CI-Build-${{ matrix.target || runner.os }}.slnf -c Release --no-build --nologo

- name: Archive Nuget Packages
if: env.CI_PUBLISHING_BUILD == 'true'
Expand All @@ -153,15 +174,20 @@ jobs:

integration-test:
needs: build
name: Integration test (${{ matrix.os }})
name: Integration test (${{ matrix.container || matrix.os }})
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}

strategy:
fail-fast: false
matrix:
# Pin ubuntu to ensure mono is installed
# Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703
os: [ubuntu-22.04, windows-latest, macos-15]
include:
- os: ubuntu-22.04 # Pin ubuntu to ensure mono is installed
- os: ubuntu-latest
container: ghcr.io/jpnurmi/alpine:3.21 # TODO: getsentry
target: Linux-musl
- os: windows-latest
- os: macos-15 # Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703

steps:
- uses: actions/checkout@v4
Expand All @@ -180,7 +206,7 @@ jobs:
path: src

- name: Install build dependencies
if: runner.os == 'Linux'
if: runner.os == 'Linux' && !matrix.container
run: |
sudo apt update
sudo apt install libcurl4-openssl-dev
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Redact Authorization headers before sending events to Sentry ([#4164](https://github.com/getsentry/sentry-dotnet/pull/4164))
- Remove Strong Naming from Sentry.Hangfire ([#4099](https://github.com/getsentry/sentry-dotnet/pull/4099))
- Increase `RequestSize.Small` threshold from 1 kB to 4 kB to match other SDKs ([#4177](https://github.com/getsentry/sentry-dotnet/pull/4177))
- Support musl on Linux ([#4182](https://github.com/getsentry/sentry-dotnet/pull/4182))

### Features

Expand Down
74 changes: 74 additions & 0 deletions Sentry-CI-Build-Linux-musl.slnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"solution": {
"path": ".generated.NoMobile.sln",
"projects": [
"benchmarks\\Sentry.Benchmarks\\Sentry.Benchmarks.csproj",
"samples\\Sentry.Samples.AspNetCore.Basic\\Sentry.Samples.AspNetCore.Basic.csproj",
"samples\\Sentry.Samples.AspNetCore.Blazor.Server\\Sentry.Samples.AspNetCore.Blazor.Server.csproj",
"samples\\Sentry.Samples.AspNetCore.Blazor.Wasm\\Sentry.Samples.AspNetCore.Blazor.Wasm.csproj",
"samples\\Sentry.Samples.AspNetCore.Grpc\\Sentry.Samples.AspNetCore.Grpc.csproj",
"samples\\Sentry.Samples.AspNetCore.Mvc\\Sentry.Samples.AspNetCore.Mvc.csproj",
"samples\\Sentry.Samples.AspNetCore.Serilog\\Sentry.Samples.AspNetCore.Serilog.csproj",
"samples\\Sentry.Samples.AspNetCore.WebAPI.Profiling\\Sentry.Samples.AspNetCore.WebAPI.Profiling.csproj",
"samples\\Sentry.Samples.Aws.Lambda.AspNetCoreServer\\Sentry.Samples.Aws.Lambda.AspNetCoreServer.csproj",
"samples\\Sentry.Samples.Azure.Functions.Worker\\Sentry.Samples.Azure.Functions.Worker.csproj",
"samples\\Sentry.Samples.Console.Basic\\Sentry.Samples.Console.Basic.csproj",
"samples\\Sentry.Samples.Console.Customized\\Sentry.Samples.Console.Customized.csproj",
"samples\\Sentry.Samples.Console.HeapDump\\Sentry.Samples.Console.HeapDump.csproj",
"samples\\Sentry.Samples.Console.Native\\Sentry.Samples.Console.Native.csproj",
"samples\\Sentry.Samples.Console.Profiling\\Sentry.Samples.Console.Profiling.csproj",
"samples\\Sentry.Samples.EntityFramework\\Sentry.Samples.EntityFramework.csproj",
"samples\\Sentry.Samples.GenericHost\\Sentry.Samples.GenericHost.csproj",
"samples\\Sentry.Samples.Google.Cloud.Functions\\Sentry.Samples.Google.Cloud.Functions.csproj",
"samples\\Sentry.Samples.GraphQL.Client.Http\\Sentry.Samples.GraphQL.Client.Http.csproj",
"samples\\Sentry.Samples.GraphQL.Server\\Sentry.Samples.GraphQL.Server.csproj",
"samples\\Sentry.Samples.Hangfire\\Sentry.Samples.Hangfire.csproj",
"samples\\Sentry.Samples.Log4Net\\Sentry.Samples.Log4Net.csproj",
"samples\\Sentry.Samples.ME.Logging\\Sentry.Samples.ME.Logging.csproj",
"samples\\Sentry.Samples.NLog\\Sentry.Samples.NLog.csproj",
"samples\\Sentry.Samples.OpenTelemetry.AspNetCore\\Sentry.Samples.OpenTelemetry.AspNetCore.csproj",
"samples\\Sentry.Samples.OpenTelemetry.Console\\Sentry.Samples.OpenTelemetry.Console.csproj",
"samples\\Sentry.Samples.Serilog\\Sentry.Samples.Serilog.csproj",
"src\\Sentry.Analyzers\\Sentry.Analyzers.csproj",
"src\\Sentry.AspNet\\Sentry.AspNet.csproj",
"src\\Sentry.AspNetCore.Blazor.WebAssembly\\Sentry.AspNetCore.Blazor.WebAssembly.csproj",
"src\\Sentry.AspNetCore.Grpc\\Sentry.AspNetCore.Grpc.csproj",
"src\\Sentry.AspNetCore\\Sentry.AspNetCore.csproj",
"src\\Sentry.Azure.Functions.Worker\\Sentry.Azure.Functions.Worker.csproj",
"src\\Sentry.DiagnosticSource\\Sentry.DiagnosticSource.csproj",
"src\\Sentry.EntityFramework\\Sentry.EntityFramework.csproj",
"src\\Sentry.Extensions.Logging\\Sentry.Extensions.Logging.csproj",
"src\\Sentry.Google.Cloud.Functions\\Sentry.Google.Cloud.Functions.csproj",
"src\\Sentry.Hangfire\\Sentry.Hangfire.csproj",
"src\\Sentry.Log4Net\\Sentry.Log4Net.csproj",
"src\\Sentry.NLog\\Sentry.NLog.csproj",
"src\\Sentry.OpenTelemetry\\Sentry.OpenTelemetry.csproj",
"src\\Sentry.Profiling\\Sentry.Profiling.csproj",
"src\\Sentry.Serilog\\Sentry.Serilog.csproj",
"src\\Sentry.SourceGenerators\\Sentry.SourceGenerators.csproj",
"src\\Sentry\\Sentry.csproj",
"test\\Sentry.Analyzers.Tests\\Sentry.Analyzers.Tests.csproj",
"test\\Sentry.AspNet.Tests\\Sentry.AspNet.Tests.csproj",
"test\\Sentry.AspNetCore.Grpc.Tests\\Sentry.AspNetCore.Grpc.Tests.csproj",
"test\\Sentry.AspNetCore.Tests\\Sentry.AspNetCore.Tests.csproj",
"test\\Sentry.AspNetCore.TestUtils\\Sentry.AspNetCore.TestUtils.csproj",
"test\\Sentry.Azure.Functions.Worker.Tests\\Sentry.Azure.Functions.Worker.Tests.csproj",
"test\\Sentry.DiagnosticSource.IntegrationTests\\Sentry.DiagnosticSource.IntegrationTests.csproj",
"test\\Sentry.DiagnosticSource.Tests\\Sentry.DiagnosticSource.Tests.csproj",
"test\\Sentry.EntityFramework.Tests\\Sentry.EntityFramework.Tests.csproj",
"test\\Sentry.Extensions.Logging.Tests\\Sentry.Extensions.Logging.Tests.csproj",
"test\\Sentry.Google.Cloud.Functions.Tests\\Sentry.Google.Cloud.Functions.Tests.csproj",
"test\\Sentry.Hangfire.Tests\\Sentry.Hangfire.Tests.csproj",
"test\\Sentry.Log4Net.Tests\\Sentry.Log4Net.Tests.csproj",
"test\\Sentry.NLog.Tests\\Sentry.NLog.Tests.csproj",
"test\\Sentry.OpenTelemetry.Tests\\Sentry.OpenTelemetry.Tests.csproj",
"test\\Sentry.Profiling.Tests\\Sentry.Profiling.Tests.csproj",
"test\\Sentry.Serilog.Tests\\Sentry.Serilog.Tests.csproj",
"test\\Sentry.SourceGenerators.Tests\\Sentry.SourceGenerators.Tests.csproj",
"test\\Sentry.Testing.CrashableApp\\Sentry.Testing.CrashableApp.csproj",
"test\\Sentry.Testing\\Sentry.Testing.csproj",
"test\\Sentry.Tests\\Sentry.Tests.csproj",
"test\\SingleFileTestApp\\SingleFileTestApp.csproj"
]
}
}
2 changes: 1 addition & 1 deletion modules/sentry-native
Submodule sentry-native updated 59 files
+63 −0 .github/workflows/benchmark.yml
+37 −3 .github/workflows/ci.yml
+3 −0 .gitmodules
+20 −1 CHANGELOG.md
+38 −2 CMakeLists.txt
+16 −0 CONTRIBUTING.md
+5 −1 Makefile
+10 −0 README.md
+22 −1 examples/example.c
+1 −0 external/benchmark
+1 −1 external/crashpad
+36 −1 include/sentry.h
+1 −1 ndk/gradle.properties
+1 −1 sentry-config.cmake.in
+7 −1 src/CMakeLists.txt
+6 −4 src/path/sentry_path.c
+17 −3 src/path/sentry_path_unix.c
+10 −0 src/screenshot/sentry_screenshot_windows.c
+1 −1 src/sentry_alloc.c
+38 −1 src/sentry_core.c
+6 −0 src/sentry_core.h
+1 −1 src/sentry_database.c
+3 −3 src/sentry_json.c
+5 −5 src/sentry_logger.c
+15 −0 src/sentry_options.c
+5 −0 src/sentry_options.h
+2 −2 src/sentry_os.c
+8 −2 src/sentry_scope.c
+1 −0 src/sentry_scope.h
+17 −0 src/sentry_tracing.c
+9 −6 src/sentry_utils.c
+6 −0 src/sentry_utils.h
+40 −0 src/sentry_value.c
+35 −2 src/transports/sentry_transport_curl.c
+4 −0 src/unwinder/sentry_unwinder.c
+47 −0 src/unwinder/sentry_unwinder_libunwind.c
+25 −6 tests/assertions.py
+55 −0 tests/benchmark.py
+53 −0 tests/benchmark/CMakeLists.txt
+44 −0 tests/benchmark/benchmark_backend.cpp
+14 −0 tests/benchmark/benchmark_init.cpp
+2 −0 tests/cmake.py
+90 −0 tests/conftest.py
+9 −3 tests/test_integration_crashpad.py
+230 −5 tests/test_integration_http.py
+4 −1 tests/unit/test_basic.c
+9 −0 tests/unit/test_failures.c
+3 −1 tests/unit/test_fuzzfailures.c
+1 −1 tests/unit/test_modulefinder.c
+1 −1 tests/unit/test_mpack.c
+3 −2 tests/unit/test_path.c
+1 −1 tests/unit/test_symbolizer.c
+262 −14 tests/unit/test_tracing.c
+1 −1 tests/unit/test_unwinder.c
+2 −2 tests/unit/test_utils.c
+43 −1 tests/unit/test_value.c
+6 −0 tests/unit/tests.inc
+1 −1 tests/win_utils.py
+19 −4 vendor/acutest.h
9 changes: 8 additions & 1 deletion scripts/build-sentry-native.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ try
}
elseif ($IsLinux)
{
$outDir += '/linux-x64'
if ((ldd --version 2>&1) -match 'musl')
{
$outDir += '/linux-musl-x64'
}
else
{
$outDir += '/linux-x64'
}
}
else
{
Expand Down
17 changes: 17 additions & 0 deletions scripts/generate-solution-filters-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,20 @@ filterConfigs:
- "**/*Bindings*"
- "**/*DeviceTests*"
- "**/*TestApp*"

# WIP: SentryNoMobile.slnf minus *Mac* for testing Linux musl CI w/o Android
- outputPath: Sentry-CI-Build-Linux-musl.slnf
solution: .generated.NoMobile.sln
include:
groups:
- "allProjects"
exclude:
groups:
- "artefacts"
- "trimTests"
patterns:
- "**/*Bindings*.csproj"
- "**/*Android*.csproj"
- "**/*Ios*.csproj"
- "**/*Mac*.csproj"
- "**/*Maui*.csproj"
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
<NativeLibrary Include="Gdi32.lib" />
</ItemGroup>

<ItemGroup Condition="'$(FrameworkSupportsNative)' == 'true' and '$(RuntimeIdentifier)' == 'linux-x64'">
<ItemGroup Condition="'$(FrameworkSupportsNative)' == 'true' and ('$(RuntimeIdentifier)' == 'linux-x64' or '$(RuntimeIdentifier)' == 'linux-musl-x64')">
<DirectPInvoke Include="sentry-native" />
<NativeLibrary Include="$(MSBuildThisFileDirectory)..\sentry-native\linux-x64\libsentry-native.a" />
<NativeLibrary Include="$(MSBuildThisFileDirectory)..\sentry-native\$(RuntimeIdentifier)\libsentry-native.a" />
<!-- See: https://github.com/dotnet/runtime/issues/97414 -->
<NativeSystemLibrary Include="curl" />
</ItemGroup>
Expand Down
Loading