-
Notifications
You must be signed in to change notification settings - Fork 6
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
Features for libmagic
API changes
#16
Conversation
After staring at that Windows build failure from runs/3969370194 for a while, I believe these are the problems:
Due to the Yet when we inspect the output of
Those seem to be coming from microsoft/vcpkg ports/libmagic/vcpkg.json Looking at the
No The build can be "fixed" by adding the following to println!("cargo:rustc-link-lib=shlwapi"); But that is not the right place. Looking at file/file src/Makefile.am we see:
The
Thus I believe there are 2 upstream issues:
I believe this didn't surface earlier with vcpkg since there was no test with all linked symbols. |
According to https://repology.org/project/file/cves the
That might be motivation to drop support for old (API) versions sooner than later. |
Regarding feature flag names, see gdesmott/system-deps#18 Feature names could be changed later, but that'd be a semver breaking change. |
This adds crate features named "libmagic-abi-v5??" for each change in the v5
libmagic
API/ABI.In general, the API seems to be backwards compatible by only adding new functionality.
The use case for this is supporting both old and new versions of the
libmagic
API, depending on the user setup.Currently no effort is made to identify the version of
libmagic
that is being linked against. If symbols are undefined, a linker error will occur. If linking works, there might still be slight API differences.It would probably be possible to indirectly identify versions by their symbols and defines, but this seems unclean.
Upstream seems to have switched to
autotools
and added a#define MAGIC_VERSION
in v5.13.The
libmagic.pc
was only added in v5.39, see #1Slightly unrelated changes:
cargo fmt
, no enforcement via CIcargo clippy
have been fixed, no enforcement via CI#define
s have mostly been added as constants, so they can be used from e.g. themagic
cratecargo test
tests were added to ensure linking with the feature gated symbols worksMagic
struct has been fixed according to the 'nomicon and now mostly matches whatbindgen
would emitLeftover TODOs for myself:
docs.rs
libmagic
needs to be (any) version 5, update doc for Clarify requirements #5magic
cratemagic-sys
crate release (candidate?)Misc notes:
file-5.00
seems to be from 2009-02-03, that should be sufficiently old to support even ancient systemsfile-5.41
is the latest considered version from 2021-10-18 and according to e.g. https://repology.org/project/file/badges has not even made it to all package managersdefault
feature should probably select a little older API version, given that otherwise crate compilation/linkage might fail on most systems currently, see previous bullet point