CI: Upgrade the Fedora container and fix build failure
cover CI: Upgrade the Fedora container and fix build failure
Hi,
Continuing Andrew's work on refreshing containers in GitLab CI. With Fedora 40, there was a build failure in the ocaml builds. It is due to an unused variable in an ocaml macro when building with "-Werror" . Patch 2 solves the build failure, but I'm unsure if it is the best approach. Ideas welcome.
Andrew Cooper (1):
CI: Refresh and upgrade the Fedora container
Javi Merino (2):
automation: Fix URL to the gitlab container registry documentation ocaml/libs: Fill build failure due to unused variable in ocaml macro
automation/build/README.md | 2 +- automation/build/fedora/29.dockerfile | 46 ----------- automation/build/fedora/40-x86_64.dockerfile | 77 +++++++++++++++++++ automation/gitlab-ci/build.yaml | 8 +- automation/scripts/containerize | 2 +- .../domain_getinfo_stubs_v1.c | 3 + 6 files changed, 86 insertions(+), 52 deletions(-) delete mode 100644 automation/build/fedora/29.dockerfile create mode 100644 automation/build/fedora/40-x86_64.dockerfile
Signature · 1 line
2.46.1
PATCH 3/3 CI: Refresh and upgrade the Fedora container
From: Andrew Cooper <[email protected]>
Fedora 29 is long out of date. Move forward 5 years to Fedora 40.
Include all the usual improvements. Rework the container to be non-root, use heredocs for legibility, and switch to the new naming scheme.
--- automation/build/fedora/29.dockerfile | 46 ------------ automation/build/fedora/40-x86_64.dockerfile | 77 ++++++++++++++++++++ automation/gitlab-ci/build.yaml | 8 +- automation/scripts/containerize | 2 +- 4 files changed, 82 insertions(+), 51 deletions(-) delete mode 100644 automation/build/fedora/29.dockerfile create mode 100644 automation/build/fedora/40-x86_64.dockerfile
automation/build/fedora/29.dockerfile deleted +0 -46
@@ -1,46 +0,0 @@ -# syntax=docker/dockerfile:1 -FROM --platform=linux/amd64 fedora:29 -LABEL maintainer.name="The Xen Project" \ - maintainer.email="[email protected]" - -# install Xen depends -RUN dnf -y install \ - clang \ - gcc \ - gcc-c++ \ - ncurses-devel \ - zlib-devel \ - python-devel \ - python3-devel \ - libuuid-devel \ - pkgconfig \ - flex \ - bison \ - libaio-devel \ - glib2-devel \ - yajl-devel \ - pixman-devel \ - glibc-devel \ - make \ - binutils \ - git \ - wget \ - acpica-tools \ - python-markdown \ - patch \ - checkpolicy \ - dev86 \ - xz-devel \ - bzip2 \ - nasm \ - ocaml \ - ocaml-findlib \ - golang \ - # QEMU - ninja-build \ - && dnf clean all && \ - rm -rf /var/cache/dnf - -RUN useradd --create-home user -USER user -WORKDIR /build
automation/build/fedora/40-x86_64.dockerfile new file +77 -0
77 lines not on this page · raw message
automation/gitlab-ci/build.yaml +4 -4
@@ -579,15 +579,15 @@ debian-bookworm-32-gcc-debug: variables: CONTAINER: debian:bookworm-i386 -fedora-gcc: +fedora-40-x86_64-gcc: extends: .gcc-x86-64-build variables: - CONTAINER: fedora:29 + CONTAINER: fedora:40-x86_64 -fedora-gcc-debug: +fedora-40-x86_64-gcc-debug: extends: .gcc-x86-64-build-debug variables: - CONTAINER: fedora:29 + CONTAINER: fedora:40-x86_64 ubuntu-16.04-x86_64-clang: extends: .clang-x86-64-build
automation/scripts/containerize +1 -1
@@ -28,7 +28,7 @@ case "_${CONTAINER}" in _alpine-arm64v8) CONTAINER="${BASE}/alpine:3.18-arm64v8" ;; _archlinux|_arch) CONTAINER="${BASE}/archlinux:current" ;; _centos7) CONTAINER="${BASE}/centos:7" ;; - _fedora) CONTAINER="${BASE}/fedora:29";; + _fedora) CONTAINER="${BASE}/fedora:40-x86_64";; _bullseye-ppc64le) CONTAINER="${BASE}/debian:11-ppc64le" ;; _bookworm-ppc64le) CONTAINER="${BASE}/debian:12-ppc64le" ;; _bullseye-riscv64) CONTAINER="${BASE}/debian:11-riscv64" ;;
Signature · 1 line
2.46.1
PATCH 1/3 automation: Fix URL to the gitlab container registry documentation
In reply to Javi MerinoThe gitlab documentation is now at
https://docs.gitlab.com/ee/administration/packages/container_registry.html
--- automation/build/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
automation/build/README.md +1 -1
@@ -110,7 +110,7 @@ make -C automation/build opensuse/tumbleweed-x86_64 PUSH=1 [BuildKit]: https://docs.docker.com/build/buildkit/ [registry]: https://gitlab.com/xen-project/xen/container_registry -[registry help]: https://gitlab.com/help/user/project/container_registry +[registry help]: https://docs.gitlab.com/ee/user/packages/container_registry/ Building/Running container for a different architecture
Signature · 1 line
2.46.1
PATCH 2/3 ocaml/libs: Fill build failure due to unused variable in ocaml macro
In reply to Javi MerinoOn Fedora 40, the build fails with:
gcc -m64 -DBUILD_ID -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-but-set-variable -Wno-unused-local-typedefs -Werror -O2 -fomit-frame-pointer -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__ -MMD -MP -MF .domain_getinfo_stubs_v1.o.d -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -fPIC -I/usr/lib64/ocaml -I /build/tools/ocaml/libs/xsd_glue/domain_getinfo_plugin_v1/../../../libs -I /build/tools/ocaml/libs/xsd_glue/domain_getinfo_plugin_v1/../../../libs/xsd_glue -I/build/tools/ocaml/libs/xsd_glue/domain_getinfo_plugin_v1/../../../../../tools/include -D__XEN_TOOLS__ -I/build/tools/ocaml/libs\/xsd_glue/domain_getinfo_plugin_v1/../../../../../tools/include -c -o domain_getinfo_stubs_v1.o domain_getinfo_stubs_v1.c
In file included from domain_getinfo_stubs_v1.c:10:
domain_getinfo_stubs_v1.c: In function 'xsd_glue_failwith':
/usr/lib64/ocaml/caml/memory.h:275:29: error: unused variable 'caml__frame' [-Werror=unused-variable]
275 | struct caml__roots_block *caml__frame = *caml_local_roots_ptr
| ^~~~~~~~~~~
domain_getinfo_stubs_v1.c:48:9: note: in expansion of macro 'CAMLparam0'
48 | CAMLparam0();
| ^~~~~~~~~~
cc1: all warnings being treated as errors
The CAMLparam0 macro is defined in /usr/lib64/ocaml/caml/memory.h:255 as:
#define CAMLparam0() \
struct caml__roots_block** caml_local_roots_ptr = \
(DO_CHECK_CAML_STATE ? Caml_check_caml_state() : (void)0, \
&CAML_LOCAL_ROOTS); \ struct caml__roots_block *caml__frame = *caml_local_roots_ptr
We can't modify the macro. Mark the xsd_glue_failwith() function with ignore "-Wunused-variable" to prevent gcc from failing the build due to the unused variable.
---
While it is not ideal, this is the most effective option I have found that avoids treating warnings as errors. I can add a comment above the pragma explaining why if we decide that this is the way forward.
.../domain_getinfo_plugin_v1/domain_getinfo_stubs_v1.c | 3 +++ 1 file changed, 3 insertions(+)
tools/ocaml/libs/xsd_glue/domain_getinfo_plugin_v1/domain_getinfo_stubs_v1.c +3 -0
@@ -42,6 +42,8 @@ static struct custom_operations xsd_glue_xenctrl_ops = { .compare_ext = custom_compare_ext_default, /* Can't compare */ }; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-variable" static void Noreturn xsd_glue_failwith(xc_interface *xch,const char *func,unsigned int line) {
@@ -70,6 +72,7 @@ static void Noreturn xsd_glue_failwith(caml_raise_with_arg (*caml_named_value ("xsg.error_v1" ), msg); } +#pragma GCC diagnostic pop#define xsd_glue_failwith (xch) xsd_glue_failwith(xch, __func__, __LINE__) CAMLprim value stub_xsd_glue_xc_interface_open(value unit)
Signature · 1 line
2.46.1
Re: [XEN PATCH v1 1/3] automation: Fix URL to the gitlab container registry documentation
In reply to Javi MerinoQuoted 2 lines · Javi Merino
The gitlab documentation is now at
https://docs.gitlab.com/ee/administration/packages/container_registry.html
This link seems to be for self-managed instance of gitlab, but the link in the patch looks fine.
Quoted 1 line
Signed-off-by Javi Merino <[email protected]>
The patch description could be removed, so:
Thanks,
Quoted 17 lines
--- automation/build/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)automation/build/README.md +1
-1@@ -110,7 +110,7 @@ make -C automation/build opensuse/tumbleweed-x86_64 PUSH=1 [BuildKit]: https://docs.docker.com/build/buildkit/ [registry]: https://gitlab.com/xen-project/xen/container_registry -[registry help]: https://gitlab.com/help/user/project/container_registry +[registry help]: https://docs.gitlab.com/ee/user/packages/container_registry/ Building/Running container for a different architecture
Signature · 5 lines
Anthony Perard | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech
Re: [XEN PATCH v1 3/3] CI: Refresh and upgrade the Fedora container
In reply to Javi MerinoQuoted 9 lines · Javi Merino
From: Andrew Cooper <[email protected]>
Fedora 29 is long out of date. Move forward 5 years to Fedora 40.
Include all the usual improvements. Rework the container to be non-root, use heredocs for legibility, and switch to the new naming scheme.
Signed-off-by Andrew Cooper <[email protected]>Signed-off-by Javi Merino <[email protected]>
Thanks,
Signature · 5 lines
Anthony Perard | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech
Re: [XEN PATCH v1 2/3] ocaml/libs: Fill build failure due to unused variable in ocaml macro
In reply to Javi MerinoQuoted 19 lines · Javi Merino
On Fedora 40, the build fails with:
gcc -m64 -DBUILD_ID -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-but-set-variable -Wno-unused-local-typedefs -Werror -O2 -fomit-frame-pointer -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__ -MMD -MP -MF .domain_getinfo_stubs_v1.o.d -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -fPIC -I/usr/lib64/ocaml -I /build/tools/ocaml/libs/xsd_glue/domain_getinfo_plugin_v1/../../../libs -I /build/tools/ocaml/libs/xsd_glue/domain_getinfo_plugin_v1/../../../libs/xsd_glue -I/build/tools/ocaml/libs/xsd_glue/domain_getinfo_plugin_v1/../../../../../tools/include -D__XEN_TOOLS__ -I/build/tools/ocaml/libs\/xsd_glue/domain_getinfo_plugin_v1/../../../../../tools/include -c -o domain_getinfo_stubs_v1.o
domain_getinfo_stubs_v1.c
In file included from domain_getinfo_stubs_v1.c:10:
domain_getinfo_stubs_v1.c: In function 'xsd_glue_failwith':
/usr/lib64/ocaml/caml/memory.h:275:29: error: unused variable 'caml__frame' [-Werror=unused-variable]
275 | structcaml__roots_block*caml__frame=*caml_local_roots_ptr
| ^~~~~~~~~~~
domain_getinfo_stubs_v1.c:48:9: note: in expansion of macro 'CAMLparam0'
48 |CAMLparam0();
| ^~~~~~~~~~
cc1: all warnings being treated as errorsThe CAMLparam0 macro is defined in
/usr/lib64/ocaml/caml/memory.h:255as:#define CAMLparam0() \ struct caml__roots_block** caml_local_roots_ptr = \ (DO_CHECK_CAML_STATE ? Caml_check_caml_state() : (void)0, \ &CAML_LOCAL_ROOTS); \
Quoted 8 lines
struct
caml__roots_block*caml__frame=*caml_local_roots_ptrWe can't modify the macro. Mark the
xsd_glue_failwith()function with ignore "-Wunused-variable" to prevent gcc from failing the build due to the unused variable.Fixes a6576011a4d2 ("ocaml/libs: Implement a dynamically-loaded plugin for Xenctrl.domain_getinfo")Signed-off-by Javi Merino <[email protected]>
That's horrible...
I note the Ocaml manual even says:
"Some C compilers give bogus warnings about unused variables caml__dummy_xxx at each use of CAMLparam and CAMLlocal. You should ignore them." which a brave claim to make...
The problem with pragma gcc is that we support Clang too.
Having had a play, this works too
@@ -45,7 +45,9 @@ static struct custom_operations xsd_glue_xenctrl_ops = { static void Noreturn xsd_glue_failwith(
xc_interface *xch, const char *func, unsigned int line) {
+#define caml__frame __attribute__((unused)) caml__frame CAMLparam0();
+#undef caml__frame
CAMLlocal1(msg);
const xc_error *error = xch ? xc_get_last_error(xch) : NULL; char *str = NULL;
and is rather more selective.
However, looking through other bits of memory.h, there's this gem:
#define CAMLnoreturn ((void) caml__frame)
which has existed since db3745919 "suppression des warnings "unused variable" de gcc" in 2004.
So, I think this is a better fix:
@@ -69,6 +69,7 @@ static void Noreturn xsd_glue_failwith( free(str);
caml_raise_with_arg(*caml_named_value("xsg.error_v1"), msg); + CAMLnoreturn;
}
#define xsd_glue_failwith(xch) xsd_glue_failwith(xch, __func__, __LINE__)
and F40 seem happy with the result.
~Andrew
Re: [XEN PATCH v1 2/3] ocaml/libs: Fill build failure due to unused variable in ocaml macro
Quoted 66 lines · Andrew Cooper
Quoted 19 lines · Javi Merino
On Fedora 40, the build fails with:
gcc -m64 -DBUILD_ID -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-but-set-variable -Wno-unused-local-typedefs -Werror -O2 -fomit-frame-pointer -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__ -MMD -MP -MF .domain_getinfo_stubs_v1.o.d -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -fPIC -I/usr/lib64/ocaml -I /build/tools/ocaml/libs/xsd_glue/domain_getinfo_plugin_v1/../../../libs -I /build/tools/ocaml/libs/xsd_glue/domain_getinfo_plugin_v1/../../../libs/xsd_glue -I/build/tools/ocaml/libs/xsd_glue/domain_getinfo_plugin_v1/../../../../../tools/include -D__XEN_TOOLS__ -I/build/tools/ocaml/libs\/xsd_glue/domain_getinfo_plugin_v1/../../../../../tools/include -c -o domain_getinfo_stubs_v1.o
domain_getinfo_stubs_v1.c
In file included from domain_getinfo_stubs_v1.c:10:
domain_getinfo_stubs_v1.c: In function 'xsd_glue_failwith':
/usr/lib64/ocaml/caml/memory.h:275:29: error: unused variable 'caml__frame' [-Werror=unused-variable]
275 | structcaml__roots_block*caml__frame=*caml_local_roots_ptr
| ^~~~~~~~~~~
domain_getinfo_stubs_v1.c:48:9: note: in expansion of macro 'CAMLparam0'
48 |CAMLparam0();
| ^~~~~~~~~~
cc1: all warnings being treated as errorsThe CAMLparam0 macro is defined in
/usr/lib64/ocaml/caml/memory.h:255as:#define CAMLparam0() \ struct caml__roots_block** caml_local_roots_ptr = \ (DO_CHECK_CAML_STATE ? Caml_check_caml_state() : (void)0, \ &CAML_LOCAL_ROOTS); \Quoted 8 lines
struct
caml__roots_block*caml__frame=*caml_local_roots_ptrWe can't modify the macro. Mark the
xsd_glue_failwith()function with ignore "-Wunused-variable" to prevent gcc from failing the build due to the unused variable.Fixes a6576011a4d2 ("ocaml/libs: Implement a dynamically-loaded plugin for Xenctrl.domain_getinfo")Signed-off-by Javi Merino <[email protected]>That's horrible...
I note the Ocaml manual even says:
"Some C compilers give bogus warnings about unused variables
caml__dummy_xxxat each use of CAMLparam and CAMLlocal. You should ignore them." which a brave claim to make...The problem with pragma gcc is that we support Clang too.
Having had a play, this works too
(quoted diff) +0
-0@@ -45,7 +45,9 @@ static struct custom_operations xsd_glue_xenctrl_ops = {static void Noreturn xsd_glue_failwith(
xc_interface*xch, const char *func, unsigned int line) {
+#definecaml__frame__attribute__((unused))caml__frameCAMLparam0();
+#undefcaml__frame
CAMLlocal1(msg);
constxc_error*error = xch ?xc_get_last_error(xch): NULL; char *str = NULL;and is rather more selective.
However, looking through other bits of
memory.h, there's this gem:#define CAMLnoreturn ((void)
caml__frame)which has existed since
db3745919"suppression des warnings "unused variable" de gcc" in 2004.So, I think this is a better fix:
(quoted diff) +0
-0@@ -69,6 +69,7 @@ static void Noreturn xsd_glue_failwith( free(str);
Quoted 7 lines
caml_raise_with_arg(*caml_named_value("xsg.error_v1"), msg); + CAMLnoreturn;
}
#definexsd_glue_failwith(xch)xsd_glue_failwith(xch, __func__, __LINE__)
and F40 seem happy with the result.
And https://github.com/ocaml/ocaml/pull/13561 to update Ocaml's documentation on the matter.
~Andrew
Stefano Stabellini
Acked-byRe: [XEN PATCH v1 1/3] automation: Fix URL to the gitlab container registry documentation
In reply to Anthony PERARDQuoted 11 lines · Anthony PERARD
Quoted 2 lines · Javi Merino
The gitlab documentation is now at
https://docs.gitlab.com/ee/administration/packages/container_registry.htmlThis link seems to be for self-managed instance of gitlab, but the link in the patch looks fine.
Quoted 1 line
Signed-off-by Javi Merino <[email protected]>The patch description could be removed, so:
Reviewed-by Anthony PERARD <[email protected]>
Quoted 26 lines
Quoted 17 lines
--- automation/build/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)automation/build/README.md +1
-1@@ -110,7 +110,7 @@ make -C automation/build opensuse/tumbleweed-x86_64 PUSH=1 [BuildKit]: https://docs.docker.com/build/buildkit/ [registry]: https://gitlab.com/xen-project/xen/container_registry -[registry help]: https://gitlab.com/help/user/project/container_registry +[registry help]: https://docs.gitlab.com/ee/user/packages/container_registry/ Building/Running container for a different architectureSignature · 5 lines
Anthony Perard | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech
Stefano Stabellini
Acked-byRe: [XEN PATCH v1 3/3] CI: Refresh and upgrade the Fedora container
In reply to Anthony PERARDQuoted 5 lines · Anthony PERARD
Quoted 4 lines · Javi Merino
From: Andrew Cooper <[email protected]>
Fedora 29 is long out of date. Move forward 5 years to Fedora 40.
Quoted 7 lines
Quoted 5 lines
Include all the usual improvements. Rework the container to be non-root, use heredocs for legibility, and switch to the new naming scheme.
Signed-off-by Andrew Cooper <[email protected]>Signed-off-by Javi Merino <[email protected]>Reviewed-by Anthony PERARD <[email protected]>
Assuming it was tested successfully:
Christian Lindig
Acked-byRe: [XEN PATCH v1 2/3] ocaml/libs: Fill build failure due to unused variable in ocaml macro
In reply to Andrew CooperQuoted 15 lines · Andrew Cooper
So, I think this is a better fix:
tools/ocaml/libs/xsd_glue/domain_getinfo_plugin_v1/domain_getinfo_stubs_v1.c +1
-0@@ -69,6 +69,7 @@ static void Noreturn xsd_glue_failwith(free (str);caml_raise_with_arg (*caml_named_value ("xsg.error_v1" ), msg); + CAMLnoreturn; }#define xsd_glue_failwith (xch) xsd_glue_failwith(xch, __func__, __LINE__)
Quoted 1 line
and F40 seem happy with the result.
I like the effort to remove warnings.
— C
Re: [XEN PATCH v1 2/3] ocaml/libs: Fill build failure due to unused variable in ocaml macro
In reply to Andrew CooperQuoted 67 lines · Andrew Cooper
Quoted 19 lines · Javi Merino
On Fedora 40, the build fails with:
gcc -m64 -DBUILD_ID -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-but-set-variable -Wno-unused-local-typedefs -Werror -O2 -fomit-frame-pointer -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__ -MMD -MP -MF .domain_getinfo_stubs_v1.o.d -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -fPIC -I/usr/lib64/ocaml -I /build/tools/ocaml/libs/xsd_glue/domain_getinfo_plugin_v1/../../../libs -I /build/tools/ocaml/libs/xsd_glue/domain_getinfo_plugin_v1/../../../libs/xsd_glue -I/build/tools/ocaml/libs/xsd_glue/domain_getinfo_plugin_v1/../../../../../tools/include -D__XEN_TOOLS__ -I/build/tools/ocaml/libs\/xsd_glue/domain_getinfo_plugin_v1/../../../../../tools/include -c -o domain_getinfo_stubs_v1.o
domain_getinfo_stubs_v1.c
In file included from domain_getinfo_stubs_v1.c:10:
domain_getinfo_stubs_v1.c: In function 'xsd_glue_failwith':
/usr/lib64/ocaml/caml/memory.h:275:29: error: unused variable 'caml__frame' [-Werror=unused-variable]
275 | structcaml__roots_block*caml__frame=*caml_local_roots_ptr
| ^~~~~~~~~~~
domain_getinfo_stubs_v1.c:48:9: note: in expansion of macro 'CAMLparam0'
48 |CAMLparam0();
| ^~~~~~~~~~
cc1: all warnings being treated as errorsThe CAMLparam0 macro is defined in
/usr/lib64/ocaml/caml/memory.h:255as:#define CAMLparam0() \ struct caml__roots_block** caml_local_roots_ptr = \ (DO_CHECK_CAML_STATE ? Caml_check_caml_state() : (void)0, \ &CAML_LOCAL_ROOTS); \Quoted 8 lines
struct
caml__roots_block*caml__frame=*caml_local_roots_ptrWe can't modify the macro. Mark the
xsd_glue_failwith()function with ignore "-Wunused-variable" to prevent gcc from failing the build due to the unused variable.Fixes a6576011a4d2 ("ocaml/libs: Implement a dynamically-loaded plugin for Xenctrl.domain_getinfo")Signed-off-by Javi Merino <[email protected]>That's horrible...
I note the Ocaml manual even says:
"Some C compilers give bogus warnings about unused variables
caml__dummy_xxxat each use of CAMLparam and CAMLlocal. You should ignore them." which a brave claim to make...The problem with pragma gcc is that we support Clang too.
Having had a play, this works too
(quoted diff) +0
-0@@ -45,7 +45,9 @@ static struct custom_operations xsd_glue_xenctrl_ops = {static void Noreturn xsd_glue_failwith(
xc_interface*xch, const char *func, unsigned int line) {
+#definecaml__frame__attribute__((unused))caml__frameCAMLparam0();
+#undefcaml__frame
CAMLlocal1(msg);
constxc_error*error = xch ?xc_get_last_error(xch): NULL; char *str = NULL;and is rather more selective.
However, looking through other bits of
memory.h, there's this gem:#define CAMLnoreturn ((void)
caml__frame)which has existed since
db3745919"suppression des warnings "unused variable" de gcc" in 2004.So, I think this is a better fix:
(quoted diff) +0
-0@@ -69,6 +69,7 @@ static void Noreturn xsd_glue_failwith( free(str);
Quoted 6 lines
caml_raise_with_arg(*caml_named_value("xsg.error_v1"), msg); + CAMLnoreturn;
}
#definexsd_glue_failwith(xch)xsd_glue_failwith(xch, __func__, __LINE__)
Right! I actually tried put a (void)caml__frame to silence the warning, but I didn't think of looking for a macro that would do exactly that.
Do I have to resend the series with your patch, or can you commit it directly?
Cheers,
Javi
Re: [XEN PATCH v1 2/3] ocaml/libs: Fill build failure due to unused variable in ocaml macro
Quoted 65 lines · Javi Merino
Quoted 64 lines · Andrew Cooper
Quoted 19 lines · Javi Merino
On Fedora 40, the build fails with:
gcc -m64 -DBUILD_ID -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wno-unused-but-set-variable -Wno-unused-local-typedefs -Werror -O2 -fomit-frame-pointer -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__ -MMD -MP -MF .domain_getinfo_stubs_v1.o.d -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -fPIC -I/usr/lib64/ocaml -I /build/tools/ocaml/libs/xsd_glue/domain_getinfo_plugin_v1/../../../libs -I /build/tools/ocaml/libs/xsd_glue/domain_getinfo_plugin_v1/../../../libs/xsd_glue -I/build/tools/ocaml/libs/xsd_glue/domain_getinfo_plugin_v1/../../../../../tools/include -D__XEN_TOOLS__ -I/build/tools/ocaml/libs\/xsd_glue/domain_getinfo_plugin_v1/../../../../../tools/include -c -o domain_getinfo_stubs_v1.o
domain_getinfo_stubs_v1.c
In file included from domain_getinfo_stubs_v1.c:10:
domain_getinfo_stubs_v1.c: In function 'xsd_glue_failwith':
/usr/lib64/ocaml/caml/memory.h:275:29: error: unused variable 'caml__frame' [-Werror=unused-variable]
275 | structcaml__roots_block*caml__frame=*caml_local_roots_ptr
| ^~~~~~~~~~~
domain_getinfo_stubs_v1.c:48:9: note: in expansion of macro 'CAMLparam0'
48 |CAMLparam0();
| ^~~~~~~~~~
cc1: all warnings being treated as errorsThe CAMLparam0 macro is defined in
/usr/lib64/ocaml/caml/memory.h:255as:#define CAMLparam0() \ struct caml__roots_block** caml_local_roots_ptr = \ (DO_CHECK_CAML_STATE ? Caml_check_caml_state() : (void)0, \ &CAML_LOCAL_ROOTS); \Quoted 8 lines
struct
caml__roots_block*caml__frame=*caml_local_roots_ptrWe can't modify the macro. Mark the
xsd_glue_failwith()function with ignore "-Wunused-variable" to prevent gcc from failing the build due to the unused variable.Fixes a6576011a4d2 ("ocaml/libs: Implement a dynamically-loaded plugin for Xenctrl.domain_getinfo")Signed-off-by Javi Merino <[email protected]>That's horrible...
I note the Ocaml manual even says:
"Some C compilers give bogus warnings about unused variables
caml__dummy_xxxat each use of CAMLparam and CAMLlocal. You should ignore them." which a brave claim to make...The problem with pragma gcc is that we support Clang too.
Having had a play, this works too
(quoted diff) +0
-0@@ -45,7 +45,9 @@ static struct custom_operations xsd_glue_xenctrl_ops = {static void Noreturn xsd_glue_failwith(
xc_interface*xch, const char *func, unsigned int line) {
+#definecaml__frame__attribute__((unused))caml__frameCAMLparam0();
+#undefcaml__frame
CAMLlocal1(msg);
constxc_error*error = xch ?xc_get_last_error(xch): NULL; char *str = NULL;and is rather more selective.
However, looking through other bits of
memory.h, there's this gem:#define CAMLnoreturn ((void)
caml__frame)which has existed since
db3745919"suppression des warnings "unused variable" de gcc" in 2004.So, I think this is a better fix:
Quoted 11 lines
Quoted 8 lines
(quoted diff) +0
-0@@ -69,6 +69,7 @@ static void Noreturn xsd_glue_failwith( free(str);
caml_raise_with_arg(*caml_named_value("xsg.error_v1"), msg); + CAMLnoreturn;
}
#definexsd_glue_failwith(xch)xsd_glue_failwith(xch, __func__, __LINE__)Right! I actually tried put a (void)caml__frame to silence the warning, but I didn't think of looking for a macro that would do exactly that.
:) It's Ocaml. I had a hunch there'd be something.
Quoted 2 lines
Do I have to resend the series with your patch, or can you commit it directly?
I'll just fold it on commit. No point spending more time on this.
In the meantime, Ocaml upstream have already merged my docs PR about this.
~Andrew