Problem with Kaliedoscope examples under Linux

Hi folks.

I’m not new to compiler writing, but I’m a raw beginner with LLVM. I’m running a vanilla Debian Linux system.

I’ve started by working through the Kaliedoscope project, and everything works fine as far as Chapter 3. But with Chapter4, when I try the supplied toy.cpp, with the given command line, I get this:

mike@debian:~/Development/llvm-project/llvm/examples/Kaleidoscope/Chapter4$ clang++ -g toy.cpp llvm-config --cxxflags --ldflags --system-libs --libs core orcjit native -rdynamic -O3 -o toy
In file included from toy.cpp:1:
./…/include/KaleidoscopeJIT.h:25:10: fatal error: ‘llvm/ExecutionEngine/Orc/Shared/ExecutorSymbolDef.h’ file not found
#include “llvm/ExecutionEngine/Orc/Shared/ExecutorSymbolDef.h”
1 error generated.

I would have expected the supplied examples to work pretty much out of the box. But something’s obviously wrong with the #include paths with the given files. Any suggestions?

Cheers, Mike.

Not familiar with the specific tutorial but I think adding --includedir may help.

$ clang++ -g toy.cpp llvm-config --includedir --cxxflags --ldflags --system-libs --libs core orcjit native -rdynamic -O3 -o toy

I’d hope we had a bot building this regularly, I’ll see if we do.

It’s also possible that this header is new and isn’t present in your installed llvm copy, but we can cross that bridge if it comes to it.

We do have some bots building the code portion but this command from the written portion is not automatically checked unfortunately.

I may be mistaken about using --includedir. Since [Kaleidoscope] Add an initial "Building an ORC JIT" tutorial chapter. · llvm/llvm-project@7331cc3 · GitHub it has not been in that command.

It seems like --cxxflags should be providing the include paths, I get this for example:

$ ./bin/llvm-config --cxxflags
-I/home/david.spickett/llvm-project/llvm/include -I/home/david.spickett/build-llvm-aarch64/include -std=c++17  <...>

So you could look at what that’s producing and check there is in fact a file with that name somewhere in those paths.

Ok thanks David, I’ll try that in the morning. It’s a bit late here just now. :slight_smile:
I should have mentioned that this was with a new clone of the project.

— Mike.


This header was added within the last few months ([ORC] Add missing header. · llvm/llvm-project@9382bba · GitHub) so if llvm-config is from an installed llvm, it may not include that header file at all.

It’s likely the text was validated using an llvm built from source, which is what I’d recommend you also do if you aren’t already. Then the built llvm-config will point to a place that has the header you need.

OK David, that sounds like a good explanation and suggestion. While my llvm source was from a new clone, I was running the installed llvm, whatever version Debian installs. Certainly I should run the same version as my source, so I’ll get on with doing a full build from source and use that. That will probably fix the problem. I’ll let you know the results, but that willl probably be tomorrow.

Cheers, Mike (Darwin - UTC+9.5)

Hi again David.

All right, I’ve tried some things, and made some progress, but I’ve got a couple of suggestions too.

I followed the “Building LLVM” instructions to build from source.

cmake -S llvm -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug

That worked fine, and I got a good build. I then did what it suggested:

ninja -C build check-llvm

That worked too, but I think beginners should be warned that it will take a LONG time - hours maybe, and chew up 20 gigs of disk space.

After all that, there’s ambiguity about how to compile the examples, The new contents of the “build” folder also has “examples”. as well as in the initial location
llvm-project/llvm/examples. The doco doesn’t say which directory to use to compile the examples. I’d guess it’s the latter location, but this should be documented.

Than, worse, it can’t find llvm-config. I can see that it’s there, in a number of locations, but where’s it supposed to go? Maybe /usr/bin ?

This all should be described clearly for beginners. I can figure it out, but maybe I shouldn’t have to?

Anyway I’ll keep plugging away tomorrow.

Cheers, Mike.

OK, I now think that to build LLVM and run the examples, I’d need to follow the instructions under “Stand-alone builds” and also build Clang. I could do this, but it would take a while and isn’t really a priority. The currently installed version of LLVM in Debian (1:16.0-57) is working fine, even if there are problems running the examples. (It’s like I want to learn to drive a car, and I want to concentrate on that, and not have to try to build the car first :slight_smile: I just want to learn about LLVM and I can do that fine with what I’ve got.