Toyc-ch1 command not found

I was following the instructions given in the “Chapter 1: Toy Language and AST” tutorial. When I run the following command :

path/to/BUILD/bin/toyc-ch1 test/Examples/Toy/Ch1/ast.toy -emit=ast

I get this error: /home/user3/Desktop/LLVM_OFFICIAL/llvm-project/build/bin/toyc-ch1: No such file or directory

I have build llvm and mlir using following cmake variable values :

cmake -G Ninja -DCMAKE_BUILD_TYPE="Debug"   
-DBUILD_SHARED_LIBS=True 
-DLLVM_USE_SPLIT_DWARF=True   
-DCMAKE_INSTALL_PREFIX="../../_install"   
-DLLVM_OPTIMIZED_TABLEGEN=True 
-DLLVM_BUILD_TESTS=True   
-DLLVM_DEFAULT_TARGET_TRIPLE="riscv64-unknown-elf"   
-DLLVM_TARGETS_TO_BUILD="RISCV" 
-DLLVM_ENABLE_PROJECTS=mlir  ../llvm

Kindly help.

You are likely missing -DLLVM_BUILD_EXAMPLES=1 in your cmake config.

1 Like

I added -DLLVM_BUILD_EXAMPLES=1 and tried building llvm and mlir again. This time I encountered following error :

[3325/4308] Linking CXX executable bin/toyc-ch6
FAILED: bin/toyc-ch6 
.
.
.
/usr/bin/ld: cannot find -lMLIRExecutionEngine

I suppose that if your host machine is not a RISC-V, you also need to build the host target for the execution engine to work.

Alternatively, you can separately build the toyc-ch1 target and skip the ch6 and ch7 that require a JIT.

2 Likes

The error message isn’t great: our cmake should check this before we reach the link step (diagnose at config time).