drm-rs icon indicating copy to clipboard operation
drm-rs copied to clipboard

Update OpenBSD support to new drm API introduced in 6.9

Open tobhe opened this issue 9 months ago • 6 comments

This makes OpenBSD work properly on my machine.

WIP because it depends on a libc change in https://github.com/rust-lang/libc/pull/4285#issuecomment-2682420476

My rust experience is rather limited so I'm looking forward to hear how this could be improved.

One potential problem I see is that devname() is not thread-safe as is because the name buffer is static. Does this need to be copied safely, guarded by a lock or marked unsafe?

tobhe avatar Feb 25 '25 17:02 tobhe

This was based on upstream libdrm, which still defines those original constants for OpenBSD to be different from the rest: https://gitlab.freedesktop.org/mesa/drm/-/blob/a7eb2cfd53a70fcd9ba9dcfad80a3994642f362f/xf86drm.h#L79-90

Any clue as to how/when this was changing, and is this PR backwards-compatible "enough"?

MarijnS95 avatar Mar 02 '25 22:03 MarijnS95

Any clue as to how/when this was changing, and is this PR backwards-compatible "enough"?

It looks like this changed in 2021 https://github.com/openbsd/xenocara/commit/9d1e1e287e6f15bd4810a2651a500918a3c54d54

OpenBSD only supports the last two releases, with one release every 6 months that means we don't need to worry (besides, breaking API and ABI across releases is not a huge issue in OpenBSD land).

tobhe avatar Mar 02 '25 23:03 tobhe

Latest push includes a few fixes based on feedback from @MarijnS95. I also added a check to handle the actual error case "??" properly. I am not convinced that buf.is_null() is actually possible here but it probably doesn't hurt to keep that check.

tobhe avatar Mar 02 '25 23:03 tobhe

One potential problem I see is that devname() is not thread-safe as is because the name buffer is static. Does this need to be copied safely, guarded by a lock or marked unsafe?

We can't really mark a function as thread-unsafe in rust, so I am afraid this would need a global lock variable.

Drakulix avatar Mar 03 '25 11:03 Drakulix

Clarified the /dev/dri node change in the commit message, changed the libc dependency to a more realistic target (if I understand their versioning right) and added a global lock for the static buffer returned by devname().

tobhe avatar Mar 03 '25 12:03 tobhe

libc with devname support is now available so I force pushed to remove the XXX comment and removed WIP in the PR title

tobhe avatar Jun 15 '25 16:06 tobhe