-
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
Add bundled feature #50
base: main
Are you sure you want to change the base?
Conversation
0ecf1ac
to
9c3ab09
Compare
9c3ab09
to
0a0836b
Compare
Hej @roblabla thanks for your contribution! We've had a similar feature in #4 but that contribution got retracted. From the top of my head
I'm not quite sure I follow regarding cross-compilcation; this is easier than building Fair word of warning; I'm afraid the last pull request didn't get much traction since I have an incomplete idea of how this feature should work and am hesistant to merge a partial solution. |
Thanks for the quick review!
Sure, that's a rather straightforward fix. Yara-rs used to do that too. Should I just make a new crate in this repo, and make a cargo workspace? New, separate repo with the source?
This choice mostly comes down to trying to reduce the necessary build-time dependencies, and my past experiences cross-compiling with autotools being painful so I tend to avoid it. Using One of the main "downsides" with the way I currently build is that I don't enable any of the optional feature. This means no decompression for instance (as that requires depending on libz, libbz2, liblzma and libzstd). I might be able to wrangle it into working though. I could certainly try using
Ah yeah, I called it vendor originally, and moved to
Yeah, currently if it's enabled it just disables everything else - hence why the warning about unreachable code. This is mostly placeholder though.
Failure seems to be due to CI not fetching the submodule. It probably needs some adjustment, I'll look into it.
Yeah, I think for now, documenting this feature as being unix-only would probably be a good idea. The vcpkg build of libmagic is heavily patched. We could reproduce that (either by vendoring a patched version, or taking the patches and applying them in the build script), but it feels like a larger maintenance burden - especially considering it requires a dependency on tre and whatnot.
So, in my use-case, I don't actually care about the default magic database - I build a custom database at build-time (in a build.rs script) that I then include in the final binary. This is in fact why I'd rather want a static library instead of a dynamic one - I want to make sure the version of libmagic used is the same at compiletime and runtime. As for whether the feature should be the default or not, I don't mind either way.
I'm working on a rather large project where we cross-compile from linux to linux-musl, macos and windows. To this end, I have a bespoke cross-compilation toolchain with lots of bells and whistles setup to make Enter libmagic, which does not offer a way to build it as part of
That's fair, and I totally understand not wanting to merge a PR without fully understanding its implication - you're the maintainer after all 😄. I personally don't really need this merged upstream - I can use a fork with this PR, so there's no rush. I do think that there would be value in working towards an upstreamable version of this PR, as it'd make libmagic more convenient to use by anyone that already has the |
Hej @roblabla I'm sorry this pull request didn't get much attention recently. I've looked into how licenses and vulnerabilities (rustsec) are usually handled for bundled C code and then got a bit sidetracked elsewhere.
The
Did you get to this? Also could you create a little doc about what needs to be checked so I or someone else can do this when updating the vendored/bundled
How would you imagine this to work, do you expect some of the decompression libraries to be available or also start bundling them?
I'm not happy about basically requiring vcpkg on Windows (I haven't really tested a GNU/MinGW setup, see #2) but at least it's sort of isolated and maintained elsewhere this way. I'd rather not drag along a bunch of patches for the bundled
Fair enough, but I guess some users of
As can be seen from the previous attempt of bundling there is some demand. The problem is that that I'm not even dogfooding the crate/s and thus any advanced build magic (heh) basically starts to bitrot right away and needs community support (of which there is little). All in all the rabbit hole of C dependencies goes deep and there doesn't seem to be much consensus on how to deal with them in the Rust sphere, so I'm not at all convinced to find a good solution for now. |
This feature allows compiling and static linking a vendored version of libmagic. This pattern is used by many other crates like rusqlite or yara-rs, and makes it much easier to use them since they don't require having the library precompiled and available. It also makes it much easier to cross-compile, as only a C compiler for the target is necessary.
The bundled version is FILE_5.45