Open tomijaga opened 2 years ago
Thanks for reporting this!
If possible, can you provide the code (or a cut down version of it) that produces the bug, as well as the moc compiler arguments used to compile the code. I'm particularly interested in whether you are interpreting or compiling the code, and for which target.
I think this is the block of code that caused the issue: https://github.com/NatLabs/serde/blob/main/tests/Json.Test.mo#L32
I used this command in the makefile to compile the code: I don't know what you mean by target, but I'm using an m1 mac with Rosetta enabled.
@ggreif https://github.com/dfinity/motoko/issues/3540#issuecomment-1300015568
This shouldn't happen. Can you describe why the problem came and then went away?
After looking at it again. I think the issue is I am trying to compile more that one into an object file.
It works when I remove the tests/*Test.mo
command from the makefile and specify a single file.
Is there a command for compiling multiple files?
I was able to write a bash script that compiles all the test files and runs them individually. https://github.com/NatLabs/serde/blob/main/test.sh
Heh, this must be some old vestige in the moc
compiler. Even I didn't know that you can use it to compile various files into one .wasm
:
test1:
$(shell vessel bin)/moc $(shell vessel sources) -wasi-system-api -o Test.wasm tests/*Test.mo && wasmtime test.wasm && rm -f Test.wasm
This pretty much explains the riddle. Thanks, I believe we can repro this now.
Btw. you can use (gnu-)make
rules to run several tests. Something like
.PHONY: %.tested
%.tested: %Test.mo
$(shell vessel bin)/moc $(shell vessel sources) -wasi-system-api -o $@.wasm $@ && wasmtime $@.wasm && rm -f $@.wasm
might work.
Thanks for the repo! This is indeed a left-over feature from the days when moc was just an interpreter. Maybe we should just refuse more gracefully to handle this when actually compiling...
Yes, we should part from the gcc
idea to compile several files at the same time. The list of sources should have at most one entry.
OOPS! You've triggered a compiler bug. Please report this at https://github.com/dfinity/motoko/issues/new with the following details:
Motoko 0.7.3 (source qwdq7q2n-npg4rjz7-7s76jv69-kbwjwklg)