Pino Toscano
2019-May-28 08:25 UTC
[Libguestfs] [PATCH] build: build C sources using OCaml API with CAML_NAME_SPACE
This way no non-namespaced OCaml C symbols are used, reducing the risk of clashes with other code. The only exception is ocaml-augeas, which does not build with CAML_NAME_SPACE; it will be fixed upstream, and it affects only ocaml-augeas itself. --- builder/Makefile.am | 2 ++ common/mllibvirt/Makefile.am | 1 + common/mlpcre/Makefile.am | 1 + common/mlprogress/Makefile.am | 1 + common/mltools/Makefile.am | 1 + common/mlutils/Makefile.am | 1 + common/mlvisit/Makefile.am | 1 + common/mlxml/Makefile.am | 1 + customize/Makefile.am | 1 + daemon/Makefile.am | 2 ++ ocaml/Makefile.am | 1 + v2v/Makefile.am | 2 ++ 12 files changed, 15 insertions(+) diff --git a/builder/Makefile.am b/builder/Makefile.am index b564fadd6..c7caec5cb 100644 --- a/builder/Makefile.am +++ b/builder/Makefile.am @@ -135,6 +135,7 @@ bin_PROGRAMS += virt-builder virt-builder-repository virt_builder_SOURCES = $(SOURCES_C) virt_builder_CPPFLAGS = \ + -DCAML_NAME_SPACE \ -I$(builddir) -I$(srcdir) \ -I$(top_builddir) \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ @@ -156,6 +157,7 @@ XOBJECTS = $(BOBJECTS:.cmo=.cmx) virt_builder_repository_SOURCES = $(REPOSITORY_SOURCES_C) virt_builder_repository_CPPFLAGS = \ + -DCAML_NAME_SPACE \ -I$(builddir) -I$(srcdir) \ -I$(top_builddir) \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ diff --git a/common/mllibvirt/Makefile.am b/common/mllibvirt/Makefile.am index 12e046c35..181cb9c5c 100644 --- a/common/mllibvirt/Makefile.am +++ b/common/mllibvirt/Makefile.am @@ -59,6 +59,7 @@ noinst_DATA = $(MLLIBVIRT_CMA) libmllibvirt_a_SOURCES = $(SOURCES_C) libmllibvirt_a_CPPFLAGS = \ + -DCAML_NAME_SPACE \ -I. \ -I$(top_builddir) \ -I$(shell $(OCAMLC) -where) diff --git a/common/mlpcre/Makefile.am b/common/mlpcre/Makefile.am index 6f04256da..1e0b7795c 100644 --- a/common/mlpcre/Makefile.am +++ b/common/mlpcre/Makefile.am @@ -49,6 +49,7 @@ noinst_DATA = $(MLPCRE_CMA) libmlpcre_a_SOURCES = $(SOURCES_C) libmlpcre_a_CPPFLAGS = \ + -DCAML_NAME_SPACE \ -I. \ -I$(top_builddir) \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ diff --git a/common/mlprogress/Makefile.am b/common/mlprogress/Makefile.am index 9c5ef9baf..d807f6cc8 100644 --- a/common/mlprogress/Makefile.am +++ b/common/mlprogress/Makefile.am @@ -50,6 +50,7 @@ noinst_DATA = $(MLPROGRESS_CMA) libmlprogress_a_SOURCES = $(SOURCES_C) libmlprogress_a_CPPFLAGS = \ + -DCAML_NAME_SPACE \ -I. \ -I$(top_builddir) \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ diff --git a/common/mltools/Makefile.am b/common/mltools/Makefile.am index ae78b84b7..ba8630033 100644 --- a/common/mltools/Makefile.am +++ b/common/mltools/Makefile.am @@ -87,6 +87,7 @@ noinst_DATA = $(MLTOOLS_CMA) libmltools_a_SOURCES = $(SOURCES_C) libmltools_a_CPPFLAGS = \ + -DCAML_NAME_SPACE \ -I. \ -I$(top_builddir) \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ diff --git a/common/mlutils/Makefile.am b/common/mlutils/Makefile.am index 45f401268..e86d7bb5f 100644 --- a/common/mlutils/Makefile.am +++ b/common/mlutils/Makefile.am @@ -54,6 +54,7 @@ noinst_DATA = $(MLCUTILS_CMA) # shouldn't be located under lib. XXX libmlcutils_a_SOURCES = $(SOURCES_C) libmlcutils_a_CPPFLAGS = \ + -DCAML_NAME_SPACE \ -I. \ -I$(top_builddir) \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ diff --git a/common/mlvisit/Makefile.am b/common/mlvisit/Makefile.am index 53024a1b2..a07c2827d 100644 --- a/common/mlvisit/Makefile.am +++ b/common/mlvisit/Makefile.am @@ -51,6 +51,7 @@ noinst_DATA = $(MLVISIT_CMA) libmlvisit_a_SOURCES = $(SOURCES_C) libmlvisit_a_CPPFLAGS = \ + -DCAML_NAME_SPACE \ -I. \ -I$(top_builddir) \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ diff --git a/common/mlxml/Makefile.am b/common/mlxml/Makefile.am index 82ab803d1..e56b6fd54 100644 --- a/common/mlxml/Makefile.am +++ b/common/mlxml/Makefile.am @@ -50,6 +50,7 @@ noinst_DATA = $(MLXML_CMA) libmlxml_a_SOURCES = $(SOURCES_C) libmlxml_a_CPPFLAGS = \ + -DCAML_NAME_SPACE \ -I. \ -I$(top_builddir) \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ diff --git a/customize/Makefile.am b/customize/Makefile.am index 9c0012546..4c246b417 100644 --- a/customize/Makefile.am +++ b/customize/Makefile.am @@ -92,6 +92,7 @@ noinst_DATA = $(CUSTOMIZE_CMA) libcustomize_a_SOURCES = $(SOURCES_C) libcustomize_a_CPPFLAGS = \ + -DCAML_NAME_SPACE \ -I. \ -I$(top_builddir) \ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 5d1c222db..49dbf1998 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -239,6 +239,7 @@ guestfsd_LDADD = \ $(OCAML_LIBS) guestfsd_CPPFLAGS = \ + -DCAML_NAME_SPACE \ -I$(shell $(OCAMLC) -where) \ -I$(shell $(OCAMLC) -where)/hivex \ -I$(top_srcdir)/gnulib/lib \ @@ -398,6 +399,7 @@ daemon_utils_tests_SOURCES = \ utils.c \ utils-c.c daemon_utils_tests_CPPFLAGS = \ + -DCAML_NAME_SPACE \ -I. \ -I$(top_builddir) \ -I$(shell $(OCAMLC) -where) \ diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index 4d13eed97..b31e8fc65 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -78,6 +78,7 @@ endif touch $@ libguestfsocaml_a_CPPFLAGS = \ + -DCAML_NAME_SPACE \ -DGUESTFS_PRIVATE=1 \ -I$(top_builddir) -I$(OCAMLLIB) -I$(top_srcdir)/ocaml \ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ diff --git a/v2v/Makefile.am b/v2v/Makefile.am index b5761ef46..277b95c31 100644 --- a/v2v/Makefile.am +++ b/v2v/Makefile.am @@ -179,6 +179,7 @@ bin_PROGRAMS = virt-v2v virt-v2v-copy-to-local virt_v2v_SOURCES = $(SOURCES_C) virt_v2v_CPPFLAGS = \ + -DCAML_NAME_SPACE \ -I. \ -I$(top_builddir) \ -I$(shell $(OCAMLC) -where) \ @@ -254,6 +255,7 @@ virt_v2v_LINK = \ virt_v2v_copy_to_local_SOURCES = \ dummy.c virt_v2v_copy_to_local_CPPFLAGS = \ + -DCAML_NAME_SPACE \ -I. \ -I$(top_builddir) \ -I$(shell $(OCAMLC) -where) \ -- 2.21.0
Richard W.M. Jones
2019-May-28 09:27 UTC
Re: [Libguestfs] [PATCH] build: build C sources using OCaml API with CAML_NAME_SPACE
On Tue, May 28, 2019 at 10:25:53AM +0200, Pino Toscano wrote:> This way no non-namespaced OCaml C symbols are used, reducing the risk > of clashes with other code. > > The only exception is ocaml-augeas, which does not build with > CAML_NAME_SPACE; it will be fixed upstream, and it affects only > ocaml-augeas itself. > --- > builder/Makefile.am | 2 ++ > common/mllibvirt/Makefile.am | 1 + > common/mlpcre/Makefile.am | 1 + > common/mlprogress/Makefile.am | 1 + > common/mltools/Makefile.am | 1 + > common/mlutils/Makefile.am | 1 + > common/mlvisit/Makefile.am | 1 + > common/mlxml/Makefile.am | 1 + > customize/Makefile.am | 1 + > daemon/Makefile.am | 2 ++ > ocaml/Makefile.am | 1 + > v2v/Makefile.am | 2 ++ > 12 files changed, 15 insertions(+) > > diff --git a/builder/Makefile.am b/builder/Makefile.am > index b564fadd6..c7caec5cb 100644 > --- a/builder/Makefile.am > +++ b/builder/Makefile.am > @@ -135,6 +135,7 @@ bin_PROGRAMS += virt-builder virt-builder-repository > > virt_builder_SOURCES = $(SOURCES_C) > virt_builder_CPPFLAGS = \ > + -DCAML_NAME_SPACE \ > -I$(builddir) -I$(srcdir) \ > -I$(top_builddir) \ > -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ > @@ -156,6 +157,7 @@ XOBJECTS = $(BOBJECTS:.cmo=.cmx) > > virt_builder_repository_SOURCES = $(REPOSITORY_SOURCES_C) > virt_builder_repository_CPPFLAGS = \ > + -DCAML_NAME_SPACE \ > -I$(builddir) -I$(srcdir) \ > -I$(top_builddir) \ > -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ > diff --git a/common/mllibvirt/Makefile.am b/common/mllibvirt/Makefile.am > index 12e046c35..181cb9c5c 100644 > --- a/common/mllibvirt/Makefile.am > +++ b/common/mllibvirt/Makefile.am > @@ -59,6 +59,7 @@ noinst_DATA = $(MLLIBVIRT_CMA) > > libmllibvirt_a_SOURCES = $(SOURCES_C) > libmllibvirt_a_CPPFLAGS = \ > + -DCAML_NAME_SPACE \ > -I. \ > -I$(top_builddir) \ > -I$(shell $(OCAMLC) -where) > diff --git a/common/mlpcre/Makefile.am b/common/mlpcre/Makefile.am > index 6f04256da..1e0b7795c 100644 > --- a/common/mlpcre/Makefile.am > +++ b/common/mlpcre/Makefile.am > @@ -49,6 +49,7 @@ noinst_DATA = $(MLPCRE_CMA) > > libmlpcre_a_SOURCES = $(SOURCES_C) > libmlpcre_a_CPPFLAGS = \ > + -DCAML_NAME_SPACE \ > -I. \ > -I$(top_builddir) \ > -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ > diff --git a/common/mlprogress/Makefile.am b/common/mlprogress/Makefile.am > index 9c5ef9baf..d807f6cc8 100644 > --- a/common/mlprogress/Makefile.am > +++ b/common/mlprogress/Makefile.am > @@ -50,6 +50,7 @@ noinst_DATA = $(MLPROGRESS_CMA) > > libmlprogress_a_SOURCES = $(SOURCES_C) > libmlprogress_a_CPPFLAGS = \ > + -DCAML_NAME_SPACE \ > -I. \ > -I$(top_builddir) \ > -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ > diff --git a/common/mltools/Makefile.am b/common/mltools/Makefile.am > index ae78b84b7..ba8630033 100644 > --- a/common/mltools/Makefile.am > +++ b/common/mltools/Makefile.am > @@ -87,6 +87,7 @@ noinst_DATA = $(MLTOOLS_CMA) > > libmltools_a_SOURCES = $(SOURCES_C) > libmltools_a_CPPFLAGS = \ > + -DCAML_NAME_SPACE \ > -I. \ > -I$(top_builddir) \ > -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ > diff --git a/common/mlutils/Makefile.am b/common/mlutils/Makefile.am > index 45f401268..e86d7bb5f 100644 > --- a/common/mlutils/Makefile.am > +++ b/common/mlutils/Makefile.am > @@ -54,6 +54,7 @@ noinst_DATA = $(MLCUTILS_CMA) > # shouldn't be located under lib. XXX > libmlcutils_a_SOURCES = $(SOURCES_C) > libmlcutils_a_CPPFLAGS = \ > + -DCAML_NAME_SPACE \ > -I. \ > -I$(top_builddir) \ > -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ > diff --git a/common/mlvisit/Makefile.am b/common/mlvisit/Makefile.am > index 53024a1b2..a07c2827d 100644 > --- a/common/mlvisit/Makefile.am > +++ b/common/mlvisit/Makefile.am > @@ -51,6 +51,7 @@ noinst_DATA = $(MLVISIT_CMA) > > libmlvisit_a_SOURCES = $(SOURCES_C) > libmlvisit_a_CPPFLAGS = \ > + -DCAML_NAME_SPACE \ > -I. \ > -I$(top_builddir) \ > -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ > diff --git a/common/mlxml/Makefile.am b/common/mlxml/Makefile.am > index 82ab803d1..e56b6fd54 100644 > --- a/common/mlxml/Makefile.am > +++ b/common/mlxml/Makefile.am > @@ -50,6 +50,7 @@ noinst_DATA = $(MLXML_CMA) > > libmlxml_a_SOURCES = $(SOURCES_C) > libmlxml_a_CPPFLAGS = \ > + -DCAML_NAME_SPACE \ > -I. \ > -I$(top_builddir) \ > -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ > diff --git a/customize/Makefile.am b/customize/Makefile.am > index 9c0012546..4c246b417 100644 > --- a/customize/Makefile.am > +++ b/customize/Makefile.am > @@ -92,6 +92,7 @@ noinst_DATA = $(CUSTOMIZE_CMA) > > libcustomize_a_SOURCES = $(SOURCES_C) > libcustomize_a_CPPFLAGS = \ > + -DCAML_NAME_SPACE \ > -I. \ > -I$(top_builddir) \ > -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \ > diff --git a/daemon/Makefile.am b/daemon/Makefile.am > index 5d1c222db..49dbf1998 100644 > --- a/daemon/Makefile.am > +++ b/daemon/Makefile.am > @@ -239,6 +239,7 @@ guestfsd_LDADD = \ > $(OCAML_LIBS) > > guestfsd_CPPFLAGS = \ > + -DCAML_NAME_SPACE \ > -I$(shell $(OCAMLC) -where) \ > -I$(shell $(OCAMLC) -where)/hivex \ > -I$(top_srcdir)/gnulib/lib \ > @@ -398,6 +399,7 @@ daemon_utils_tests_SOURCES = \ > utils.c \ > utils-c.c > daemon_utils_tests_CPPFLAGS = \ > + -DCAML_NAME_SPACE \ > -I. \ > -I$(top_builddir) \ > -I$(shell $(OCAMLC) -where) \ > diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am > index 4d13eed97..b31e8fc65 100644 > --- a/ocaml/Makefile.am > +++ b/ocaml/Makefile.am > @@ -78,6 +78,7 @@ endif > touch $@ > > libguestfsocaml_a_CPPFLAGS = \ > + -DCAML_NAME_SPACE \ > -DGUESTFS_PRIVATE=1 \ > -I$(top_builddir) -I$(OCAMLLIB) -I$(top_srcdir)/ocaml \ > -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \ > diff --git a/v2v/Makefile.am b/v2v/Makefile.am > index b5761ef46..277b95c31 100644 > --- a/v2v/Makefile.am > +++ b/v2v/Makefile.am > @@ -179,6 +179,7 @@ bin_PROGRAMS = virt-v2v virt-v2v-copy-to-local > > virt_v2v_SOURCES = $(SOURCES_C) > virt_v2v_CPPFLAGS = \ > + -DCAML_NAME_SPACE \ > -I. \ > -I$(top_builddir) \ > -I$(shell $(OCAMLC) -where) \ > @@ -254,6 +255,7 @@ virt_v2v_LINK = \ > virt_v2v_copy_to_local_SOURCES = \ > dummy.c > virt_v2v_copy_to_local_CPPFLAGS = \ > + -DCAML_NAME_SPACE \ > -I. \ > -I$(top_builddir) \ > -I$(shell $(OCAMLC) -where) \ACK, thanks. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
Reasonably Related Threads
- [common PATCH] mlv2v: build as OCaml library
- [PATCH] Fix out-of-tree builds of OCaml components
- [PATCH] Fix out-of-tree builds of OCaml components
- [PATCH v3 6/6] build: ignore unused submodules
- [PATCH v6 10/41] mllib, v2v: Split out OCaml utils bindings ‘common/mlutils’.