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

API for libgpiod has changed in v2 #2842

Open
jasonKercher opened this issue Jan 9, 2024 · 4 comments
Open

API for libgpiod has changed in v2 #2842

jasonKercher opened this issue Jan 9, 2024 · 4 comments

Comments

@jasonKercher
Copy link

Here are the steps I follow to reproduce the issue:

  1. Have libgpiod version >= 2
  2. Attempt to compile linuxcnc v 2.9.2

This is what I expected to happen:

Build succeeds

This is what happened instead:

In file included from hal/drivers/hal_gpio.c:39:
hal/drivers/hal_gpio.c:188:50: error: invalid application of ‘sizeof’ to incomplete type ‘struct gpiod_line_bulk’
  188 |             (*ptr)[c].bulk = rtapi_kmalloc(sizeof(*(*ptr)[c].bulk), RTAPI_GFP_KERNEL);

...along with lots of warnings for implicit declarations of functions (due to API change).

It worked properly before this:

libgpiod version <= 1.6.4

Information about my hardware and software:

  • I am using Manjaro. I know that is not officially supported, but we do keep a working linuxcnc package over there.
    Manjaro is part of the Arch Linux family, so we always have the bleeding edge latest software. I imagine this will not be an issue on Debian for some time.
  • Linux Kernel Version 6.1.66
  • Linux CNC v2.9.2
@andypugh
Copy link
Collaborator

andypugh commented Jan 9, 2024

This was something that I knew was coming, and that I don't really know how to solve.

libgpiod is a mess, for example libgpiod2 is still v1.6, not 2.

There are no packages in Debian for libgpiod v2, with the new API, so I decided this was a problem that can be kicked down the road until at least after Trixie (which still has v1.6) https://packages.debian.org/search?suite=trixie&searchon=names&keywords=libgpiod

There is probably something horribly messy that can be done with conditional compilation, or a wrapper API.

I am not even 100% sure that libgpiod has a 1:1 mapping between v1.x and v2.x functions.

The libgpiod developers were keen that I should code for v2, but with no packages available from Debian, how would our users get it? We can host the packages on our own repository, but that isn't a fix for folk installing LinuxCNC from the main Debian mirrors.

@FabioLolix
Copy link

Hello, on the AUR making a pkgbuild for libgpiod v1.6.4 installed in /opt/libgpiod-1.6.4 (or something similar) so it doesn't conflicts with the system's one isn't a problem

How I could pass that to autogen.sh or ./configure ?

@andypugh
Copy link
Collaborator

andypugh commented Jan 9, 2024

As I knew this was coming somewhere down the line, ./configure does set an environment variable containing the version:
https://github.com/LinuxCNC/linuxcnc/blob/master/src/configure.ac#L535
Currently it is only used to detect the presence of the library:
https://github.com/LinuxCNC/linuxcnc/blob/master/src/Makefile#L1006
But I suppose, in theory, it could be used to compile a completely different source file into the same module (with the same Linuxcnc-side API)

@FabioLolix
Copy link

btw https://github.com/pikvm/ustreamer updated to build with libgpiod 2.0.x while also working with the older version seems, the 2 relevant commits:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants