fluent-bit icon indicating copy to clipboard operation
fluent-bit copied to clipboard

fluent-bit 3.0.3+ fails to build with -Wincompatible-pointer-types and -Wpointer-sign

Open j0057 opened this issue 1 year ago • 1 comments

Bug Report

Describe the bug

When building the fluent-bit AUR package for versions 3.0.3 or 3.0.4 on Archlinux, the build fails with these errors:

/build/fluent-bit/src/src/tls/openssl.c:220:40: error: passing argument 1 of ‘SSL_select_next_proto’ from incompatible pointer type [-Wincompatible-pointer-types]
/usr/include/openssl/ssl.h:828:50: note: expected ‘unsigned char **’ but argument is of type ‘const unsigned char **’
/build/fluent-bit/src/src/tls/openssl.c:222:40: warning: pointer targets in passing argument 3 of ‘SSL_select_next_proto’ differ in signedness [-Wpointer-sign]
/usr/include/openssl/ssl.h:829:55: note: expected ‘const unsigned char *’ but argument is of type ‘char *’

This is code introduced in commits 1feb741e8fcf1667b6c7dcc47da314fa7679b601 and 5340b4c1247615637281c14236be0eb9002d1569.

Is the intention to be able to build with -Wincompatible-pointer-types and -Wpointer-sign, or should I relax the build options for the fluent-bit AUR package?

To Reproduce

  • Clone the fluent-bit AUR package
  • Build on Archlinux with extra-x86_64-build

Your Environment

  • Version used: 3.0.3, 3.0.4
  • Configuration: -
  • Environment name and version (e.g. Kubernetes? What version?): -
  • Server type and version: -
  • Operating System and version: Archlinux, with openssl 3.3.0-1
  • Filters and plugins: -

Additional context

N/A

j0057 avatar May 22 '24 11:05 j0057

Update:

After patching the code to prevent the warnings, the build fails on other warnings, a -Wformat in plugins/kubernetes_events/kubernetes_events.c.

I can't build 3.0.2 either, this used to work before, but in the log file of an earlier build of 3.0.2, the -Wincompatible-pointer-types and -Wpointer-sign warnings were already there, without failing the build. Something must have changed in Archlinux itself.

I'll keep investigating...

j0057 avatar May 24 '24 15:05 j0057

@j0057 could this be due to an upgrade of GCC to 14.1? https://gcc.gnu.org/gcc-14/porting_to.html#warnings-as-errors

Type checking on pointer types (-Werror=incompatible-pointer-types)
GCC no longer allows implicitly casting all pointer types to all other pointer types. This behavior is now restricted to the void * type and its qualified variations. 

I checked with 13.2 and the program still compiles, from 14.1 this warning is now an error so compilation fails.

Javex avatar May 31 '24 11:05 Javex

Yes, that must be it! My last successful builds were on GCC 13.2.

j0057 avatar May 31 '24 15:05 j0057

I've made a PR here that might be able to fix it: https://github.com/fluent/fluent-bit/pull/8901. If nothing else you could probably turn that into a patch for the package to fix it until it's sorted out upstream.

Javex avatar Jun 01 '24 06:06 Javex

Javex changes are working fine in latest Arch

awcator avatar Jun 05 '24 13:06 awcator

Thank you @javex and @edsiper!

j0057 avatar Jun 06 '24 21:06 j0057