[libvirt PATCH 151/351] meson: src: build libvirt.syms and libvirt.def symbol files

Pavel Hrdina phrdina at redhat.com
Thu Jul 16 09:56:27 UTC 2020


Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
 m4/virt-win-symbols.m4     |  3 --
 src/Makefile.am            | 53 +--------------------------
 src/access/Makefile.inc.am | 22 -----------
 src/access/meson.build     | 14 +++++++
 src/esx/Makefile.inc.am    |  7 ----
 src/esx/meson.build        |  6 +++
 src/meson.build            | 75 ++++++++++++++++++++++++++++++++++++++
 src/openvz/Makefile.inc.am |  7 ----
 src/openvz/meson.build     |  6 +++
 src/remote/Makefile.inc.am |  6 ---
 src/remote/meson.build     |  6 +++
 src/vmware/Makefile.inc.am |  7 ----
 src/vmware/meson.build     |  6 +++
 src/vmx/Makefile.inc.am    |  7 ----
 src/vmx/meson.build        |  6 +++
 15 files changed, 120 insertions(+), 111 deletions(-)
 delete mode 100644 src/esx/Makefile.inc.am
 delete mode 100644 src/openvz/Makefile.inc.am
 delete mode 100644 src/vmware/Makefile.inc.am
 delete mode 100644 src/vmx/Makefile.inc.am

diff --git a/m4/virt-win-symbols.m4 b/m4/virt-win-symbols.m4
index eba5596e4b4..f7b8e612a8d 100644
--- a/m4/virt-win-symbols.m4
+++ b/m4/virt-win-symbols.m4
@@ -18,7 +18,6 @@ dnl <http://www.gnu.org/licenses/>.
 dnl
 
 AC_DEFUN([LIBVIRT_WIN_CHECK_SYMBOLS], [
-  LIBVIRT_SYMBOL_FILE=libvirt.syms
   LIBVIRT_ADMIN_SYMBOL_FILE=admin/libvirt_admin.syms
   LIBVIRT_LXC_SYMBOL_FILE='$(srcdir)/libvirt_lxc.syms'
   LIBVIRT_QEMU_SYMBOL_FILE='$(srcdir)/libvirt_qemu.syms'
@@ -27,13 +26,11 @@ AC_DEFUN([LIBVIRT_WIN_CHECK_SYMBOLS], [
       # Also set the symbol file to .def, so src/Makefile generates libvirt.def
       # from libvirt.syms and passes libvirt.def instead of libvirt.syms to the
       # linker
-      LIBVIRT_SYMBOL_FILE=libvirt.def
       LIBVIRT_ADMIN_SYMBOL_FILE=admin/libvirt_admin.def
       LIBVIRT_LXC_SYMBOL_FILE=libvirt_lxc.def
       LIBVIRT_QEMU_SYMBOL_FILE=libvirt_qemu.def
       ;;
   esac
-  AC_SUBST([LIBVIRT_SYMBOL_FILE])
   AC_SUBST([LIBVIRT_ADMIN_SYMBOL_FILE])
   AC_SUBST([LIBVIRT_LXC_SYMBOL_FILE])
   AC_SUBST([LIBVIRT_QEMU_SYMBOL_FILE])
diff --git a/src/Makefile.am b/src/Makefile.am
index b0990e94ec1..3ad565f7775 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -74,11 +74,7 @@ include access/Makefile.inc.am
 include logging/Makefile.inc.am
 include locking/Makefile.inc.am
 include admin/Makefile.inc.am
-include esx/Makefile.inc.am
-include vmx/Makefile.inc.am
-include vmware/Makefile.inc.am
 include vbox/Makefile.inc.am
-include openvz/Makefile.inc.am
 include qemu/Makefile.inc.am
 include bhyve/Makefile.inc.am
 include libxl/Makefile.inc.am
@@ -218,9 +214,8 @@ check-local: check-protocol check-symfile check-symsorting \
 # All .syms files should be placed in exactly one of these three lists,
 # depending on whether they are stored in git and/or used in the build.
 SYM_FILES += $(USED_SYM_FILES)
-USED_SYM_FILES += $(srcdir)/libvirt_private.syms
 GENERATED_SYM_FILES += \
-	libvirt.syms libvirt.def libvirt_qemu.def libvirt_lxc.def \
+	libvirt_qemu.def libvirt_lxc.def \
 	$(NULL)
 
 
@@ -242,52 +237,6 @@ check-augeas: $(augeas_DATA) $(augeastest_DATA)
 AUG_GENTEST_SCRIPT = $(top_srcdir)/scripts/augeas-gentest.py
 AUG_GENTEST = $(RUNUTF8) $(PYTHON) $(AUG_GENTEST_SCRIPT)
 
-
-#
-# Build our version script.  This is composed of three parts:
-#
-# 1. libvirt_public.syms - public API.  These functions are always
-# present in the library and should never change incompatibly.
-#
-# 2. libvirt_private.syms - private API.  These symbols are private and
-# semantics may change on every release, hence the version number is
-# spliced in at build time. This ensures that if libvirtd, virsh, or a
-# driver module was built against one libvirt release, it will refuse to
-# load with another where symbols may have same names but different
-# semantics. Such symbols should never be visible in an (installed)
-# public header file.
-#
-# 3. libvirt_*.syms - dynamic private API.  Like libvirt_private.syms,
-# except that build options (such as --enable-debug) can mean these
-# symbols aren't present at all.
-#
-
-USED_SYM_FILES += $(srcdir)/libvirt_driver_modules.syms
-
-if WITH_LINUX
-USED_SYM_FILES += $(srcdir)/libvirt_linux.syms
-else ! WITH_LINUX
-SYM_FILES += $(srcdir)/libvirt_linux.syms
-endif ! WITH_LINUX
-
-if WITH_SASL
-USED_SYM_FILES += $(srcdir)/libvirt_sasl.syms
-else ! WITH_SASL
-SYM_FILES += $(srcdir)/libvirt_sasl.syms
-endif ! WITH_SASL
-
-if WITH_SSH2
-USED_SYM_FILES += $(srcdir)/libvirt_libssh2.syms
-else ! WITH_SSH2
-SYM_FILES += $(srcdir)/libvirt_libssh2.syms
-endif ! WITH_SSH2
-
-if WITH_LIBSSH
-USED_SYM_FILES += $(srcdir)/libvirt_libssh.syms
-else ! WITH_LIBSSH
-SYM_FILES += $(srcdir)/libvirt_libssh.syms
-endif ! WITH_LIBSSH
-
 # Empty source list - it merely links a bunch of convenience libs together
 libvirt_la_SOURCES =
 libvirt_la_LDFLAGS = \
diff --git a/src/access/Makefile.inc.am b/src/access/Makefile.inc.am
index da9b5ef31b3..bd1d51dd777 100644
--- a/src/access/Makefile.inc.am
+++ b/src/access/Makefile.inc.am
@@ -1,11 +1,5 @@
 # vim: filetype=automake
 
-ACCESS_DRIVER_SYM_FILES = \
-	libvirt_access.syms \
-	libvirt_access_qemu.syms \
-	libvirt_access_lxc.syms \
-	$(NULL)
-
 ACCESS_DRIVER_API_FILES = \
 	libvirt_access.xml \
 	libvirt_access_qemu.xml \
@@ -14,8 +8,6 @@ ACCESS_DRIVER_API_FILES = \
 
 ACCESS_DRIVER_POLKIT_POLICY = access/org.libvirt.api.policy
 
-GENERATED_SYM_FILES += $(ACCESS_DRIVER_SYM_FILES)
-
 libvirt_la_BUILT_LIBADD += libvirt_driver_access.la
 
 $(ACCESS_DRIVER_POLKIT_POLICY): $(srcdir)/access/viraccessperm.h \
@@ -31,20 +23,6 @@ polkitaction_DATA = $(ACCESS_DRIVER_POLKIT_POLICY)
 endif WITH_LIBVIRTD
 endif ! WITH_POLKIT
 
-
-libvirt_access.syms: $(srcdir)/rpc/gendispatch.pl \
-			$(REMOTE_PROTOCOL) Makefile.am
-	$(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl --mode=aclsym \
-	  remote REMOTE $(REMOTE_PROTOCOL) > $@
-libvirt_access_qemu.syms: $(srcdir)/rpc/gendispatch.pl \
-			$(QEMU_PROTOCOL) Makefile.am
-	$(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl --mode=aclsym \
-	  qemu QEMU $(QEMU_PROTOCOL) > $@
-libvirt_access_lxc.syms: $(srcdir)/rpc/gendispatch.pl \
-			$(LXC_PROTOCOL) Makefile.am
-	$(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl --mode=aclsym \
-	  lxc LXC $(LXC_PROTOCOL) > $@
-
 libvirt_access.xml: $(srcdir)/rpc/gendispatch.pl \
 			$(REMOTE_PROTOCOL) Makefile.am
 	$(AM_V_GEN)$(PERL) -w $(srcdir)/rpc/gendispatch.pl --mode=aclapi \
diff --git a/src/access/meson.build b/src/access/meson.build
index c5784fa4a98..dc962166873 100644
--- a/src/access/meson.build
+++ b/src/access/meson.build
@@ -13,14 +13,17 @@ remote_path = meson.source_root() / 'src' / 'remote'
 
 access_gen_headers = []
 access_gen_sources = []
+access_gen_sym = []
 
 foreach name : [ 'remote', 'qemu', 'lxc' ]
   if name == 'remote'
     header_file = 'viraccessapicheck.h'
     source_file = 'viraccessapicheck.c'
+    syms_file = 'libvirt_access.syms'
   else
     header_file = 'viraccessapicheck at 0@.h'.format(name)
     source_file = 'viraccessapicheck at 0@.c'.format(name)
+    syms_file = 'libvirt_access_ at 0@.syms'.format(name)
   endif
   protocol_file = remote_path / '@0 at _protocol.x'.format(name)
 
@@ -42,6 +45,15 @@ foreach name : [ 'remote', 'qemu', 'lxc' ]
     ],
     capture: true,
   )
+
+  access_gen_sym += custom_target(
+    syms_file,
+    output: syms_file,
+    capture: true,
+    command: [
+      gendispatch_prog, '--mode=aclsym', name, name.to_upper(), protocol_file,
+    ]
+  )
 endforeach
 
 if conf.has('WITH_POLKIT')
@@ -70,3 +82,5 @@ access_dep = declare_dependency(
   include_directories: access_inc_dir,
   sources: access_gen_headers,
 )
+
+generated_sym_files += access_gen_sym
diff --git a/src/esx/Makefile.inc.am b/src/esx/Makefile.inc.am
deleted file mode 100644
index 2e776d1ebec..00000000000
--- a/src/esx/Makefile.inc.am
+++ /dev/null
@@ -1,7 +0,0 @@
-# vim: filetype=automake
-
-if WITH_ESX
-USED_SYM_FILES += $(srcdir)/libvirt_esx.syms
-else ! WITH_ESX
-SYM_FILES += $(srcdir)/libvirt_esx.syms
-endif ! WITH_ESX
diff --git a/src/esx/meson.build b/src/esx/meson.build
index 6d7e2311bff..08d8a542498 100644
--- a/src/esx/meson.build
+++ b/src/esx/meson.build
@@ -55,3 +55,9 @@ if conf.has('WITH_ESX')
     ],
   )
 endif
+
+if conf.has('WITH_ESX')
+  used_sym_files += 'libvirt_esx.syms'
+else
+  sym_files += 'libvirt_esx.syms'
+endif
diff --git a/src/meson.build b/src/meson.build
index 753d93253ea..257cdbe4090 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -76,6 +76,44 @@ if conf.has('WITH_DTRACE_PROBES')
 endif
 
 
+# symbol files
+
+public_sym_file = 'libvirt_public.syms'
+
+used_sym_files = [
+  'libvirt_private.syms',
+  'libvirt_driver_modules.syms',
+]
+
+generated_sym_files = []
+
+sym_files = []
+
+if host_machine.system() == 'linux'
+  used_sym_files += 'libvirt_linux.syms'
+else
+  sym_files += 'libvirt_linux.syms'
+endif
+
+if conf.has('WITH_SASL')
+  used_sym_files += 'libvirt_sasl.syms'
+else
+  sym_files += 'libvirt_sasl.syms'
+endif
+
+if conf.has('WITH_LIBSSH')
+  used_sym_files += 'libvirt_libssh.syms'
+else
+  sym_files += 'libvirt_libssh.syms'
+endif
+
+if conf.has('WITH_SSH2')
+  used_sym_files += 'libvirt_libssh2.syms'
+else
+  sym_files += 'libvirt_libssh2.syms'
+endif
+
+
 # list subdirectories
 
 subdir('util')
@@ -140,3 +178,40 @@ driver_lib = static_library(
     conf_inc_dir,
   ],
 )
+
+
+# symbol files for libvirt.so
+
+# Build our version script.  This is composed of three parts:
+#
+# 1. libvirt_public.syms - public API.  These functions are always
+# present in the library and should never change incompatibly.
+#
+# 2. libvirt_private.syms - private API.  These symbols are private and
+# semantics may change on every release, hence the version number is
+# spliced in at build time. This ensures that if libvirtd, virsh, or a
+# driver module was built against one libvirt release, it will refuse to
+# load with another where symbols may have same names but different
+# semantics. Such symbols should never be visible in an (installed)
+# public header file.
+#
+# 3. libvirt_*.syms - dynamic private API.  Like libvirt_private.syms,
+# except that build options (such as --enable-debug) can mean these
+# symbols aren't present at all.
+
+libvirt_syms = custom_target(
+  'libvirt.syms',
+  input: [ public_sym_file ] + used_sym_files + generated_sym_files,
+  output: 'libvirt.syms',
+  command: [ gen_sym_files_prog, 'LIBVIRT_PRIVATE_' + meson.project_version(), '@INPUT@' ],
+  capture: true,
+)
+if host_machine.system() == 'windows'
+  libvirt_def = custom_target(
+    'libvirt.def',
+    input: libvirt_syms,
+    output: 'libvirt.def',
+    command: [ gen_def_files_prog, '@INPUT@' ],
+    capture: true,
+  )
+endif
diff --git a/src/openvz/Makefile.inc.am b/src/openvz/Makefile.inc.am
deleted file mode 100644
index c01e33124ac..00000000000
--- a/src/openvz/Makefile.inc.am
+++ /dev/null
@@ -1,7 +0,0 @@
-# vim: filetype=automake
-
-if WITH_OPENVZ
-USED_SYM_FILES += $(srcdir)/libvirt_openvz.syms
-else ! WITH_OPENVZ
-SYM_FILES += $(srcdir)/libvirt_openvz.syms
-endif ! WITH_OPENVZ
diff --git a/src/openvz/meson.build b/src/openvz/meson.build
index b4e3befccb5..427b25fed1c 100644
--- a/src/openvz/meson.build
+++ b/src/openvz/meson.build
@@ -18,3 +18,9 @@ if conf.has('WITH_OPENVZ')
     ],
   )
 endif
+
+if conf.has('WITH_OPENVZ')
+  used_sym_files += 'libvirt_openvz.syms'
+else
+  sym_files += 'libvirt_openvz.syms'
+endif
diff --git a/src/remote/Makefile.inc.am b/src/remote/Makefile.inc.am
index 1dff8ec67e1..421f7337217 100644
--- a/src/remote/Makefile.inc.am
+++ b/src/remote/Makefile.inc.am
@@ -127,12 +127,6 @@ REMOTE_DRIVER_PROTOCOL = \
 	$(LXC_PROTOCOL) \
 	$(NULL)
 
-if WITH_REMOTE
-USED_SYM_FILES += $(srcdir)/libvirt_remote.syms
-else ! WITH_REMOTE
-SYM_FILES += $(srcdir)/libvirt_remote.syms
-endif ! WITH_REMOTE
-
 if WITH_LIBVIRTD
 
 sbin_PROGRAMS += libvirtd virtproxyd
diff --git a/src/remote/meson.build b/src/remote/meson.build
index 383b265ea21..f029edefd7e 100644
--- a/src/remote/meson.build
+++ b/src/remote/meson.build
@@ -57,3 +57,9 @@ if conf.has('WITH_REMOTE')
     ],
   )
 endif
+
+if conf.has('WITH_REMOTE')
+  used_sym_files += 'libvirt_remote.syms'
+else
+  sym_files += 'libvirt_remote.syms'
+endif
diff --git a/src/vmware/Makefile.inc.am b/src/vmware/Makefile.inc.am
deleted file mode 100644
index 125e0304618..00000000000
--- a/src/vmware/Makefile.inc.am
+++ /dev/null
@@ -1,7 +0,0 @@
-# vim: filetype=automake
-
-if WITH_VMWARE
-USED_SYM_FILES += $(srcdir)/libvirt_vmware.syms
-else ! WITH_VMWARE
-SYM_FILES += $(srcdir)/libvirt_vmware.syms
-endif ! WITH_VMWARE
diff --git a/src/vmware/meson.build b/src/vmware/meson.build
index 285cc5eb9a3..dc2a32a1610 100644
--- a/src/vmware/meson.build
+++ b/src/vmware/meson.build
@@ -16,3 +16,9 @@ if conf.has('WITH_VMWARE')
     ],
   )
 endif
+
+if conf.has('WITH_VMWARE')
+  used_sym_files += 'libvirt_vmware.syms'
+else
+  sym_files += 'libvirt_vmware.syms'
+endif
diff --git a/src/vmx/Makefile.inc.am b/src/vmx/Makefile.inc.am
deleted file mode 100644
index 8912f6ee21c..00000000000
--- a/src/vmx/Makefile.inc.am
+++ /dev/null
@@ -1,7 +0,0 @@
-# vim: filetype=automake
-
-if WITH_VMX
-USED_SYM_FILES += $(srcdir)/libvirt_vmx.syms
-else ! WITH_VMX
-SYM_FILES += $(srcdir)/libvirt_vmx.syms
-endif ! WITH_VMX
diff --git a/src/vmx/meson.build b/src/vmx/meson.build
index 8bed1fac9fa..25e3d1a6fca 100644
--- a/src/vmx/meson.build
+++ b/src/vmx/meson.build
@@ -18,3 +18,9 @@ if conf.has('WITH_VMX')
 endif
 
 vmx_inc_dir = include_directories('.')
+
+if conf.has('WITH_VMX')
+  used_sym_files += 'libvirt_vmx.syms'
+else
+  sym_files += 'libvirt_vmx.syms'
+endif
-- 
2.26.2




More information about the libvir-list mailing list