Jonathan2251/lbd

How to compile the code in the chapter2?

Opened this issue · 7 comments

Hello, Jonathan. You tell us how to transfer the LLVM IR into the target CPU instructions in this http://jonathan2251.github.io/lbd/llvmstructure.html. I learned a lot. but I am still confused that how to compile the code in chapter2. Could you list the steps to compile the code in chapter2? Thank you very much!

Benji Xu

root@localhost:~/llvm/lbd/lbdex# bash build-cpu0.sh
~/llvm-project/test  ~/llvm/lbd/lbdex
~ /llvm/lbd/lbdex
cp: target '/root/llvm-project/test/llvm/.' is not a directory
cp: cannot create directory '/root/llvm-project/test/llvm/lib/Target/.': No such file or directory
cp: cannot create directory '/root/llvm-project/test/llvm/test/CodeGen/.': No such file or directory
OS = Linux
~/llvm-project/test ~/llvm/lbd/lbdex
CMake Error: The source directory "/root/llvm-project/test/llvm" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
ninja: error: loading 'build.ninja': No such file or directory
~/llvm/lbd/lbdex
root@localhost:~/llvm/lbd/lbdex# mkdir /root/llvm-project/test
mkdir: cannot create directory ‘/root/llvm-project/test’: File exists
root@localhost:~/llvm/lbd/lbdex# cd /root/llvm-project/test/
root@localhost:~/llvm-project/test# ls
build  clang  llvm
root@localhost:~/llvm-project/test# cd llvm
-bash: cd: llvm: No such file or directory
root@localhost:~/llvm-project/test# file llvm
llvm: broken symbolic link to ../llvm-project/llvm

wait.... can you speak chinese?

I git clone the llvm-project and lbd. I follow the tutorial in the page to install the llvm by running the install-llvm.sh.

`root@localhost:/home/backend# ls

lbd llvm-project

root@localhost:/home/backend# file llvm-project/test/llvm
llvm-project/test/llvm: broken symbolic link to ../llvm-project/llvm

root@localhost:/home/backend# cp -rf lbd/lbdex/llvm/modify/llvm/* llvm-project/test/llvm
cp: target 'llvm-project/test/llvm' is not a directory

root@localhost:/home/backend# cd lbd/lbdex/install_llvm/
root@localhost:/home/backend/lbd/lbdex/install_llvm# bash build-llvm.sh
`

Then, I got this error:
`CMake Error at lib/Support/CMakeLists.txt:292 (get_property):
get_property could not find TARGET Terminfo::terminfo. Perhaps it has not
yet been created.

CMake Error at lib/Support/CMakeLists.txt:294 (get_library_name):
get_library_name Function invoked with incorrect arguments for function
named: get_library_name`

How can we solve this problem?

Hello, Jonathan.
After I built the llvm with the build-llvm.sh, I found that there is no bin directory in the ${LLVM_RELEASE_DIR}. I only can find the bin directory in ${LLVM_RELEASE_DIR}/build/
Is this an error?

After I compiled the llvm with readme in lbd, I was going to check the cpu0 keyword with this command:
grep -R "cpu0" ~/llvm/test/llvm/include
Then, I found this

`root@vultr:~# cp -rf /root/lbd/lbdex/llvm/modify/llvm/* /root/llvm/test/llvm/.

root@vultr:~# grep -R "cpu0" ~/llvm/test/llvm/include
/root/llvm/test/llvm/include/llvm/ADT/Triple.h:#undef cpu0
/root/llvm/test/llvm/include/llvm/ADT/Triple.h: cpu0, // For Tutorial Backend Cpu0
/root/llvm/test/llvm/include/llvm/ADT/Triple.h: cpu0el,
/root/llvm/test/llvm/include/llvm/Object/ELFObjectFile.h: return "ELF32-cpu0";
/root/llvm/test/llvm/include/llvm/Object/ELFObjectFile.h: return IsLittleEndian ? Triple::cpu0el : Triple::cpu0;
/root/llvm/test/llvm/include/llvm/IR/IntrinsicsCpu0.td:def int_cpu0_gcd : GCCBuiltin<"__builtin_cpu0_gcd">,`

The output is a little bit different from the tutorial on this page:
https://jonathan2251.github.io/lbd/llvmstructure.html#clang

Hello, Jonathan
I generated the chp3.cp0.s file. Then, I was going to check this file with the llvm-objdump. But I failed...
This is the error info:
root@vultr:~/llvm/test/build# bin/llvm-objdump -h ch3.cp0.s bin/llvm-objdump: error: 'ch3.cp0.s': The file was not recognized as a valid object file
Why the llvm-objdump output this?