From cb0edd43548f222b4ba62b48468ef38b103436f6 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Fri, 20 Dec 2019 11:29:44 +0100 Subject: [PATCH] build: use split stringlist functions from common/utils The OCaml and Python bindings directly use the utils.c source in common/utils, mostly for guestfs_int_free_string_list. That source contained also functions using gnulib functions, however without linking to gnulib. When building with default build flags (e.g. without as-needed mode), the gnulib symbols cannot be resolved, leading to unusable OCaml and Python libraries. As solution, update the common submodule to get the split of the split of the stringlist functions in common/utils, and adapt the OCaml and Python bindings: - both now use stringlists-utils.c instead of utils.c - fix the Python distutils setup to include only the sources really needed --- .gitignore | 9 ++------- common | 2 +- generator/python.ml | 2 +- ocaml/Makefile.am | 2 +- python/MANIFEST.in | 6 +----- python/Makefile.am | 45 ++++++++++----------------------------------- python/setup.py.in | 2 +- 7 files changed, 17 insertions(+), 51 deletions(-) diff --git a/.gitignore b/.gitignore index 7efd9b907..1abb1c8b7 100644 --- a/.gitignore +++ b/.gitignore @@ -451,9 +451,6 @@ Makefile.in /python/actions.h /python/bindtests.py /python/build -/python/c-ctype.h -/python/cleanups.c -/python/cleanups.h /python/config.h /python/dist /python/examples/guestfs-python.3 @@ -461,17 +458,15 @@ Makefile.in /python/guestfs.py /python/guestfs.pyc /python/guestfs.pyo -/python/guestfs-internal-all.h -/python/guestfs-utils.h -/python/ignore-value.h +/python/guestfs-stringlists-utils.h /python/MANIFEST /python/module.c +/python/stringlists-utils.c /python/structs.c /python/__pycache__ /python/setup.py /python/stamp-extra-files /python/t/tests_helper.py -/python/utils.c /rescue/stamp-virt-rescue.pod /rescue/virt-rescue /rescue/virt-rescue.1 diff --git a/common b/common index 4c57e0b76..9c247a10e 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 4c57e0b7693e0617f50ece734e8a1afc626c8304 +Subproject commit 9c247a10e6faba8f1774361aff10815ffcb6d800 diff --git a/generator/python.ml b/generator/python.ml index e436f4bda..821c66755 100644 --- a/generator/python.ml +++ b/generator/python.ml @@ -42,7 +42,7 @@ let rec generate_python_actions_h () = #define GUESTFS_PYTHON_ACTIONS_H_ #include \"guestfs.h\" -#include \"guestfs-utils.h\" +#include \"guestfs-stringlists-utils.h\" #define PY_SSIZE_T_CLEAN 1 diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index b31e8fc65..c85efee64 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -94,7 +94,7 @@ libguestfsocaml_a_SOURCES = \ guestfs-c-actions.c \ guestfs-c-errnos.c \ ../common/utils/cleanups.c \ - ../common/utils/utils.c + ../common/utils/stringlists-utils.c if HAVE_OCAMLDOC diff --git a/python/MANIFEST.in b/python/MANIFEST.in index 9de894c3c..979f99233 100644 --- a/python/MANIFEST.in +++ b/python/MANIFEST.in @@ -16,9 +16,5 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. include actions.h -include c-ctype.h -include cleanups.h include config.h -include guestfs-internal-all.h -include guestfs-utils.h -include ignore-value.h +include guestfs-stringlists-utils.h diff --git a/python/Makefile.am b/python/Makefile.am index c2f57a6ba..b470d2df2 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -63,7 +63,8 @@ libguestfsmod_la_SOURCES = \ actions.h \ handle.c \ module.c \ - structs.c + structs.c \ + ../common/utils/stringlists-utils.c libguestfsmod_la_CPPFLAGS = \ -DGUESTFS_PRIVATE=1 \ @@ -75,7 +76,6 @@ libguestfsmod_la_CFLAGS = \ $(WARN_CFLAGS) $(WERROR_CFLAGS) libguestfsmod_la_LIBADD = \ - $(top_builddir)/common/utils/libutils_la-utils.lo \ $(top_builddir)/lib/libguestfs.la libguestfsmod_la_LDFLAGS = -avoid-version -shared -module -shrext $(PYTHON_EXT_SUFFIX) @@ -97,39 +97,19 @@ setup-install: setup.py stamp-extra-files # Python's crappy MANIFEST file cannot graft single files, so we have # to hard-link any extra files we need into the local directory. stamp-extra-files: \ - c-ctype.h \ - cleanups.c \ - cleanups.h \ config.h \ - guestfs-internal-all.h \ - guestfs-utils.h \ - ignore-value.h \ - utils.c + guestfs-stringlists-utils.h \ + stringlists-utils.c touch $@ config.h: ln ../config.h $@ -c-ctype.h: - ln $(top_srcdir)/gnulib/lib/c-ctype.h $@ +guestfs-stringlists-utils.h: + ln $(top_srcdir)/common/utils/guestfs-stringlists-utils.h $@ -cleanups.c: - ln $(top_srcdir)/common/utils/cleanups.c $@ - -cleanups.h: - ln $(top_srcdir)/common/utils/cleanups.h $@ - -ignore-value.h: - ln $(top_srcdir)/gnulib/lib/ignore-value.h $@ - -guestfs-internal-all.h: - ln $(top_srcdir)/lib/guestfs-internal-all.h $@ - -guestfs-utils.h: - ln $(top_srcdir)/common/utils/guestfs-utils.h $@ - -utils.c: - ln $(top_srcdir)/common/utils/utils.c $@ +stringlists-utils.c: + ln $(top_srcdir)/common/utils/stringlists-utils.c $@ # Tests. @@ -148,15 +128,10 @@ CLEANFILES += \ *.pyc \ examples/*~ examples/*.pyc \ t/*~ t/*.pyc \ - c-ctype.h \ config.h \ - cleanups.c \ - cleanups.h \ - guestfs-internal-all.h \ - guestfs-utils.h \ - ignore-value.h \ + guestfs-stringlists-utils.h \ stamp-extra-files \ - utils.c + stringlists-utils.c clean-local: rm -rf build dist __pycache__ t/__pycache__ diff --git a/python/setup.py.in b/python/setup.py.in index 079920d0e..0c8cff13b 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -62,7 +62,7 @@ This package contains the Python bindings for libguestfs. 'handle.c', 'module.c', 'structs.c', - 'utils.c'], + 'stringlists-utils.c'], include_dirs=['.', '../lib'], libraries=['guestfs'],