Skip to content

Conversation

@flavioaiello
Copy link

Fix macOS EFI build: add libkrun.dylib symlink for pkg-config compatibility

Problem

When building libkrun on macOS with EFI=1, the library is installed as libkrun-efi.1.dylib, but libkrun.pc references -lkrun. This causes linking failures for consumers using pkg-config:

ld: library 'krun' not found

Affected consumers include krun-sys (the Rust FFI bindings in this repo) and any other project using pkg-config --libs libkrun.

Solution

Add a libkrun.dylib symlink pointing to libkrun-efi.1.dylib during installation when building with EFI on Darwin. This aligns the installed library with what libkrun.pc declares.

Changes

In the install: target, after the EFI library is installed:

ifeq ($(OS),Darwin)
ifeq ($(EFI),1)
	cd $(DESTDIR)$(PREFIX)/$(LIBDIR_$(OS))/ ; ln -sf libkrun-efi.$(ABI_VERSION).dylib libkrun.dylib
endif
endif

Why this approach?

  • Minimal change - Single symlink, no changes to .pc.in or krun-sys
  • Consistent with Linux - Linux uses libkrun.so; macOS now has matching libkrun.dylib
  • Standard practice - Unix library versioning commonly uses symlinks
  • Intent-preserving - The .pc file already uses libkrun as the stable API name

Testing

After this fix:

# Build and install with EFI
make EFI=1
sudo make EFI=1 install

# Verify symlink exists
ls -la /usr/local/lib/libkrun.dylib
# libkrun.dylib -> libkrun-efi.1.dylib

# pkg-config now works
pkg-config --libs libkrun
# -L/usr/local/lib -lkrun

# krun-sys builds without manual workarounds
cd krun-sys && cargo build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant