Bug 2108425 - compile of libguestfs-1.48.4 fails with Error: static declaration of ‘caml_alloc_initialized_string’ follows non-static declaration
Summary: compile of libguestfs-1.48.4 fails with Error: static declaration of ‘caml_al...
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libguestfs
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Richard W.M. Jones
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-07-19 04:49 UTC by weiguihua
Modified: 2022-07-20 10:03 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-07-20 10:03:02 UTC
Embargoed:


Attachments (Terms of Use)

Description weiguihua 2022-07-19 04:49:21 UTC
Description of problem:
In my project, I disabled ocaml use flag, compile of libguestfs-1.48.4 fails with Error: static declaration of ‘caml_alloc_initialized_string’ follows non-static declaration

This is the excerpt of the build log:

ocamlfind mklib  \
    augeas.cmx libmlaugeas_a-augeas-c.o -cclib -laugeas -o mlaugeas
make[2]: Leaving directory '/usr1/zhudan/DataEnableEngine/3rd/src/guestfs/libguestfs-1.48.4/bundled/ocaml-augeas'
Making all in common/mlpcre
make[2]: Entering directory '/usr1/zhudan/DataEnableEngine/3rd/src/guestfs/libguestfs-1.48.4/common/mlpcre'
  CC       libmlpcre_a-pcre-c.o
pcre-c.c:47:1: error: static declaration of ‘caml_alloc_initialized_string’ follows non-static declaration
 caml_alloc_initialized_string (mlsize_t len, const char *p)
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from pcre-c.c:31:0:
/usr/lib64/ocaml/caml/alloc.h:35:18: note: previous declaration of ‘caml_alloc_initialized_string’ was here
 CAMLextern value caml_alloc_initialized_string (mlsize_t len, const char *);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [Makefile:1024: libmlpcre_a-pcre-c.o] Error 1
make[2]: Leaving directory '/usr1/zhudan/DataEnableEngine/3rd/src/guestfs/libguestfs-1.48.4/common/mlpcre'
make[1]: *** [Makefile:1086: all-recursive] Error 1
make[1]: Leaving directory '/usr1/zhudan/DataEnableEngine/3rd/src/guestfs/libguestfs-1.48.4'
make: *** [Makefile:992: all] Error 2

Can I disable ocaml when compile of libguestfs-1.48.4?

Version-Release number of selected component (if applicable):
libguestfs 1.48.4

How reproducible:


Steps to Reproduce:
1. ./configure CFLAGS="-O2 -fPIC -fstack-protector-strong" LDFLAGS="-pie -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack" \
      --disable-daemon --disable-appliance --disable-ocaml \
      --disable-erlang --disable-gobject --disable-golang \
      --disable-haskell --disable-lua --disable-perl \
      --disable-php --disable-ruby --disable-python
2. make


Actual results:


Expected results:


Additional info:

Comment 1 Richard W.M. Jones 2022-07-19 09:07:37 UTC
The ./configure script is meant to detect if caml_alloc_initialized_string is
present in the OCaml version you are using and only substitute it if it's
not present.  See:
https://github.com/libguestfs/libguestfs/blob/master/m4/guestfs-ocaml.m4#L163

What is the output of ./configure?

> Can I disable ocaml when compile of libguestfs-1.48.4?

No, it's required to compile the daemon.  Anyway it should easy to fix
this if you look at what ./configure is doing.

Comment 2 weiguihua 2022-07-20 02:07:04 UTC
(In reply to Richard W.M. Jones from comment #1)
> The ./configure script is meant to detect if caml_alloc_initialized_string is
> present in the OCaml version you are using and only substitute it if it's
> not present.  See:
> https://github.com/libguestfs/libguestfs/blob/master/m4/guestfs-ocaml.m4#L163
> 
> What is the output of ./configure?
> 
> > Can I disable ocaml when compile of libguestfs-1.48.4?
> 
> No, it's required to compile the daemon.  Anyway it should easy to fix
> this if you look at what ./configure is doing.

It says using --disable-ocaml only disables the bindings and OCaml tools in operation manual. When using --disable-ocaml, the chek for existence of this function is never run.
And caml_alloc_initialized_string function definition in pcre-c.c has same name with the function in /usr/lib64/ocaml/caml/alloc.h

I found a post with the same question, but that libguestfs version is 1.46.0: https://bugs.gentoo.org/820053

Please check it.

Comment 3 Richard W.M. Jones 2022-07-20 10:03:02 UTC
Should be fixed in:

https://github.com/libguestfs/libguestfs/commit/adfaf25a12b97b18f8a22d96803cd0920bfd25f7 (development branch)

https://github.com/libguestfs/libguestfs/commit/f162e47ecfee711f2c3bcc761de17e502fe7ab5e (stable branch)

Note that OCaml is required for building libguestfs.  The
./configure --disable-ocaml option only disables the bindings
(which is pretty pointless IMHO, but it's there in case you want it).


Note You need to log in before you can comment on or make changes to this bug.