Skip to content

Missing pkg-config name transforms (for libarchive, libcrypto, etc) #13551

@TheZeus121

Description

@TheZeus121

Zig Version

0.11.0-dev.174+d823680e1

Steps to Reproduce and Observed Behavior

Add linkSystemLibrary("archive") to build.zig. Observe that Zig just adds -larchive without any -L or -I flags (it actually doesn't call pkg-config --cflags --libs) so it fails if libarchive is installed to a non-standard path.

Now replace that with linkSystemLibrary("libarchive") and pkg-config gets called properly but if you remove pkg-config, you get -llibarchive which doesn't work.

Expected Behavior

For linkSystemLibrary("archive") to call pkg-config --cflags --libs libarchive.

linkSystemLibraryPkgConfigOnly("libarchive") is not a solution because if libarchive is installed in a standard location it should still be linkable without pkg-config, but currently there is no portable way to do this without checking if pkg-config is in PATH in build.zig.


Currently lib/std/build.zig's runPkgConfig doesn't support the following "transform kinds" I've seen in the wild (on Homebrew and on Debian):

  • -larchive -> pkg-config libarchive
  • -lrsvg-2 -> pkg-config librsvg-2.0
  • -lxml2 -> pkg-config libxml-2.0

Aside from libxml2, it seems it should be possible to go through the checks that are in place already just also check them for names with added "lib" prefix.


I'd tackle this issue myself but I don't feel like learning how to compile zig from source tonight 🙈

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorzig build systemstd.Build, the build runner, `zig build` subcommand, package management

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions