Skip to content
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

feat: linux musl detection #502

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Sep 24, 2024

  1. feat: linux-musl runtime support

    ## Rationale
    
    pact-reference has introduced musl and arm64 based ffi libraries for linux
    
    - pact-foundation/pact-reference#416
    
    Tracking Issue
    
    - pact-foundation/roadmap#30
    
    ## Issues Resolved
    
    fixes pact-foundation#498
    fixes pact-foundation#496
    fixes pact-foundation#500
    fixes pact-foundation#374
    fixes pact-foundation#387
    
    ## Backwards Compatibility
    
    Linux glibc based hosts take precedence, so if any error occurs during musl
    detection. I do not anticipate breaking changes for users
    
    ## Implementation notes
    
    ### .NET notes
    
    - Docs
      - [Uses MSBuild Exec task](https://learn.microsoft.com/en-us/visualstudio/msbuild/exec-task?view=vs-2022)
    - MSBuild Blog Posts
      - [Cross-Platform Build Events in .NET Core using MSBuild](https://jeremybytes.blogspot.com/2020/05/cross-platform-build-events-in-net-core.html)
      - [MSBuild 101: Using the exit code from a command](https://www.creepingcoder.com/2020/06/01/msbuild-101-using-the-exit-code-from-a-command/)
    - Stack OverFlow
      - [Set PropertyGroup property to Exec output](https://stackoverflow.com/questions/76583824/set-propertygroup-property-to-exec-output)
    - .NET runtime musl detection code
      - https://github.com/dotnet/runtime/blob/a50ba0669353893ca8ade8568b0a7d210b5a425f/src/mono/llvm/llvm-init.proj\#L7
      - https://github.com/dotnet/runtime/blob/a50ba0669353893ca8ade8568b0a7d210b5a425f/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs\#L78t
    
    ### Conditions for execution
    
    musl detection will run if
    
    - if linux
    - if /lib/ld-musl-(x86_64|aarch64).so.1 exists
    - if ldd bin/sh | grep musl is true (musl lib is loaded, rather than glibc)
    
    will continue on error, reverting back to glibc based libaries.
    
    ### Supported musl targets
    
    should work for multiple musl based distroes if
    
    - /lib/ld-musl-(x86_64|aarch64).so.1 exists
    - ldd is available (available by default in alpine images)
    
    Tested on Alpine ARM64 / AMD64.
    YOU54F committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    a41c667 View commit details
    Browse the repository at this point in the history