Hi all 
I’m new to llvm!
I’m going through the kaleidoscope : compiling llvm IR to object code tutorial, code in the listings breaks and causes a segmentation fault. After some investigation through gdb, probably this constructor call, causing the segfault.
Program received signal SIGSEGV, Segmentation fault.
0x00000000004afee0 in llvm::optional_detail::OptionalStorage<llvm::Reloc::Model, true>::OptionalStorage(llvm::optional_detail::OptionalStorage<llvm::Reloc::Model, true> const&) ()
Source code:
TargetOptions opt;
auto RM = OptionalReloc::Model();
auto TheTargetMachine =
Target->createTargetMachine(TargetTriple, CPU, Features, opt, RM);
Whether this behavior is already notified and is there any workaround available for it ? I would be great to know the root cause for this behavior.
Of course, the kaleidoscope is friendly and good introduction to llvm for beginners, thank you very much for developing 
Thanks for your kind help
Hi there!
Sorry to hear you’re having trouble with the examples & thanks for reaching out.
I’m having some difficulty reproducing the failure mode you described. From the code sample, it sounds like you’re in Chapter 8 and I just took a look at Chapter 8 in my debug build and got this result:
$ ./bin/Kaleidoscope-Ch8
def average(x y) (x + y) * 0.5;
Read function definition:
define double @average(double %x, double %y) {
entry:
%y2 = alloca double
%x1 = alloca double
store double %x, double* %x1
store double %y, double* %y2
%x3 = load double, double* %x1
%y4 = load double, double* %y2
%addtmp = fadd double %x3, %y4
%multmp = fmul double %addtmp, 5.000000e-01
ret double %multmp
}
Any ideas what you might be doing differently that I could do to try to reproduce the failure you’re seeing?
Hi David!
Thanks for reaching out, the codegen part of the tutorial is fine, but when I try to generate the object code file, it throws segfault. Also please note that I’m using release build of llvm, actually I don’t know whether that is the root cause or not.
I also run through valgrind, it seems like a invalid read from stack.
``
Source compile command : clang++ -g -O3 kjit.cpp `llvm-config --cxxflags --ldflags --system-libs --libs all` -o toy
Please, let me know that if you need some additional information :)
Thanks a lot
Still haven’t had much luck reproducing this
Hi David!
Thanks for reaching out, the codegen part of the tutorial is fine, but when I try to generate the object code file, it throws segfault. Also please note that I’m using release build of llvm, actually I don’t know whether that is the root cause or not.
I also run through valgrind, it seems like a invalid read from stack.
``
Source compile command : clang++ -g -O3 kjit.cpp `llvm-config --cxxflags --ldflags --system-libs --libs all` -o toy
Please, let me know that if you need some additional information :)
Thanks a lot
Oh, hmm, this might be that ABI problem https://bugs.llvm.org/show_bug.cgi?id=39427 - if the release you’re using was built with GCC and you’re building your code with Clang, that could be it.
Maybe try building with GCC?