status-im / nimbus-eth1

Nimbus: an Ethereum Execution Client for Resource-Restricted Devices
https://status-im.github.io/nimbus-eth1/
Apache License 2.0
564 stars 109 forks source link

Compiler insanity #1648

Closed mjfh closed 1 month ago

mjfh commented 1 year ago

The following code

import config, core/chain # fails
#import core/chain, config # works

produces something like

[..]

/status/nimbus-eth1/nimbus/confuse.nim(1, 20) Warning: imported and not used: 'chain' [UnusedImport]
/status/nimbus-eth1/vendor/nim-chronos/chronos/apps/http/httptable.nim: In function ‘getInt__OOZvendorZnim45chronosZchronosZappsZhttpZhttpclient_6103’:
/status/nimbus-eth1/vendor/nim-chronos/chronos/apps/http/httptable.nim:82:76: error: incompatible type for argument 1 of ‘value__OOZvendorZnim45chronosZchronosZappsZhttpZhttpclient_6236’
   82 |     res.get()
      |                                                                            ^  
      |                                                                            |
      |                                                                            tyObject_Result__qNfoJ3Kv2ogXLq0YGQ2b5g
/status/nimbus-eth1/vendor/nim-results/results.nim:796:130: note: expected ‘tyObject_Result__36l9bBqN9czMl21017YJSMqg’ but argument is of type ‘tyObject_Result__qNfoJ3Kv2ogXLq0YGQ2b5g’
  796 | func value*[T, E](self: Result[T, E]): T {.inline.} =
      |                                                                                                                                  ^   
Error: execution of an external compiler program 'gcc -c  -w -fmax-errors=3 -pthread -I/status/nimbus-eth1/vendor/nim-libbacktrace -I/status/nimbus-eth1/vendor/nim-libbacktrace/install/usr/include -I/status/nimbus-eth1/vendor/nim-nat-traversal/vendor/miniupnp/miniupnpc/include -I/status/nimbus-eth1/vendor/nim-nat-traversal/vendor/libnatpmp-upstream -DENABLE_STRNATPMPERR -I/status/nimbus-eth1/vendor/nim-bearssl/bearssl/abi/../csources/src/ -I/status/nimbus-eth1/vendor/nim-bearssl/bearssl/abi/../csources/inc/ -I/status/nimbus-eth1/vendor/nim-bearssl/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 -I/status/nimbus-eth1/vendor/nim-zlib/zlib/csources -DHAVE_UNISTD_H -I/status/nimbus-eth1/vendor/nim-kzg4844/kzg4844/csources/blst/bindings -DFIELD_ELEMENTS_PER_BLOB=4096 -I/status/nimbus-eth1/vendor/nim-kzg4844/kzg4844/csources/src/ -DMP_32BIT -I/status/nimbus-eth1/vendor/libtommath -march=native -fno-omit-frame-pointer -g3 -Og -O3 -fno-strict-aliasing -fno-ident   -I/status/nimbus-eth1/vendor/nimbus-build-system/vendor/Nim/lib -I/status/nimbus-eth1/nimbus -o nimcache/debug/confuse/@m..@svendor@snim-chronos@schronos@sapps@shttp@shttptable.nim.c.o nimcache/debug/confuse/@m..@svendor@snim-chronos@schronos@sapps@shttp@shttptable.nim.c' failed with exit code: 1

nim-compile exited abnormally with code 1 at Tue Jul 18 12:29:14

whereas the code

#import config, core/chain # fails
import core/chain, config # works

compiles fine.

This goes along with other errors, maybe related to result.tryGet() (I am working n that.) A dirty fix for this particular one would be changing the line nim-chronos/chronos/apps/http/httptable.nim:80

let res = Base10.decode(uint64, ht.getString(key))

to

var res = Base10.decode(uint64, ht.getString(key))
tersec commented 2 months ago

I can't reproduce this -- what are the specific conditions under which it occurs?

tersec commented 2 months ago

Is this still reproducible now that nimbus-eth1 uses Nim 2.0.6?

jangko commented 1 month ago

Both chain and config have been refactored many times since this issue opened, I don't think this issue still reproducible because we don't know what exactly the problem is.