When I generate LLVM IRL code from C ++, I can use the console command clang++ -emit-llvm –S test.cppto get the test.ll file that I want LLVM IR.
To get the executable file, follow these steps:
llvm-as test.ll → gives me the test.bc. file
llc test.bc --o test.s → gives me the file test.s.
clang++ test.s -o test.native → gives me my own file that I can execute.
For C ++, this works fine.
In theory, should the same steps apply when I write Rust or Python code?
I take Rust code and get LLVM IR by typing rustc test.rs --emit llvm-ir. This again gives me the test.ll file.
For Python, I use "Numba" and get LLVM IR by typing numba --dump-llvm test.py> test.ll, which also gives me the test.ll file.
The steps to create an executable from these .ll files should be the same.
, :
Python
/tmp/test-9aa440.o: In function 'main':
test.bc:(.text+0x67): undefined reference to 'numba_gil_ensure'
test.bc:(.text+0x79): undefined reference to 'numba_unpickle'
test.bc:(.text+0x84): undefined reference to 'PyObject_Str'
test.bc:(.text+0x8f): undefined reference to 'PyString_AsString'
test.bc:(.text+0xa1): undefined reference to 'PySys_WriteStdout'
test.bc:(.text+0xa9): undefined reference to 'Py_DecRef'
test.bc:(.text+0xb1): undefined reference to 'Py_DecRef'
test.bc:(.text+0xbd): undefined reference to 'PySys_WriteStdout'
test.bc:(.text+0xc5): undefined reference to 'numba_gil_release'
test.bc:(.text+0xff): undefined reference to 'numba_gil_ensure'
test.bc:(.text+0x10b): undefined reference to 'PySys_WriteStdout'
test.bc:(.text+0x113): undefined reference to 'numba_gil_release'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
/tmp/main-5e59bd.o: In function ‘main::sum::h514304ffa40dd7c3’:
main.bc:(.text+0xf): undefined reference to ‘core::panicking::panic::h2596388ccef1871c’
/tmp/main-5e59bd.o: In function ‘main’: main.bc:(.text+0x53): undefined reference to ‘std::rt::lang_start::h65647f6e36cffdae’
clang: error: linker command failed with exit code 1 (use -v to see invocation)
, , clang Rust/Python IR LLVM (, PyObject) Python "" Rust), .bc. s - .native.
, IR, ? LLVM IR , , LLVM ?
, LLVMs LLVM IR. , ?
IR - , "" LLVM IR, clang, , - clang?