You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I try to compile with GCC, I could see this error.
root@79bff74f036a:~/elfconv/bin# TARGET=Wasi ./elfconv.sh ../examples/mnist-neural-network-plain-c/mnist
[INFO] ELF -> LLVM bitcode...
elflift: /__w/cxx-common/cxx-common/vcpkg/buildtrees/llvm-16/src/org-16.0.5-90a3d25b70.clean/llvm/lib/IR/Instructions.cpp:631: void llvm::CallInst::init(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*>>, const llvm::Twine&): Assertion `(Args.size() == FTy->getNumParams() || (FTy->isVarArg() &&Args.size() >FTy->getNumParams())) && "Calling a function with bad signature!"' failed../elfconv.sh: line 22: 399 Aborted (core dumped) ./elflift --arch aarch64 --bc_out lift.bc --target_elf "$ELFPATH" --dbg_fun_cfg "$2" --target_arch "$wasi32_target_arch"[INFO] LLVM bitcode (lift.bc) was generated.[INFO] Compiling to Wasm (for WASI)... clang++: error: no such file or directory: 'lift.bc'[INFO] exe.wasm was generated.rm: cannot remove '/root/elfconv/bin/lift.bc': No such file or directory
So, I tried to cross-compile to aarch64 with clang-16 on x86 environment, elfconv container. It converted properly, but It cannot read files. This happens not only in this file, I tried with below test code but it couldn't find or create test_file.txt.
#include<unistd.h>#include<fcntl.h>intmain() {
// Open or create a test fileintfd=open("/root/elfconv/bin/test_file.txt", O_WRONLY | O_CREAT, 0644);
if (fd<0) {
return1; // Error opening file
}
// Write some data to the file (minimal write syscall)write(fd, "Hello, fsync!", 13);
// Call fsync to flush changes to diskfsync(fd);
// Close the fileclose(fd);
return0;
}
This is mnist-neural-network-plain-c test error log. I also tried move exe.wasm to mnist-neural-network-plain-c folder but nothing changed.
root@79bff74f036a:~/elfconv/examples/mnist-neural-network-plain-c# clang-16 -static --target=aarch64-linux-gnu --gcc-toolchain=/usr --sysroot=/usr/aarch64-linux-gnu mnist.c mnist_file.c neural_network.c -lm -o mnist -fuse-ld=lld;
root@79bff74f036a:~/elfconv/examples/mnist-neural-network-plain-c# ls
Makefile README.md data include mnist mnist.c mnist_file.c neural_network.c
root@79bff74f036a:~/elfconv/examples/mnist-neural-network-plain-c# cd ../../bin
root@79bff74f036a:~/elfconv/bin# ls
a.out core.399 elfconv.sh elflift exe.html exe.wasm test.c
root@79bff74f036a:~/elfconv/bin# TARGET=Wasi ./elfconv.sh ../examples/mnist-neural-network-plain-c/mnist
[INFO] ELF -> LLVM bitcode...
[INFO] Opt Pass 1: [874/874]
[INFO] Opt Pass 2: [874/874]
[INFO] LLVM bitcode (lift.bc) was generated.
[INFO] Compiling to Wasm (for WASI)...
[INFO] exe.wasm was generated.
root@79bff74f036a:~/elfconv/bin# wasmtime exe.wasm
openat error!: No such file or directory
Could not open file: data/train-images-idx3-ubyte
openat error!: No such file or directory
Could not open file: data/t10k-images-idx3-ubyte
Error: failed to run main module `exe.wasm`
Caused by:
0: failed to invoke command default
1: error while executing at wasm backtrace:
0: 0x1cf7d7 - exe.wasm!__remill_read_memory_8
1: 0x1407af - exe.wasm!neural_network_training_step_____1172_23a174
2: 0x13fe58 - exe.wasm!main_____1183_239418
3: 0x13fa9a - exe.wasm!__wrap_main
4: 0x1cfb99 - exe.wasm!__remill_function_call
5: 0xabb4c - exe.wasm!__libc_start_call_main_____1151_23a7b0
6: 0xa8b41 - exe.wasm!__libc_start_main_impl_____1149_23a840
7: 0x1b2f32 - exe.wasm!_start_____1191_239180
8: 0x1ce064 - exe.wasm!main
9: 0x1fe07e - exe.wasm!__main_void
10: 0x18fe - exe.wasm!_start
note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
2: memory fault at wasm address 0x7476e202 in linear memory of size 0x40290000
3: wasm trap: out of bounds memory access
The text was updated successfully, but these errors were encountered:
I think that we cannot execute examples/mnist-neural-network-plain-c on the latest commit by recently adding an optimization pass for LLVM IR (e.g. #53), but you will execute at least on the 8a236da as demo shows.
It is not hard work to fix for executing mnist-NN, so I will fix it soon.
However, we should be able to execute the simple file I/O program like the one you showed.
Generally, we need to explicitly indicate what path of the host filesystem is mapped inside the target Wasm when executing by WASI runtime because WASI security is based on capability-based security. Can you try the command wasmtime --dir=. exe.wasm? (it may be good to refer this).
If it still doesn't work with that command, please attach the binary file to this issue.
Oh, I understand. It is running on sandbox so I have to connect file manually. I tried wasmtime --dir=. exe.wasm but it cannot read files so I tried with absolute path wasmtime --dir=/root/elfconv/bin exe.wasm and it worked! Thank you 👍
If I try to compile with GCC, I could see this error.
So, I tried to cross-compile to aarch64 with clang-16 on x86 environment, elfconv container. It converted properly, but It cannot read files. This happens not only in this file, I tried with below test code but it couldn't find or create
test_file.txt
.This is
mnist-neural-network-plain-c
test error log. I also tried moveexe.wasm
tomnist-neural-network-plain-c
folder but nothing changed.The text was updated successfully, but these errors were encountered: