-
Notifications
You must be signed in to change notification settings - Fork 232
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
Add linux-musl-x64 runtime support #497
base: master
Are you sure you want to change the base?
Add linux-musl-x64 runtime support #497
Conversation
src/PactNet/PactNet.csproj
Outdated
<Link>libpact_ffi.so</Link> | ||
<PackagePath>runtimes/linux-musl-x64/native</PackagePath> | ||
<Pack>true</Pack> | ||
<CopyToOutputDirectory Condition="'$(IsLinux)'">PreserveNewest</CopyToOutputDirectory> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs an additional condition to only unpack on musl targets, which last time I tried to do this wasn't possible.
The libc and musl versions are both just called libpact_ffi.so and so their names conflict and it's unclear which one you actually get.
If you get the musl version where previously you get the libc version then this is a breaking change.
It's the same reason why the Mac version has two conditions below, so you don't end up with the ARM version on x86 and vice versa.
The CI additionally would need updating to test the new target |
Nice, I had a go at this myself as part of a mission to bring alpine/musl support to the Pact ecosystem - see linked issue master...YOU54F:pact-net:feat/musl added a gh test in the branch, tried to test arm64 under qemu but no 🎲 master...YOU54F:pact-net:feat/trimmed_binaries There still doesn't seem to be a nice way to detect musl via .NET I used a file system lookup for the musl shared lib, which varies on the arch of the target, and I've only tested against alpine based images. From looking at a few different languages, most tend to For rust based executables, (not the pact_ffi shared libs), we are beginning to roll out the building of them statically with musl, rather than glibc, so we can support a single executable for all linux users. Unfortunatly, we cannot do that with the ffi libs in languages that read on the shared, not static libs (PHP, .NET, Ruby) |
Yep that was the same problem I had when I originally raised a PR for this and had to abandon it @YOU54F. There doesn't seem to be a reliable way to determine libc vs musl at NuGet restore time to make sure the correct shared library is unpacked, and if you get the wrong one it just won't work with no real workaround. That would be a disaster for existing users, hence why we need extensive CI for that situation. It's got to be totally reliable and it can't break existing libc distros, and that's where the problem lies. |
It may be more pragmatic on Alpine to install something like https://github.com/Stantheman/gcompat to provide glibc compatibility so that the existing shared library will work, although I've not tested that. |
Unfortunately, |
Refactored the project to use runtime specific native packages as shown at https://github.com/Mizux/dotnet-native.
The On Alpine
Output:
On Debian
Output:
Is this approach worth pursuing? |
PactNet used to have architecture specific packages but a key design goal of the major changes in 4.x was to move away from this approach. In practice it's very awkward to use for consumers - for example if you run the tests locally on Windows/Mac but your CI runs in Linux (as is very common) then you've got to reference multiple native packages and add conditions to your dependencies, which is a bad devex. I don't see the cost of reintroducing all the complexity both within PactNet and especially for our users being worth adding musl support. At the end of the day this is a test library, so it's much less of a burden to run your tests in a glibc env instead, until such a time that detecting running on musl is more robust and can use the existing packaging mechanism. It may be worth you creating an issue on the .Net team to add a feature to make detecting musl easier. It's definitely not an easy task to do really robustly though. Like even just detecting certain heuristics is hard because of things like cross compilation envs. |
There's only need to reference a single package,
Some teams prefer to run tests on the exact same platform with exactly the same dependencies as what gets deployed to production. Exceptions could be made, and contract tests could be run on a sperate platform, but that adds extra complexity to the CI pipeline. |
Possible solution for #496