views:

201

answers:

4

llvm-config puts -fno-exceptions in the LDFLAGS for linking llvm itself. Am I right in assuming this means that I cannot use normal C++ try/throw blocks in code (such as a new language front-end) that link against the llvm compiler? I'm not talking about programs the compiler produces, but the compiler itself. I do not want to meddle with the output from llvm-config, I am sure -fno-exceptions is there for a reason..

If I wanted to write a new language front-end for LLVM (for a toy language I'm writing) that linked with the other LLVM code, is there a standard way of handling exceptions in the code for the front-end?

A: 

The LLVM documentation should tell you what you need to know about how to use exceptions; I don't know why -fno-exceptions is specified, or whether you can remove it.

Jon Purdy
I did check that, but it seems that that page is for adding exception handling support to the language frontend which we'd write. I was asking about try/throw in the driver code itself.
Sup3rkiddo
Ah, I misunderstood. Mea culpa.
Jon Purdy
+1  A: 

Just because the LLVM code does not use exceptions does not mean the LLVM environment does not have a exception handling mechanism ... I think you are getting confused here.

Hassan Syed
A: 

Adding -fexceptions to LDFLAGS in the source level Makefile.am works, but I am not sure if this is a right thing to do.

Sup3rkiddo
Unwinding the stack through code that isn't designed to handle exceptions can result is some pretty bad leaks and other strange things.
Omnifarious
+1  A: 

LLVM bug 815 has the rationale: the generated EH code was about 10-20% of the entire binary. It also states that there are exceptions in some parts of the code. Hence, it is reasonable to assume your code can also use exceptions.

MSalters