Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure with stricter C compilers (e.g. GCC 14) #608

Closed
thesamesam opened this issue Dec 1, 2023 · 2 comments · Fixed by #609
Closed

Build failure with stricter C compilers (e.g. GCC 14) #608

thesamesam opened this issue Dec 1, 2023 · 2 comments · Fixed by #609

Comments

@thesamesam
Copy link

thesamesam commented Dec 1, 2023

Modern C compilers are becoming stricter with a variety of changes over the last year or so.

GCC 14 in particular (to be released in ~April 2024) fails to build p11-kit-0.25.3 like:

FAILED: p11-kit/p11-kit.p/import-object.c.o
x86_64-pc-linux-gnu-gcc -m32 -mfpmath=sse -Ip11-kit/p11-kit.p -Ip11-kit -I../p11-kit-0.25.3/p11-kit -I. -I../p11-kit-0.25.3 -Icommon -I../p11-kit-0.25.3/common -I/usr/lib/libffi/include -fdiagnostics-color=al
ways -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -D_GNU_SOURCE -DP11_KIT_FUTURE_UNSTABLE_API -O2 -pipe -march=native -fdiagnostics-color=always '-DBINDIR="/usr/bin"' '-DPRIVATEDIR="/usr/libexec/p11-kit"' '-DSY
SCONFDIR="/etc"' '-DP11_SYSTEM_CONFIG_FILE="/etc/pkcs11/pkcs11.conf"' '-DP11_SYSTEM_CONFIG_MODULES="/etc/pkcs11/modules"' '-DP11_PACKAGE_CONFIG_MODULES="/usr/share/p11-kit/modules"' '-DP11_USER_CONFIG_FILE="~
/.config/pkcs11/pkcs11.conf"' '-DP11_USER_CONFIG_MODULES="~/.config/pkcs11/modules"' '-DP11_MODULE_PATH="/usr/lib/pkcs11"' -MD -MQ p11-kit/p11-kit.p/import-object.c.o -MF p11-kit/p11-kit.p/import-object.c.o.d
 -o p11-kit/p11-kit.p/import-object.c.o -c ../p11-kit-0.25.3/p11-kit/import-object.c
../p11-kit-0.25.3/p11-kit/import-object.c: In function ‘add_attrs_pubkey_rsa’:
../p11-kit-0.25.3/p11-kit/import-object.c:223:62: error: passing argument 3 of ‘p11_asn1_read’ from incompatible pointer type [-Wincompatible-pointer-types]
  223 |         attr_modulus.pValue = p11_asn1_read (asn, "modulus", &attr_modulus.ulValueLen);
      |                                                              ^~~~~~~~~~~~~~~~~~~~~~~~
      |                                                              |
      |                                                              long unsigned int *
In file included from ../p11-kit-0.25.3/p11-kit/import-object.c:53:
../p11-kit-0.25.3/common/asn1.h:60:62: note: expected ‘size_t *’ {aka ‘unsigned int *’} but argument is of type ‘long unsigned int *’
   60 |                                                      size_t *length);
      |                                                      ~~~~~~~~^~~~~~
../p11-kit-0.25.3/p11-kit/import-object.c:229:70: error: passing argument 3 of ‘p11_asn1_read’ from incompatible pointer type [-Wincompatible-pointer-types]
  229 |         attr_exponent.pValue = p11_asn1_read (asn, "publicExponent", &attr_exponent.ulValueLen);
      |                                                                      ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                      |
      |                                                                      long unsigned int *
../p11-kit-0.25.3/common/asn1.h:60:62: note: expected ‘size_t *’ {aka ‘unsigned int *’} but argument is of type ‘long unsigned int *’
   60 |                                                      size_t *length);
      |                                                      ~~~~~~~~^~~~~~
../p11-kit-0.25.3/p11-kit/import-object.c: In function ‘add_attrs_pubkey_ec’:
../p11-kit-0.25.3/p11-kit/import-object.c:264:78: error: passing argument 3 of ‘p11_asn1_read’ from incompatible pointer type [-Wincompatible-pointer-types]
  264 |         attr_ec_params.pValue = p11_asn1_read (info, "algorithm.parameters", &attr_ec_params.ulValueLen);
      |                                                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                              |
      |                                                                              long unsigned int *
../p11-kit-0.25.3/common/asn1.h:60:62: note: expected ‘size_t *’ {aka ‘unsigned int *’} but argument is of type ‘long unsigned int *’
   60 |                                                      size_t *length);
      |                                                      ~~~~~~~~^~~~~~

Originally reported downstream in Gentoo at https://bugs.gentoo.org/918982.

This can be emulated with -Werror=incompatible-pointer-types -Werror=implicit -Werror=int-conversion on an older GCC or Clang.

ueno added a commit to ueno/p11-kit that referenced this issue Dec 2, 2023
The build fails when compiling for 32-bit platforms with
-Werror=incompatible-pointer-types:

  CFLAGS="-m32 -march=i686 -Werror=incompatible-pointer-types -Werror=implicit -Werror=int-conversion" setarch i686 -- meson setup _build
  setarch i686 -- meson compile -C _build -v
  ...

  ../p11-kit/import-object.c: In function ‘add_attrs_pubkey_rsa’:
  ../p11-kit/import-object.c:223:62: error: passing argument 3 of ‘p11_asn1_read’ from incompatible pointer type [-Werror=incompatible-pointer-types]
    223 |         attr_modulus.pValue = p11_asn1_read (asn, "modulus", &attr_modulus.ulValueLen);
        |                                                              ^~~~~~~~~~~~~~~~~~~~~~~~
        |                                                              |
        |                                                              long unsigned int *

Reported by Sam James in:
p11-glue#608

Signed-off-by: Daiki Ueno <ueno@gnu.org>
@ueno
Copy link
Member

ueno commented Dec 2, 2023

Thanks for the report; #609 should fix it. I guess we should enable 32-bit build in our CI to catch this kind of problems.

@thesamesam
Copy link
Author

Thank you! Yeah, that's a good idea. I haven't looked at your CI setup but I can look at doing that if you need me to.

The patch works for me, the quick response is really appreciated as going through quite a few of these.

ueno added a commit to ueno/p11-kit that referenced this issue Dec 4, 2023
The build fails when compiling for 32-bit platforms with
-Werror=incompatible-pointer-types:

  CFLAGS="-m32 -march=i686 -Werror=incompatible-pointer-types -Werror=implicit -Werror=int-conversion" setarch i686 -- meson setup _build
  setarch i686 -- meson compile -C _build -v
  ...

  ../p11-kit/import-object.c: In function ‘add_attrs_pubkey_rsa’:
  ../p11-kit/import-object.c:223:62: error: passing argument 3 of ‘p11_asn1_read’ from incompatible pointer type [-Werror=incompatible-pointer-types]
    223 |         attr_modulus.pValue = p11_asn1_read (asn, "modulus", &attr_modulus.ulValueLen);
        |                                                              ^~~~~~~~~~~~~~~~~~~~~~~~
        |                                                              |
        |                                                              long unsigned int *

Reported by Sam James in:
p11-glue#608

Signed-off-by: Daiki Ueno <ueno@gnu.org>
ueno added a commit to ueno/p11-kit that referenced this issue Dec 4, 2023
The build fails when compiling for 32-bit platforms with
-Werror=incompatible-pointer-types:

  CFLAGS="-m32 -march=i686 -Werror=incompatible-pointer-types -Werror=implicit -Werror=int-conversion" setarch i686 -- meson setup _build
  setarch i686 -- meson compile -C _build -v
  ...

  ../p11-kit/import-object.c: In function ‘add_attrs_pubkey_rsa’:
  ../p11-kit/import-object.c:223:62: error: passing argument 3 of ‘p11_asn1_read’ from incompatible pointer type [-Werror=incompatible-pointer-types]
    223 |         attr_modulus.pValue = p11_asn1_read (asn, "modulus", &attr_modulus.ulValueLen);
        |                                                              ^~~~~~~~~~~~~~~~~~~~~~~~
        |                                                              |
        |                                                              long unsigned int *

Reported by Sam James in:
p11-glue#608

Signed-off-by: Daiki Ueno <ueno@gnu.org>
@ueno ueno closed this as completed in #609 Dec 4, 2023
ueno added a commit that referenced this issue Dec 4, 2023
The build fails when compiling for 32-bit platforms with
-Werror=incompatible-pointer-types:

  CFLAGS="-m32 -march=i686 -Werror=incompatible-pointer-types -Werror=implicit -Werror=int-conversion" setarch i686 -- meson setup _build
  setarch i686 -- meson compile -C _build -v
  ...

  ../p11-kit/import-object.c: In function ‘add_attrs_pubkey_rsa’:
  ../p11-kit/import-object.c:223:62: error: passing argument 3 of ‘p11_asn1_read’ from incompatible pointer type [-Werror=incompatible-pointer-types]
    223 |         attr_modulus.pValue = p11_asn1_read (asn, "modulus", &attr_modulus.ulValueLen);
        |                                                              ^~~~~~~~~~~~~~~~~~~~~~~~
        |                                                              |
        |                                                              long unsigned int *

Reported by Sam James in:
#608

Signed-off-by: Daiki Ueno <ueno@gnu.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants