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

Dynamic loading of libdrm and libdrm_amdgpu #438

Merged

Conversation

Umio-Yasuno
Copy link
Contributor

libdrm_amdgpu_sys 0.8.0 supports dynamic loading.
Now LACT supports GPUs from multiple vendors, so dynamic loading would be better.

@Umio-Yasuno Umio-Yasuno marked this pull request as draft January 4, 2025 00:04
@Umio-Yasuno Umio-Yasuno marked this pull request as ready for review January 4, 2025 03:26
@ilya-zlobintsev
Copy link
Owner

ilya-zlobintsev commented Jan 4, 2025

Dynamic loading would make sense, though it is not a requirement as libdrm is something that is usually present on every system, even when using nvidia proprietary drivers.

However, I have one concern with this: what are the backwards compatibility guarantees of the libdrm API? Could the symbols change or be removed in an update? Currently this would lead to a link-time error, which is easier to catch than a runtime one when a function symbol fails to load (or even worse, have the wrong signature).

match LibDrmAmdgpu::new() {
Ok(libdrm_amdgpu) => {
info!("libdrm and libdrm_amdgpu initialized");
Some(Rc::new(libdrm_amdgpu))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe this needs to be wrapped in an Rc, as LibDrmAmdgpu is a cloneable struct with Arcs internally: https://github.com/Umio-Yasuno/libdrm-amdgpu-sys-rs/blob/main/lib.rs#L75

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

af7aecc

@Umio-Yasuno
Copy link
Contributor Author

Dynamic loading would make sense, though it is not a requirement as libdrm is something that is usually present on every system, even when using nvidia proprietary drivers.

For users who only use NVIDIA GPUs, there is less need to be concerned about libdrm_amdgpu by dynamic loading.

However, I have one concern with this: what are the backwards compatibility guarantees of the libdrm API? Could the symbols change or be removed in an update? Currently this would lead to a link-time error, which is easier to catch than a runtime one when a function symbol fails to load (or even worse, have the wrong signature).

Runtime errors can probably occur with dynamic linking, even if not dynamic loading.
Umio-Yasuno/amdgpu_top#17

@ilya-zlobintsev
Copy link
Owner

I'll merge this as is since it turns out the mismatched header problem is already a possibility before this PR, but I would like to continue the discussion in Umio-Yasuno/libdrm-amdgpu-sys-rs#9

@ilya-zlobintsev ilya-zlobintsev merged commit 3afbcb2 into ilya-zlobintsev:master Jan 4, 2025
4 of 27 checks passed
@Umio-Yasuno Umio-Yasuno deleted the dynamic-loading-of-libdrm branch January 4, 2025 13:54
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

Successfully merging this pull request may close these issues.

2 participants