Creating and building LLVM projects with Eclipse CDT on Windows?

I just downloaded LLVM a couple days ago – I got everything built and installed quite easily using CMake to generate build files for Eclipse CDT + MinGW. That much worked like a charm – but I’ve spent most of the intervening time trying to get a simple project set up. :stuck_out_tongue:

My goal is to create a project consisting of two main parts:

  • A backend for WDC 65816
  • A frontend including a simple programming language and tools for managing generated code

It’s my understanding that it’s necessary to develop the backend as part of the LLVM source tree. The frontend, though, I would like to maintain as a separate project, with as little coupling as possible to the rest of the LLVM source and build configuration.

The problem, though, is that I’m having a heck of a time figuring out how to do this. I started with the “Creating an LLVM Project” documentation:

http://llvm.org/docs/Projects.html

Which advises copying projects/sample to a location of your choosing and modifying it with autoconf. That seems to be a tricky proposition on Windows, though, especially if you want to use Eclipse CDT to build and maintain your project. For one thing, since I built using CMake instead of using the configure script, some files (like Makefile.config in LLVM_OBJ_ROOT) do not exist.``

Eventually I decided to just try compiling the source for Chapter 3 of the Kaleidoscope tutorial directly with GCC. Here was the command line I used:

g++ toy.cpp llvm-config --cxxflags llvm-config --libs core llvm-config --ldflags

This compiled just fine, with no warnings; but when I tried to run the program, as soon as I entered an expression for Kaleidoscope to compile, I got an assert failure like this:

define double @0()Assertion failed: errorcode == 0, file c:/llvm-2.7/lib/System/RWMutex.cpp, line 87

When I built the examples using Eclipse CDT (via the CMake-generated project files), the Kaleidoscope examples all worked perfectly.

So what’s the scoop? Is there any way I can conveniently create a project with Eclipse CDT that uses LLVM? What do I actually need to include and link? Any advice or guidance would be greatly appreciated.

Trip Volpe <mraccident@gmail.com> writes:

[snip]

So what's the scoop? Is there any way I can conveniently create a project
with Eclipse CDT that uses LLVM? What do I actually need to include and
link? Any advice or guidance would be greatly appreciated.

On your Eclipse project:

1. Set the #include paths to where LLVM headers are installed.

2. Set the library paths to where LLVM libraries are installed.

3. On a command shell, run "llvm-config --libs component1 component2.."
replacing the names of the LLVM components you need on your project.

4. Copy the names of the libraries shown on the previous step to your
Eclipse project.

5. If you get weird errors while building or running your project, see
what the LLVM example projects do: run "make VERBOSE=1" to see the full
command line and watch for #define's, system libraries, etc.

6. If you keep having problems with the above, ask for help here
describing what the problem is and listing the output of "make
VERBOSE=1" for at least the compilation of one .cpp file and the link
phase of your project, plus copying&pasting whatever error messages you
see (if gcc outputs one of those enourmous and useless error message
list, reporting the first ten or so is enough.)