Open liquidev opened 5 years ago
Can you paste the output of nim -v
and gcc -v
? I have tested on Fedora 29 and the code above works as expected. What command are you using to compile?
I installed the latest development build of Nim yesterday (0.19.9). Not sure about the gcc version, I'll check back later when I get back home. Also using Fedora 29. I'm using the following command to compile my code:
$ nim c -r wrentest.nim
I'll try updating gcc and report back on the issue.
On a fresh install of fedora 29:
> yum install git gcc
> curl https://nim-lang.org/choosenim/init.sh -sSf | sh # install choosenim
> choosenim devel
> nimble install wren
> vim test.nim # pasted your code above
> nim c -r test.nim
[echo] "Hello, World!"
WREN_RESULT_SUCCESS
Also tested on stable:
> choosenim stable
Switched to Nim 0.19.2
> nim c -r test.nim
[echo] "Hello, World!"
WREN_RESULT_SUCCESS
Your nim compiler seems to be generating different code, in your paste above you have NTI_jkZaaPp7ATeGOEOHyTyOdg_.size = sizeof(struct WrenConfiguration);
, but in the same file after compiling I have NTI_jkZaaPp7ATeGOEOHyTyOdg_.size = sizeof(WrenConfiguration);
(after compiling on devel and stable). Maybe you have an old version of the nim compiler being used accidentally?
The version is not old, for sure, this is the output of nim -v
:
Nim Compiler Version 0.19.9 [Linux: amd64]
Compiled at 2019-01-22
Copyright (c) 2006-2018 by Andreas Rumpf
active boot switches: -d:release
gcc -v
:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --enable-libmpx --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 8.2.1 20181215 (Red Hat 8.2.1-6) (GCC)
I recompiled Nim today using choosenim update devel
.
Can't reproduce this
I was able to reproduce this on WIndows 10 - it seems to be that nimgen is generating
WrenConfiguration* {.importc: "struct WrenConfiguration", header: headerlibwren,
bycopy.} = object
and
WrenForeignClassMethods* {.importc: "struct WrenForeignClassMethods",
header: headerlibwren, bycopy.} = object
I'm guessing something is up in the cfg file - I will look into fixing this.
This might be due to https://github.com/nim-lang/c2nim/issues/150.
You might want to try updating to the latest c2nim.
That's interesting, will reopen this issue now and try to reproduce.
@genotrance is there a nice way of asserting a minimum version of c2nim
in nimgen
?
Can confirm, that after installing the latest c2nim, this problem no longer presents itself. Thanks for the tip @genotrance .
I just tried installing the Nimble package, and I tried to run the following source code:
However, this error popped up during compilation: