@@ -30,8 +30,10 @@ if host_machine.system() == 'windows'
3030endif
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
441443msi_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+
443449if 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+ ]
449459endif
450460
451461msi_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