bytecodealliance / bytecodealliance/wasmtime

Include `pkg-config` support

Open
#13,611 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
18.6k
Forks
1.8k
Avg merge
1d 18h
Merged PRs (30d)
126

Description

I propose including **pkg-config** support.

Many software repositories vending C libraries have support for `pkg-config` by generating a `*.pc` file (during the build configuration phase, when installation paths become known), which significantly improves discoverability of the C library, as well as improves interoperability with other build systems.

#### Feature

Including **pkg-config** support means producing a `wasmtime.pc` file as part of each release. The `wasmtime.pc` would be used in conjunction with the `pkg-config` tool to streamline C API usage and would contain all necessary information like the include path, the library path, and the library to be linked with.

#### Benefit

- Wasmtime exposes a stable C embedding API via `wasmtime.h` and `libwasmtime.dylib`, which at the moment aren't easy to integrate into build processes without custom environment configuration.
- Build systems like **SwiftPM**, **Meson**, **Autotools**, **CMake**, and many others can consume libraries through `pkg-config`.
#### Implementation

I created a separate [homebrew](https://brew.sh) formula that depends on the existing `wasmtime` formula and generates the `wasmtime.pc` file. I was going to create a pull request for [homebrew-core.git](https://github.com/homebrew/homebrew-core), but having the build process generate the `wasmtime.pc` file seems like a better approach.

Here's the source code of my homebrew formula for reference (I tentatively named it **libwasmtime** for disambiguation purposes).

[libwasmtime.rb.txt](https://github.com/user-attachments/files/28834279/libwasmtime.rb.txt)

#### Alternatives

Alternatively, the ruby code that generates the `wasmtime.pc` file inside the `install` function of my homebrew formula could be copied into `wasmtime.rb`, making the existing wasmtime homebrew formula install the `wasmtime.pc` file.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.