Comments (10)
I think the best solution is either a cargo feature for version 1.5 (which is enabled by default to prevent from breaking semver) or a separate struct which omits the new functions. I've been wanting to update x11-dl to version 3 by generating code from the C headers, but I still have some planning to do. I'm a little worried about the compile time and generated code size of x11-dl, and I'm trying to find a solution to this as well as some other problems in the meantime.
from x11-rs.
Version 2.4 was never published to crates.io; seems like there shouldn't be any semver issue. I'm inclined to not have default features as much as possible having watched hyper/iron struggle with openssl as a default feature. Any intermediate dependencies which don't opt-out of default features force the defaults to be enabled downstream.
The separate struct is an interesting idea. It seems that gl-rs has used that idea extensively to the point that individual functions can be loaded without triggering any other dlopens.
from x11-rs.
It would be nice and ergonomic to lazily load functions as they're called from static function wrappers like you can do with gl-rs. I'm definitely considering this for version 3. I would like a way to query whether a function is available to handle cases where some are missing without having a thread panic in order to find out. This would probably make it unnecessary to even have the static bindings anymore.
from x11-rs.
There's some discussion about version based feature flags on the rust user forum with regards to ffi bindings. ilogiq suggested using a built script to set feature flags based on the available binary. Sounds like a reasonable idea here.
from x11-rs.
Since this hasn't been done in x11-rs
before, would you prefer the recently added functions to be behind a feature gate or in a separate struct?
It appears that these are the functions that have been added between the version in Ubuntu 14.04 and the current version in Arch:
- XRRAllocateMonitor
- XRRDeleteMonitor
- XRRFreeMonitors
- XRRGetMonitors
- XRRSetMonitor
from x11-rs.
I think the separate struct makes the most sense. The program can then be compiled with support for all of them, and then we can fail at runtime on systems that don't have the newer symbols.
from x11-rs.
I've opened a pull request #39, but I'd like your thoughts on it before I merge it. It's a little hacky, but it will only be a temporary solution until x11-rs
v3.
Edit: The new struct is x11_dl::xrandr::Xrandr_2_2_0
. The version number is taken from the binary version rather than the library version.
from x11-rs.
from x11-rs.
Before I go through with v3, I'd like to wait until untagged unions are available in stable Rust. But I thought of another solution to this problem that may be cleaner for v2 and wouldn't require a separate struct for Xrandr 1.4.2. A cargo feature, probably called lazy
, could be added to x11-dl
. Enabling this feature would enable lazy initialization of library functions, so they're not loaded until they're called. Unused functions would never be loaded, and this would help backwards compatibility for all X11 libraries without much added complexity. In order to keep the crate compatible with versions that have xrandr::Xrandr_2_2_0
, this can be changed to an alias of xrandr::Xrandr
. What are your thoughts on this? Do you know of any potential problems this would cause?
In addition, the library structs can have a method along the lines of xrandr.check_function("XRRAllocateMonitor")
to see if a function is available without panicking.
Edit: One potential edge case that may cause a problem is if anyone is taking the library functions by reference. Changing them to lazy functions would change them from extern
function pointers to struct methods, which would only cause problems in some weird hypothetical case.
from x11-rs.
Has this issue been resolved? I am still getting the error "undefined symbol: XRRAllocateMonitor" when creating an X11 event loop using libxrandr 1.4.2.
from x11-rs.
Related Issues (20)
- x11 vs x11-dl? HOT 3
- undefined reference to `XOpenDisplay' HOT 1
- Debug implementation for XEvent is unsound
- XCreateIC returns null incorrectly but only if another crate (tempfile) is present HOT 1
- XshmSegmentInfo can't be created and its fields should be public
- unify x11/x11-dl crates with dlib HOT 2
- Can't run test_x11 test of my lib-crate even with xlib feature enabled HOT 6
- X11 build dependency failed. HOT 3
- Xcomposite extension HOT 1
- Xdamage extension HOT 1
- How to use the Xfixes extension? HOT 7
- MacOS Support HOT 3
- I don't know how to use this struct HOT 3
- Can't load shared library on NetBSD
- Missing constant `None`? HOT 3
- Xlib::open takes up a significant amount of the binary HOT 5
- What is the difference between x11 and x11-dl? HOT 2
- Add documentation for the differences between x11 and x11-dl HOT 1
- x11-dl linker error when building musl target on Ubuntu 20.04 with rust 1.72+
- Does x11 support cross-compiling?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from x11-rs.