alexcrichton / xz2-rs

Bindings to liblzma in Rust (xz streams in Rust)
Apache License 2.0
81 stars 52 forks source link

Detection of system-provided liblzma fails on FreeBSD #125

Open UnitedMarsupials opened 3 months ago

UnitedMarsupials commented 3 months ago

Modern FreeBSD-releases come with liblzma (and xz) included in the base system (along with libz and libbz2), but it is not detected by the lzma-sys/build.rs -- presumably because there is no matching pkg-config files for it.

It cannot be difficult to fix, but I cannot figure it out myself :(

UnitedMarsupials commented 3 months ago

Simply removing the pkg_config::probe_library call like this:

--- vendor/lzma-sys/build.rs    2023-12-04 16:32:19.000000000 -0500
+++ vendor/lzma-sys/build.rs    2023-12-11 18:09:40.320258000 -0500
@@ -19,5 +19,5 @@
     // Otherwise check the system to see if it has an lzma library already
     // installed that we can use.
-    if !want_static && !msvc && pkg_config::probe_library("liblzma").is_ok() {
+    if !want_static && !msvc {
         return;
     }

"works" in that the included xz-5.2 sources are ignored -- as they should be. But the build fails later, when linking something, that actually needs LZMA-functions.

How do I change the build.rs so that adds -lzma to the linker command-line of everything, that wants LZMA-functions? Some kind of ldflags.append('-lzma') before return-ing?

UnitedMarsupials commented 3 months ago

Matter of fact, even if want_static is true, the system-provided /usr/lib/liblzma.a should be used...