Alex Rivera | Logout

How to build LLVM using GCC 4 on Windows?

Asked 2010-01-24T22:54:45.083
15

I have been able to build LLVM 2.6 (the llvm-2.6.tar.gz package) using MinGW GCC 3.4.5. I haven't tested properly, but it seems to work.

The trouble is, I have libraries of my own which don't build using GCC3, but which work fine in GCC4 (template issues). I believe the first official GCC4 version for MinGW is GCC 4.4.0.

EDIT

Decluttered - everything useful in the "tried this tried that" info is now in the answer.

EDIT

Most of this question/answer is redundant with LLVM 2.7 - the standard configure, make routine works fine in MinGW with no hacks or workarounds.

Edit
Report

1 Answer

12

If at first you don't succeed...

I can now build LLVM 2.6 using MinGW GCC 4.4.0, and it isn't too hard once you know how. I still cannot run the DejaGNU tests, though at first sight that shouldn't be that hard - most likely I'll need the CygWin packages for dejagnu and expect. I also haven't built llvm-gcc yet.

Before the step-by-step, here are the three problems...


Problem 1...

Attempting to build llvm using the standard build instructions fails with the following compiler error in Signals.cpp (win32/Program.inc)

llvm[1]: Compiling Signals.cpp for Release build
In file included from Signals.cpp:33:
Win32/Signals.inc: In function 'LONG LLVMUnhandledExceptionFilter(_EXCEPTION_POINTERS*)':
Win32/Signals.inc:234: error: exception handling disabled, use -fexceptions to enable

The workaround is to use "make -k -fexceptions" - answer found in the pure language documentation.


Problem 2...

Even with the first workaround, the following compiler error occurs...

ExternalFunctions.cpp: In function 'bool ffiInvoke(void (*)(), llvm::Function*, const std::vector<llvm::GenericValue, std::allocator<llvm::GenericValue> >&, const llvm::TargetData*, llvm::GenericValue&)':
ExternalFunctions.cpp:207: error: 'alloca' was not declared in this scope

It seems that an option is being specified which disables the "alloca" built-in.

The workaround is to edit the problem file

C:\llvm-2.6\lib\ExecutionEngine\Interpreter\ExternalFunctions.cpp

Just after the "#include <string>" line, insert...

#define alloca __builtin_alloca


Problem 3...

Even with the compilation errors fixed, the example programs won't run. The run-time errors are...

Assertion failed: errorcode == 0, file RWMutex.cpp, line 87

This relates to the use of the pthreads library,

answered 2010-01-30T19:46:57.883

Your Answer