I am new to llvm so I might be missing a critical step. My system is
Fedora 12 but this also happens in Mac OS X 10.6.2. Here are the
steps I used to compile llvm:
export TARGETS=x86,x86_64,cpp
export INSTALLDIR=/home/rovitotv/llvm
../llvm-2.6/configure --prefix=$INSTALLDIR --enable-bindings=none
--enable-targets=$TARGETS --enable-optimized
--with-llvmgccdir=$INSTALLDIR --with-llvm-externals=/home/rovitotv/
make ENABLE_OPTIMIZED=1
make install
To compile the llvm-gcc4.2-2.6 front end:
../llvm-gcc4.2-2.6/configure --target=i686-pc-linux-gnu
--with-tune=generic --with-arch=pentium4 --prefix=/home/rovitotv/llvm/
--enable-llvm=/home/rovitotv/llvm/ --enable-languages=c,c++
make
make install
Then I make sure that /home/rovitotv/llvm/bin is in my path. At this
point I copy/paste the example in the tutorial chapter 4, please see
code below. I have tried a few different commands to compile, here
are the variations:
g++ -g toy4_new_copy.cpp `llvm-config --cppflags --ldflags --libs core
jit native` -O3 -o toy4
g++ -g toy4.cpp `llvm-config --cppflags --ldflags --libs core jit
interpreter native` -O2 -o toy4
The compile completes with no errors or warnings. When I execute the
program then enter the expression 4+5; I get a seg fault Here is
sample gdb output from a recent run:
(gdb) run
Starting program: /home/rovitotv/prog/llvm-tutorial/toy4
[Thread debugging using libthread_db enabled]
4+5;
Program received signal SIGSEGV, Segmentation fault.
0x080524f0 in llvm::ExecutionEngine::getTargetData (this=0x0)
at /home/rovitotv/llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:167
167 const TargetData *getTargetData() const { return TD; }
Missing separate debuginfos, use: debuginfo-install glibc-2.11-2.i686
libgcc-4.4.2-7.fc12.i686 libstdc++-4.4.2-7.fc12.i686
(gdb) bt
#0 0x080524f0 in llvm::ExecutionEngine::getTargetData (this=0x0)
at /home/rovitotv/llvm/include/llvm/ExecutionEngine/ExecutionEngine.h:167
#1 0x0805201a in main () at toy4_new_copy.cpp:577
(gdb)
Any help you can provide would be much appreciated. Thanks!