Closed
Description
mytests/mymodule.nim:
# Any code compiles without errors
mytests/test.nim:
import mymodule
At first compile mytests/mymodule.nim
, then compile mytests/test.nim
:
$ ./bin/nimony c -r mytests/mymodule.nim
bin/nimsem --isSystem m nimcache/sysvq0asl.1.nif nimcache/sysvq0asl.2.nif nimcache/sysvq0asl.2.idx.nif
bin/nimsem m nimcache/mym1dun561.1.nif nimcache/mym1dun561.2.nif nimcache/mym1dun561.2.idx.nif
cc -c -Ivendor/mimalloc/include vendor/mimalloc/src/static.c -o nimcache/static.o
bin/hexer --bits:64 nimcache/mym1dun561.2.nif
bin/nifc c --compileOnly --isMain nimcache/mym1dun561.c.nif
cc -c -Imytests nimcache/mym1dun561.c -o nimcache/mym1dun561.o
bin/hexer --bits:64 nimcache/sysvq0asl.2.nif
bin/nifc c --compileOnly nimcache/sysvq0asl.c.nif
cc -c -Imytests nimcache/sysvq0asl.c -o nimcache/sysvq0asl.o
cc -o nimcache/mym1dun561 nimcache/static.o nimcache/mym1dun561.o nimcache/sysvq0asl.o
$ ./bin/nimony c -r mytests/test.nim
bin/nimsem m nimcache/tes9hvujc.1.nif nimcache/tes9hvujc.2.nif nimcache/tes9hvujc.2.idx.nif
bin/hexer --bits:64 nimcache/tes9hvujc.2.nif
bin/nifc c --compileOnly --isMain nimcache/tes9hvujc.c.nif
cc -c -Imytests nimcache/tes9hvujc.c -o nimcache/tes9hvujc.o
cc -o nimcache/tes9hvujc nimcache/static.o nimcache/tes9hvujc.o nimcache/mym1dun561.o nimcache/sysvq0asl.o
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: nimcache/mym1dun561.o:(.tbss+0x0): multiple definition of `NIFC_E
RR_'; nimcache/tes9hvujc.o:(.tbss+0x0): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: nimcache/mym1dun561.o:(.bss+0x0): multiple definition of `cmdCoun
t'; nimcache/tes9hvujc.o:(.bss+0x0): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: nimcache/mym1dun561.o:(.bss+0x8): multiple definition of `cmdLine
'; nimcache/tes9hvujc.o:(.bss+0x8): first defined here
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: nimcache/mym1dun561.o: in function `main':
mym1dun561.c:(.text+0x0): multiple definition of `main'; nimcache/tes9hvujc.o:tes9hvujc.c:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
mytests/test.nim
compiles without error if I delete the cache before compiling it.
When I compile mytests/mymodule.nim
, it is compiled to nimcache/mym1dun561.c
as main module and it has main function.
And when I compile mytests/test.nim
, nimcache/mym1dun561.c
is not updated and nimcache/mym1dun561.o
is reused.
So there are two object files tes9hvujc.o
and mym1dun561.o
contains main
function and linker generates multiple definition error.
Metadata
Metadata
Assignees
Labels
No labels