I can get llvm-ir from C code using Clang. I just want to work with LLVM-IR. For my compiler project.
I need to convert LLVM-IR to target machine code or executable.
But I can't convert LLVM-IR to .exe. I downloaded LLVM from official site. But I can't find llc or lli tool. Did I download the wrong one?. I use windows 10.
Yep, there is no llc.exe in Windows binary package. Compile LLVM yourself, this is pretty straightforward.
Related
I am learning LLVMand C++, but I find it hard to import LLVM into my project.
The first problem is my system has already installed clang and clang++ in usr/bin, but the other LLVM which was installed by brew is in /opt/homebrew/opt/llvm, is ok to delete clang in usr/bin and add opt/homebrew/opt/llvm/bin to env variable?
The second problem is how to link LLVM to my VSCode project, I try link LLVM by
#include "/opt/homebrew/opt/llvm/include/llvm/IR/Constants.h"
but it can't work.
Thanks for any help !!!
Never delete system utilities. Of any kind. For any reason.
Read the information presented to you in brew info llvm. This information was shown to you when you installed it.
Don't #include absolute paths.
Learn how to use compiler/linker flags to tell your compiler where to find headers/libraries.
Read the libc++ documentation to learn how to specify a specific libc++.
Finally, use a tool like cmake to automate this for you.
A homespun makefile might be sufficient.
What you are attempting to do is highly non-trivial. As one of the comments suggests, I would also recommend getting familiar with what's baked in before you try switching to a custom version.
I wish to do path profiling. I am using LLVM 4.0. After building and llvm I don't find llvm-prof tool. Is it removed? What are the options available for profiling now? Should I use older versions of LLVM?.
I also don't find profiling passes in /lib/Transformation!
Is there a repository of passes which I can use?
I need to build KLEE on my Ubuntu 12.04. I followed KLEE website's instructions step by step. I had LLVM 2.9 built. But when I need to install klee-uclibc, and in the process of configuring, it complained that it failed to find a working LLVM bitcode compiler. Does this mean that my LLVM built was unsuccessful? I am new to Linux and new to the testing tool. Any help is greatly appreciated.
I ran into the same problem, but a closer look in klee document helped me fix it. Especially look at step (02)(01):
Install llvm-gcc:
Download and install the LLVM 2.9 release of llvm-gcc from here. On an x86-64 Linux platform you are going to need the archive LLVM-GCC 4.2 Front End Binaries for Linux x86-64.
Add llvm-gcc to your PATH. It is important to do this first so that llvm-gcc is found in subsequent configure steps. llvm-gcc will be used later to compile programs that KLEE can execute. Forgetting to add llvm-gcc to your PATH at this point is by far the most common source of build errors reported by new users.
Hence, make sure that llvm-gcc is installed and a PATH is provided to the executable.
I build Clang from sources to ensure I get the latest analysis tools and sanitizers. The tarballs I download are Clang Source Code, LLVM Source Code, Compiler-RT Source Code and LLDB Source Code. The LLVM Download Page also lists a Clang Tools Extra download.
What is in Clang Tools Extra tarball?
You can check it in the official documentation:
extra clang tools documentation
I am trying to compile a 32-bit version (MinGW) of a program I wrote using zlib. Until now, I've never has to compile for 32-bit so the version of zlib I compiled from source (libz.a) is 64-bit. I tried to rerun the makefile in the zlib-1.2.5 directory but it only compiles a 64bit version of libz.a.
I can't seem to find an option to build 32-bit.
Does anyone know how to do this?
Thanks!
Jeffrey Kevin Pry
Checking the configure file, you can see some env.
On 64bit debian, following command line will build the 32bit version of libz
CFLAGS=-m32 ./configure
It turns out I had to get the 32bit version of MinGW and compile it with that. I was using MinGW64.
Using CFLAGS=-32 won't do it for me, configure script still shouts out telling me to use win32/Makefile.gcc instead all the time.
The recent version of zlib is 1.2.11, so it should be minimal gap of difference up until today. Without any context on system, the following might be useful for other users facing this similar problem these days.
I cross compile on Linux (Ubuntu 18.04), and target 32-bit version of zlib to be produced. What I did is as follows.
./configure (this is just to let us have required file to building process, we will be using different Makefile though)
Modify win32/Makefile.gcc for its PREFIX=i686-w64-mingw32- (for 64-bit you change it to PREFIX=x86_64-w64-mingw32-.
make -fwin32/Makefile.gcc
Install to your desire location via make install -fwin32/Makefile.gcc SHARED_MODE=1 INCLUDE_PATH=/tmp/zlib-win32/include LIBRARY_PATH=/tmp/zlib-win32/lib BINARY_PATH=/tmp/zlib-win32/bin. Notice that you need to specify INCLUDE_PATH, LIBRARY_PATH, and BINARY_PATH. BINARY_PATH will contains result .dll file.