containerized-data-importer icon indicating copy to clipboard operation
containerized-data-importer copied to clipboard

Go wrapper for libnbd does not compile with GCC 15

Open gruenich opened this issue 2 months ago • 2 comments

What happened: openSuse's CDI package does not build. I updated it to 1.63.1 and the problem persists.

What you expected to happen: Compilation without errors.

How to reproduce it (as minimally and precisely as possible): Build with GCC 15.

Additional context: Part of the output containing the compiler error:

[   15s] + GOFLAGS='-buildmode=pie -mod=vendor'
[   15s] + ./hack/build/build-go.sh build cmd/cdi-apiserver cmd/cdi-cloner cmd/cdi-controller cmd/cdi-importer cmd/cdi-uploadproxy cmd/cdi-uploadserver cmd/cdi-operator tools/cdi-image-size-detection tools/cdi-source-update-poller
[   15s] CDI_CRI: , CDI_CONTAINER_BUILDCMD: buildah
[   74s] # libguestfs.org/libnbd
[   74s] In file included from _cgo_export.c:4:
[   74s] cgo-gcc-export-header-prolog:56:12: error: conflicting types for ‘chunk_callback’; have ‘int(long int *, void *, size_t,  uint64_t,  unsigned int,  int *)’ {aka ‘int(long int *, void *, long unsigned int,  long unsigned int,  unsigned int,  int *)’}
[   74s] In file included from closures.go:32:
[   74s] ../../vendor/libguestfs.org/libnbd/wrappers.h:338:12: note: previous declaration of ‘chunk_callback’ with type ‘int(void)’
[   74s]   338 | extern int chunk_callback ();
[   74s]       |            ^~~~~~~~~~~~~~
[   74s] cgo-gcc-export-header-prolog:57:12: error: conflicting types for ‘completion_callback’; have ‘int(long int *, int *)’
[   74s] ../../vendor/libguestfs.org/libnbd/wrappers.h:345:12: note: previous declaration of ‘completion_callback’ with type ‘int(void)’
[   74s]   345 | extern int completion_callback ();
[   74s]       |            ^~~~~~~~~~~~~~~~~~~
[   74s] cgo-gcc-export-header-prolog:58:12: error: conflicting types for ‘debug_callback’; have ‘int(long int *, char *, char *)’
[   74s] ../../vendor/libguestfs.org/libnbd/wrappers.h:350:12: note: previous declaration of ‘debug_callback’ with type ‘int(void)’
[   74s]   350 | extern int debug_callback ();
[   74s]       |            ^~~~~~~~~~~~~~
[   74s] cgo-gcc-export-header-prolog:59:12: error: conflicting types for ‘extent_callback’; have ‘int(long int *, char *, uint64_t,  uint32_t *, size_t,  int *)’ {aka ‘int(long int *, char *, long unsigned int,  unsigned int *, long unsigned int,  int *)’}
[   74s] ../../vendor/libguestfs.org/libnbd/wrappers.h:356:12: note: previous declaration of ‘extent_callback’ with type ‘int(void)’
[   74s]   356 | extern int extent_callback ();
[   74s]       |            ^~~~~~~~~~~~~~~
[   74s] cgo-gcc-export-header-prolog:60:12: error: conflicting types for ‘list_callback’; have ‘int(long int *, char *, char *)’
[   74s] ../../vendor/libguestfs.org/libnbd/wrappers.h:363:12: note: previous declaration of ‘list_callback’ with type ‘int(void)’
[   74s]   363 | extern int list_callback ();
[   74s]       |            ^~~~~~~~~~~~~
[   74s] cgo-gcc-export-header-prolog:61:12: error: conflicting types for ‘context_callback’; have ‘int(long int *, char *)’
[   74s] ../../vendor/libguestfs.org/libnbd/wrappers.h:369:12: note: previous declaration of ‘context_callback’ with type ‘int(void)’
[   74s]   369 | extern int context_callback ();
[   74s]       |            ^~~~~~~~~~~~~~~~
[   74s] _cgo_export.c:43:5: error: conflicting types for ‘chunk_callback’; have ‘int(long int *, void *, size_t,  uint64_t,  unsigned int,  int *)’ {aka ‘int(long int *, void *, long unsigned int,  long unsigned int,  unsigned int,  int *)’}
[   74s]    43 | int chunk_callback(long int* callbackid, void* subbuf, size_t count, uint64_t offset, unsigned int status, int* error)
[   74s]       |     ^~~~~~~~~~~~~~
[   74s] ../../vendor/libguestfs.org/libnbd/wrappers.h:338:12: note: previous declaration of ‘chunk_callback’ with type ‘int(void)’
[   74s]   338 | extern int chunk_callback ();
[   74s]       |            ^~~~~~~~~~~~~~
[   74s] _cgo_export.c:73:5: error: conflicting types for ‘completion_callback’; have ‘int(long int *, int *)’
[   74s]    73 | int completion_callback(long int* callbackid, int* error)
[   74s]       |     ^~~~~~~~~~~~~~~~~~~
[   74s] ../../vendor/libguestfs.org/libnbd/wrappers.h:345:12: note: previous declaration of ‘completion_callback’ with type ‘int(void)’
[   74s]   345 | extern int completion_callback ();
[   74s]       |            ^~~~~~~~~~~~~~~~~~~
[   74s] _cgo_export.c:94:5: error: conflicting types for ‘debug_callback’; have ‘int(long int *, char *, char *)’
[   74s]    94 | int debug_callback(long int* callbackid, char* context, char* msg)
[   74s]       |     ^~~~~~~~~~~~~~
[   74s] ../../vendor/libguestfs.org/libnbd/wrappers.h:350:12: note: previous declaration of ‘debug_callback’ with type ‘int(void)’
[   74s]   350 | extern int debug_callback ();
[   74s]       |            ^~~~~~~~~~~~~~
[   74s] _cgo_export.c:117:5: error: conflicting types for ‘extent_callback’; have ‘int(long int *, char *, uint64_t,  uint32_t *, size_t,  int *)’ {aka ‘int(long int *, char *, long unsigned int,  unsigned int *, long unsigned int,  int *)’}
[   74s]   117 | int extent_callback(long int* callbackid, char* metacontext, uint64_t offset, uint32_t* entries, size_t nr_entries, int* error)
[   74s]       |     ^~~~~~~~~~~~~~~
[   74s] ../../vendor/libguestfs.org/libnbd/wrappers.h:356:12: note: previous declaration of ‘extent_callback’ with type ‘int(void)’
[   74s]   356 | extern int extent_callback ();
[   74s]       |            ^~~~~~~~~~~~~~~
[   74s] _cgo_export.c:146:5: error: conflicting types for ‘list_callback’; have ‘int(long int *, char *, char *)’
[   74s]   146 | int list_callback(long int* callbackid, char* name, char* description)
[   74s]       |     ^~~~~~~~~~~~~
[   74s] ../../vendor/libguestfs.org/libnbd/wrappers.h:363:12: note: previous declaration of ‘list_callback’ with type ‘int(void)’
[   74s]   363 | extern int list_callback ();
[   74s]       |            ^~~~~~~~~~~~~
[   74s] _cgo_export.c:169:5: error: conflicting types for ‘context_callback’; have ‘int(long int *, char *)’
[   74s]   169 | int context_callback(long int* callbackid, char* name)
[   74s]       |     ^~~~~~~~~~~~~~~~
[   74s] ../../vendor/libguestfs.org/libnbd/wrappers.h:369:12: note: previous declaration of ‘context_callback’ with type ‘int(void)’
[   74s]   369 | extern int context_callback ();
[   74s]       |            ^~~~~~~~~~~~~~~~
[  109s] error: Bad exit status from /var/tmp/rpm-tmp.9BRmDb (%build)

Adding the argment types in wrapper.h is not enough. wrapper.go and bindings.go specify different types. I don't know which one is to prefer.

Environment:

  • CDI version (use kubectl get deployments cdi-deployment -o yaml): 1.63.1
  • Kubernetes version (use kubectl version): N/A
  • DV specification: N/A
  • Cloud provider or hardware configuration: N/A
  • OS (e.g. from /etc/os-release): openSuse Tumbleweed
  • Kernel (e.g. uname -a): N/A
  • Install tools: N/A
  • Others: N/A

gruenich avatar Oct 11 '25 18:10 gruenich

I have to check which is the latest version of the bindings. Have you tried updating the bindings to the latest version to see if that works? We build CDI in a container which has a version of GCC that doesn't exhibit this problem.

awels avatar Oct 13 '25 13:10 awels

I checked the changes in upstream libnbd and could not spot a relevant change.

The issue seems to be somewhere in wrappers.h, wrappers.go, and closures.go.

gruenich avatar Oct 18 '25 18:10 gruenich