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

Support GCC14 #1150

Closed
AlejandroCabeza opened this issue Jul 11, 2024 · 1 comment · Fixed by #1151
Closed

Support GCC14 #1150

AlejandroCabeza opened this issue Jul 11, 2024 · 1 comment · Fixed by #1151

Comments

@AlejandroCabeza
Copy link
Collaborator

AlejandroCabeza commented Jul 11, 2024

Description

Compiling the test binary with gcc14 doesn't work because there's a type issue.

Context

Nim doesn't do C const pointers, and now gcc cares because the BearSSL library (properly, correctly) declares its argument to be a const pointer
Nim compiles through C, so this does matter
addr (of some var Foo) becomes Foo** not const Foo**
and BearSSL wants const Foo**
-- @tersec

see https://github.com/status-im/nim-bearssl/pull/58/files and https://github.com/status-im/nim-bearssl/pull/61/files for how part was already fixed.

There's already a PrngClassPointerConst* {.importc: "const br_prng_class**", header: "bearssl_rand.h", bycopy.} = pointer which is defined manually and then
proc ecKeygen*(rngCtx: PrngClassPointerConst; impl: ptr EcImpl; sk: ptr EcPrivateKey;

is defined in those terms
that's for another keygen. And, yeah, it's arguably a nim-bearssl issue still, just not one anyone else has run across yet
the gimmick here is that it steps outside the Nim type system proper and simply inserts the C const Foo** directly
-- @tersec

Logs

When calling nimble --mm:refc test

~/.cache/nim/testnative_d/@m..@slibp2p@[email protected]: In function ‘random__testrsa_u138’:
~/.cache/nim/testnative_d/@m..@slibp2p@[email protected]:1703:31: error: passing argument 1 of ‘keygen’ from incompatible pointer type [-Wincompatible-pointer-types]
 1703 |                 T7_ = keygen(((br_prng_class**) (&(*rng_p1).vtable)), ((br_rsa_private_key*) ((&(*res).seck))), ((void*) ((&(*res).buffer->data[sko]))), ((br_rsa_public_key*) ((&(*res).pubk))), ((void*) ((&(*res).buffer->data[pko]))), ((unsigned int) (bits_p2)), pubexp_p3);
      |                              ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                               |
      |                               br_prng_class ** {aka struct br_prng_class_ **}
~/.cache/nim/testnative_d/@m..@slibp2p@[email protected]:1703:31: note: expected ‘const br_prng_class **’ {aka ‘const struct br_prng_class_ **’} but argument is of type ‘br_prng_class **’ {aka ‘struct br_prng_class_ **’}
~/.cache/nim/testnative_d/@m..@slibp2p@[email protected]: In function ‘sign__testrsa_u2751’:
~/.cache/nim/testnative_d/@m..@slibp2p@[email protected]:4270:37: error: passing argument 1 of ‘kv->init’ from incompatible pointer type [-Wincompatible-pointer-types]
 4270 |         nimln_(757);    (*kv).init(((br_hash_class**) (&hc.vtable)));
      |                                    ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                     |
      |                                     br_hash_class ** {aka struct br_hash_class_ **}
~/.cache/nim/testnative_d/@m..@slibp2p@[email protected]:4270:37: note: expected ‘const br_hash_class **’ {aka ‘const struct br_hash_class_ **’} but argument is of type ‘br_hash_class **’ {aka ‘struct br_hash_class_ **’}
~/.cache/nim/testnative_d/@m..@slibp2p@[email protected]:4274:31: error: passing argument 1 of ‘kv->update’ from incompatible pointer type [-Wincompatible-pointer-types]
 4274 |                 (*kv).update(((br_hash_class**) (&hc.vtable)), ((void*) ((&message_p1[((NI)0)]))), ((NU) (message_p1Len_0)));
      |                              ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                               |
      |                               br_hash_class ** {aka struct br_hash_class_ **}
~/.cache/nim/testnative_d/@m..@slibp2p@[email protected]:4274:31: note: expected ‘const br_hash_class **’ {aka ‘const struct br_hash_class_ **’} but argument is of type ‘br_hash_class **’ {aka ‘struct br_hash_class_ **’}
compilation terminated due to -fmax-errors=3.
~/.cache/nim/testnative_d/@m..@slibp2p@[email protected]: In function ‘sign__testecnist_u2611’:
~/.cache/nim/testnative_d/@m..@slibp2p@[email protected]:2967:53: error: passing argument 1 of ‘kv->init’ from incompatible pointer type [-Wincompatible-pointer-types]
 2967 |                 nimln_(943);            (*kv).init(((br_hash_class**) (&hc.vtable)));
      |                                                    ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                     |
      |                                                     br_hash_class ** {aka struct br_hash_class_ **}
~/.cache/nim/testnative_d/@m..@slibp2p@[email protected]:2967:53: note: expected ‘const br_hash_class **’ {aka ‘const struct br_hash_class_ **’} but argument is of type ‘br_hash_class **’ {aka ‘struct br_hash_class_ **’}
~/.cache/nim/testnative_d/@m..@slibp2p@[email protected]:2971:39: error: passing argument 1 of ‘kv->update’ from incompatible pointer type [-Wincompatible-pointer-types]
 2971 |                         (*kv).update(((br_hash_class**) (&hc.vtable)), ((void*) ((&message_p1[((NI)0)]))), ((NU) (message_p1Len_0)));
      |                                      ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                       |
      |                                       br_hash_class ** {aka struct br_hash_class_ **}
~/.cache/nim/testnative_d/@m..@slibp2p@[email protected]:2971:39: note: expected ‘const br_hash_class **’ {aka ‘const struct br_hash_class_ **’} but argument is of type ‘br_hash_class **’ {aka ‘struct br_hash_class_ **’}
~/.cache/nim/testnative_d/@m..@slibp2p@[email protected]:2976:71: error: passing argument 1 of ‘kv->update’ from incompatible pointer type [-Wincompatible-pointer-types]
 2976 |                         nimln_(947);                    (*kv).update(((br_hash_class**) (&hc.vtable)), NIM_NIL, ((NU)0));
      |                                                                      ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                       |
      |                                                                       br_hash_class ** {aka struct br_hash_class_ **}
~/.cache/nim/testnative_d/@m..@slibp2p@[email protected]:2976:71: note: expected ‘const br_hash_class **’ {aka ‘const struct br_hash_class_ **’} but argument is of type ‘br_hash_class **’ {aka ‘struct br_hash_class_ **’}
compilation terminated due to -fmax-errors=3.
Error: execution of an external compiler program 'gcc -c  -w -fmax-errors=3 -pthread -I~/.nimble/pkgs2/bearssl-0.2.4-f350e073a33be84afd879416279a4679c227c6d4/bearssl/abi -I~/.nimble/pkgs2/bearssl-0.2.4-f350e073a33be84afd879416279a4679c227c6d4/bearssl/abi/../csources/src/ -I~/.nimble/pkgs2/bearssl-0.2.4-f350e073a33be84afd879416279a4679c227c6d4/bearssl/abi/../csources/inc/ -I~/.nimble/pkgs2/bearssl-0.2.4-f350e073a33be84afd879416279a4679c227c6d4/bearssl/abi/../csources/tools/ -DBR_USE_UNIX_TIME=1 -DBR_USE_URANDOM=1 -DBR_LE_UNALIGNED=1 -DBR_64=1  -DBR_amd64=1 -DBR_INT128=1 -O3 -fno-strict-aliasing -fno-ident -fno-math-errno   -I~/.choosenim/toolchains/nim-2.0.8/lib -I~/Projects/nim-libp2p-2/tests -o ~/.cache/nim/testnative_d/@m..@slibp2p@[email protected] ~/.cache/nim/testnative_d/@m..@slibp2p@[email protected]' failed with exit code: 1


stack trace: (most recent call last)
/tmp/nimblecache-1634003104/nimscriptapi_1746015816.nim(212, 16)
~/Projects/nim-libp2p-2/libp2p.nimble(53, 10) testnativeTask
~/Projects/nim-libp2p-2/libp2p.nimble(36, 3) runTest
~/.choosenim/toolchains/nim-2.0.8/lib/system/nimscript.nim(265, 7) exec
~/.choosenim/toolchains/nim-2.0.8/lib/system/nimscript.nim(265, 7) Error: unhandled exception: FAILED: nim c -d:debug  --styleCheck:usages --styleCheck:error --verbosity:0 --hints:off --skipParentCfg --skipUserCfg -f --threads:on --opt:speed  -d:libp2p_pubsub_sign=true -d:libp2p_pubsub_verify=true   -r  tests/testnative [OSError]
       Tip: 223 messages have been suppressed, use --verbose to show them.
nimscriptwrapper.nim(161) execScript

    Error:  Exception raised during nimble script execution
stack trace: (most recent call last)
/tmp/nimblecache-1634003104/nimscriptapi_1746015816.nim(212, 16)
~/Projects/nim-libp2p-2/libp2p.nimble(95, 3) testTask
~/.choosenim/toolchains/nim-2.0.8/lib/system/nimscript.nim(265, 7) exec
~/.choosenim/toolchains/nim-2.0.8/lib/system/nimscript.nim(265, 7) Error: unhandled exception: FAILED: nimble testnative [OSError]
       Tip: 223 messages have been suppressed, use --verbose to show them.
nimscriptwrapper.nim(161) execScript

    Error:  Exception raised during nimble script execution
@fryorcraken
Copy link

Looks like fix is wip: status-im/nim-bearssl#62

@kaiserd kaiserd moved this from new to In Progress in nim-libp2p Jul 26, 2024
diegomrsantos added a commit that referenced this issue Aug 1, 2024
- Add ubuntu-24-gcc-14 target on CI.
#1156 prevents us from using
only Ubuntu 24.
- Made the changes necessary to support gcc 14. More info on
status-im/nim-bearssl#62

Fixes #1150
@github-project-automation github-project-automation bot moved this from In Progress to done in nim-libp2p Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants