Skip to content
This repository was archived by the owner on May 24, 2026. It is now read-only.

Commit 7afbd81

Browse files
authored
Merge pull request #4 from velopack/claude/fix-msi-dll-linking-80klg
Statically link msi-interop on Linux (no system deps when P/Invoked)
2 parents 6986e63 + 24205cf commit 7afbd81

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

meson.build

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ if host_machine.system() == 'windows'
3030
endif
3131

3232
# --- libxml2 ---
33-
if host_machine.system() == 'darwin'
34-
# Build from source on macOS — Homebrew doesn't provide a static libxml2.a
33+
# Build from source on macOS (Homebrew doesn't ship static libxml2.a) and
34+
# Linux (Alpine's libxml2.a isn't compiled with -fPIC, so it can't be embedded
35+
# into a shared object like libmsi-interop.so).
36+
if host_machine.system() == 'darwin' or host_machine.system() == 'linux'
3537
cc = meson.get_compiler('c')
3638

3739
xml2_version_config = configuration_data()
@@ -440,12 +442,20 @@ msi_interop_sources = [
440442

441443
msi_interop_inc = include_directories('msi-interop')
442444

445+
msi_interop_deps = [glib, gio, gobject, libxml, zlib]
446+
msi_interop_link_with = []
447+
msi_interop_link_args = libmsi_shared_link_args
448+
443449
if host_machine.system() == 'linux'
444-
msi_interop_deps = libmsi_shared_deps
445-
msi_interop_link_with = []
446-
else
447-
msi_interop_deps = [glib, gio, gobject, libxml, zlib]
448-
msi_interop_link_with = []
450+
# Statically embed all dependencies into libmsi-interop.so so it has no
451+
# runtime system library dependencies (other than libc) when loaded via
452+
# P/Invoke from C#. This requires PIC-compiled static libs.
453+
# libeconf provides econf_* symbols required by libblkid (transitive dep
454+
# of glib's gio static link).
455+
msi_interop_link_with += [libeconf]
456+
msi_interop_link_args += [
457+
'-Wl,--exclude-libs,ALL',
458+
]
449459
endif
450460

451461
msi_interop_shared = shared_library('msi-interop',
@@ -455,7 +465,7 @@ msi_interop_shared = shared_library('msi-interop',
455465
include_directories: [inc_dirs, gsf_inc_dirs, gcab_inc_dirs, msi_interop_inc],
456466
dependencies: msi_interop_deps,
457467
link_with: msi_interop_link_with,
458-
link_args: libmsi_shared_link_args,
468+
link_args: msi_interop_link_args,
459469
gnu_symbol_visibility: 'hidden',
460470
)
461471

0 commit comments

Comments
 (0)