-
Notifications
You must be signed in to change notification settings - Fork 606
Bind to explicit major version of libgpiod #2090
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
Conversation
…pre-installed in the system
src/System.Device.Gpio/Interop/Unix/libgpiod/Interop.libgpiod.cs
Outdated
Show resolved
Hide resolved
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.
Looks good to me
|
I tested the behavior (with the Board sample project).
I have not tested whether libgipod2 is installed by default on a recent Raspberry Pi OS image. |
|
Thanks for testing @pgrawehr! Yeah I think the behavior you are seeing is expected, and indeed it is my believe that libgpiod2 comes installed by default in the RPI OS which is the main value that the PR is bringing. If someone would be able to validate that, it would be great and I would consider this ready to go in. |
|
Test successful on RPi4
|
|
Test failed on RPi3 with Raspbian version 'stretch'. compiled with .NET 6The package compiled with .NET 7Same app/binaries of the RPi4 test, compiled as self-contained: This error is new to me |
|
I have no other hardware boards to test on. |
|
[Triage] We should figure out if we can make it still work with libgpiod 1 |
|
The available Raspbian versions are the following (Bullseye is the first available at 64 bit)
Source: https://raspberrytips.com/raspberry-pi-os-versions/ This is the summary of my tests:
Given that the string "libgpiod.2" is a const, we have few options:
@joperezr I believe that before or later option 3 and 4 will fail again in case of a v3. What do you think? |
|
[Triage] This will be merged post 3.0 |
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.
Please review the comments
|
Sorry, catching up with this thread. I don't think there is anything wrong with us dropping stretch for newer versions of the packages. People using stretch, can always use packages from 2.x era, but for 3.x stuff we will require higher OS, and I think that is fine as long as it is well documented. Once libgpiod 3.x is available, we can then use bump to use that in our next major version release. I don't think this PR should be merged post 3.0 release, it should either be included in it, or just wait till 4.0 as it is a breaking change. We know it is breaking, and we always have, which is why we wanted to use the major version bump to take this break as we believe the overall benefits would be more than the setbacks. |
I tried to install libgpiod2 on stretch and the installation (apt i) failed. |
|
Right, what I meant here is that people using stretch can still use our System.Device.Gpio and Iot.Device.Bindings 2.x packages, which does support stretch. What I'm saying is that now that we are shipping a new major version, we can decide to drop support for stretch with the libgpiod driver (meaning potentially losing some people there and would just endup using sysfs there) in order to have much more people using libgpiod driver in newer distros (which we know this driver behaves much better than sysfs). |
|
As long as we communicate this correctly, in our release notes and package notes we can say which package is recommended depending on your base Linux distro. |
This can also be done using NativeLibrary.SetDllImport. That is, chose a well known string constant and then in the resolver try to load From the inadvertent tests in #1070, there doesn't seem to be an incompatibility in the used exports between 1 and 2 as both work fine. |
|
@joperezr I would definitely prefer to support both and not dropping the old OS just because of this. |
|
My only concerns with that approach would be perf impact, which could be mitigated by making sure we somehow cache the result so we only have to find the right version once, as opposed to having to do it for every single PInvoke. If we are able to do that, then I'm fine with closing this PR and then doing this post 3.0 release (as we wouldn't be doing a breaking change anymore so no need to tie this to a major version bump) |
|
@joperezr The work of loading a native library is O(1) with the constant being 1 ;-) |
|
We'd presumably call SetDllImportResolver in one of the static ctors? |
@krwq We can definitely use |
Or use |
|
Thanks for the suggestion @Tragetaschen I think that is a good idea for us to try. In favor of that, I'm closing this PR so that we instead can go with the NativeLibrary load approach. @Tragetaschen given you are familiar to how all of that works, would you be willing to contribute a PR to achieve this 😃? |
|
Under different circumstances, I would gladly go ahead, but I changed jobs a couple of years back and don't have any embedded platform to run and test code on. |
|
Understood, appreciate the guidance and I hope you'd be okay if we tag you on the PR once we have it ready in case you have a chance to do a quick review. FWIW, looks like runtime is attempting to do something super similar due to the exact same problem but with a different native library, and they have a PR open to fix this dotnet/runtime#88851 so we can use that as guidance. |
Fixes #1070
cc: @rafal-mz @Ellerbach @krwq @pgrawehr
Things that I need help with for testing this:
libgpiod-devpackageMicrosoft Reviewers: Open in CodeFlow