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

Add wayland-dlopen feature switch #75

Merged
merged 1 commit into from
Jun 22, 2024

Conversation

liferooter
Copy link
Contributor

This feature controls whether to load libwayland at runtime using dlopen instead of linking with it.

Before this commit the library always used dlopen.

This feature controls whether to load libwayland at runtime using dlopen
instead of linking with it.
@chrisduerr
Copy link
Member

Could you elaborate on the motivation?

@liferooter
Copy link
Contributor Author

liferooter commented Jun 22, 2024

dlopen-based library loading is used for X11 and Wayland because in any real case only one of these backends is used, but the choice is done at runtime and can be different even between multiple runs on the same machine. So many X11/Wayland-related Rust crates use dlopen to load backend libraries (technically there are not so many basic crates that do that and other just depend on them). This is a pretty convenient way, I can have only X11 on my machine and no Wayland and its libraries. But in reality this strategy is not as perfect as it seems:

  • In fact I always have libwayland and libX11 in my Linux-based system because most of the applications and libraries doesn't use dlopen and just link with both of them.
  • It makes dependency tracking much harder.
  • It works only if there's a single directory for all the libraries, which is not always the case. For example, there's a Nix package manager and NixOS Linux distro based on it which places every application into its own directory in /nix/store and every application's dependencies are also pinned to some particular directories at /nix/store, so libraries are never placed inside some single directory for libraries. On NixOS this dlopen strategy gives no advantages just because it doesn't work. If an application requires libwayland and libX11 in some cases, I need the application to depend on them both, or repackage and reconfigure it every time manually. Of course I always can use some wrapper that will pass these libraries by LD_LIBRARY_PATH environment variable, but why should I use some feature and then bypass it using hacks?

As you can see, dlopen-based library loading can be useful in some situations, but still not the only one and the right solution for all cases. That's why most of the libraries which use it allows a feature switch to disable it if needed. I think this library should do that too.

@chrisduerr chrisduerr merged commit 0bea1d8 into alacritty:master Jun 22, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants