Skip to content
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

How to compile the code in the chapter2? #5

Open
xubenji opened this issue Jun 2, 2022 · 7 comments
Open

How to compile the code in the chapter2? #5

xubenji opened this issue Jun 2, 2022 · 7 comments

Comments

@xubenji
Copy link

xubenji commented Jun 2, 2022

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

@xubenji
Copy link
Author

xubenji commented Jun 2, 2022

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

@Jonathan2251
Copy link
Owner

Jonathan2251 commented Jun 3, 2022 via email

@xubenji
Copy link
Author

xubenji commented Jun 4, 2022

wait.... can you speak chinese?

@xubenji
Copy link
Author

xubenji commented Jun 4, 2022

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?

@xubenji
Copy link
Author

xubenji commented Jun 5, 2022

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?

@xubenji
Copy link
Author

xubenji commented Jun 6, 2022

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

@xubenji
Copy link
Author

xubenji commented Jun 6, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants