-
Notifications
You must be signed in to change notification settings - Fork 7
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
Importing the module that was compiled as main module causes link error #716
Comments
Interesting, maybe we have to encode "mainness" in the filename somehow. |
There is similar problem when using mytests/testdefine.nim import std/syncio
proc foo*(): string =
result = when defined(foo): "defined" else: "Not defined"
echo foo() $ rm -rf nimcache/
$ ./bin/nimony c -r mytests/testdefine.nim
bin/nimsem --isSystem m nimcache/sysvq0asl.1.nif nimcache/sysvq0asl.2.nif nimcache/sysvq0asl.2.idx.nif
bin/nimsem m nimcache/syn1lfpjv.1.nif nimcache/syn1lfpjv.2.nif nimcache/syn1lfpjv.2.idx.nif
bin/nimsem m nimcache/tesqq7kqu1.1.nif nimcache/tesqq7kqu1.2.nif nimcache/tesqq7kqu1.2.idx.nif
cc -c -Ivendor/mimalloc/include vendor/mimalloc/src/static.c -o nimcache/static.o
bin/hexer --bits:64 nimcache/tesqq7kqu1.2.nif
bin/nifc c --compileOnly --isMain nimcache/tesqq7kqu1.c.nif
cc -c -Imytests nimcache/tesqq7kqu1.c -o nimcache/tesqq7kqu1.o
bin/hexer --bits:64 nimcache/syn1lfpjv.2.nif
bin/nifc c --compileOnly nimcache/syn1lfpjv.c.nif
cc -c -Imytests nimcache/syn1lfpjv.c -o nimcache/syn1lfpjv.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/tesqq7kqu1 nimcache/static.o nimcache/tesqq7kqu1.o nimcache/syn1lfpjv.o nimcache/sysvq0asl.o
Not defined
$ ./bin/nimony c -r -d:foo mytests/testdefine.nim
make: 'nimcache/tesqq7kqu1.2.idx.nif' is up to date.
make: Nothing to be done for 'all'.
Not defined
$ rm -rf nimcache/
$ ./bin/nimony c -r -d:foo mytests/testdefine.nim
bin/nimsem --d:foo --isSystem m nimcache/sysvq0asl.1.nif nimcache/sysvq0asl.2.nif nimcache/sysvq0asl.2.idx.nif
bin/nimsem --d:foo m nimcache/syn1lfpjv.1.nif nimcache/syn1lfpjv.2.nif nimcache/syn1lfpjv.2.idx.nif
bin/nimsem --d:foo m nimcache/tesqq7kqu1.1.nif nimcache/tesqq7kqu1.2.nif nimcache/tesqq7kqu1.2.idx.nif
cc -c -Ivendor/mimalloc/include vendor/mimalloc/src/static.c -o nimcache/static.o
bin/hexer --bits:64 nimcache/tesqq7kqu1.2.nif
bin/nifc c --compileOnly --isMain nimcache/tesqq7kqu1.c.nif
cc -c -Imytests nimcache/tesqq7kqu1.c -o nimcache/tesqq7kqu1.o
bin/hexer --bits:64 nimcache/syn1lfpjv.2.nif
bin/nifc c --compileOnly nimcache/syn1lfpjv.c.nif
cc -c -Imytests nimcache/syn1lfpjv.c -o nimcache/syn1lfpjv.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/tesqq7kqu1 nimcache/static.o nimcache/tesqq7kqu1.o nimcache/syn1lfpjv.o nimcache/sysvq0asl.o
defined I think caching logic need to care about all command line options that can change generated nif or c files. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mytests/mymodule.nim:
mytests/test.nim:
At first compile
mytests/mymodule.nim
, then compilemytests/test.nim
:mytests/test.nim
compiles without error if I delete the cache before compiling it.When I compile
mytests/mymodule.nim
, it is compiled tonimcache/mym1dun561.c
as main module and it has main function.And when I compile
mytests/test.nim
,nimcache/mym1dun561.c
is not updated andnimcache/mym1dun561.o
is reused.So there are two object files
tes9hvujc.o
andmym1dun561.o
containsmain
function and linker generates multiple definition error.The text was updated successfully, but these errors were encountered: